Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/AddressMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*********************************************************************************/

#include "AddressMapping.h"

#include <bitset>
#include <iostream>

#include "AddressMapping.h"
#include "SystemConfiguration.h"
#include "Utils.h"

Expand All @@ -49,6 +48,7 @@ AddrMapping::AddrMapping()
rankBitWidth = uLog2(getConfigParam(UINT, "NUM_RANKS"));
bankBitWidth = uLog2(getConfigParam(UINT, "NUM_BANKS"));
bankgroupBitWidth = uLog2(getConfigParam(UINT, "NUM_BANK_GROUPS"));
//subarrayBitWidth = uLog2(getConfigParam(UINT, "NUM_SUBARRAYS")); //how we make, how about we use ...
rowBitWidth = uLog2(getConfigParam(UINT, "NUM_ROWS"));
colBitWidth = uLog2(getConfigParam(UINT, "NUM_COLS"));
byteOffsetWidth = uLog2(getConfigParam(UINT, "JEDEC_DATA_BUS_BITS") / 8);
Expand All @@ -70,6 +70,18 @@ bool AddrMapping::isSameBankgroup(int bank0, int bank1)
{
return bankgroupId(bank0) == bankgroupId(bank1);
}
unsigned AddrMapping::findsubarray(unsigned row)
{
if(row < 0x2000) return 0;
else if(row<0x4000) return 1;
else if(row<0x6000) return 2;
else return 3;
}

bool AddrMapping::isSameSubarray(int row, int sub)
{
return findsubarray(row) == sub;
}

void AddrMapping::addressMapping(uint64_t physicalAddress, unsigned& newTransactionChan,
unsigned& newTransactionRank, unsigned& newTransactionBank,
Expand Down Expand Up @@ -172,7 +184,7 @@ void AddrMapping::addressMapping(uint64_t physicalAddress, unsigned& newTransact
newTransactionChan = diffBitWidth(&physicalAddress, channelBitWidth);
}
// clone of scheme 5, but channel moved to lower bits
else if (addressMappingScheme == Scheme7)
else if (addressMappingScheme == Scheme7) //how about using this logic?
{
// row:col:rank:bank:chan
newTransactionChan = diffBitWidth(&physicalAddress, channelBitWidth);
Expand Down
4 changes: 3 additions & 1 deletion src/AddressMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ class AddrMapping
}

unsigned bankgroupId(int bank);
static unsigned findsubarray(unsigned row);
bool isSameBankgroup(int bank0, int bank1);

bool isSameSubarray(int row, int sub);
private:
uint64_t transactionSize;
uint64_t transactionMask;
uint64_t channelBitWidth;
uint64_t rankBitWidth;
uint64_t bankBitWidth;
uint64_t subarrayBitWidth;
uint64_t bankgroupBitWidth;
uint64_t rowBitWidth;
uint64_t colBitWidth;
Expand Down
66 changes: 36 additions & 30 deletions src/Bank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*********************************************************************************/

#include "Bank.h"

#include <memory>

#include "Bank.h"
#include "BusPacket.h"

using namespace std;
Expand Down Expand Up @@ -73,11 +72,12 @@ shared_ptr<Bank::DataStruct> Bank::searchForRow(unsigned row, shared_ptr<DataStr
head = head->next;
}
// if we get here, didn't find it
return NULL;
return NULL;
}

void Bank::read(BusPacket* busPacket)
{
//cout<<"Bank::read() and busPacket->bank is "<<busPacket->bank<<" and row is "<<busPacket->row<<" and col is " <<busPacket->column<<" and bank's entry is "<<numCols<<endl;
shared_ptr<DataStruct> rowHeadNode = rowEntries[busPacket->column];
shared_ptr<DataStruct> foundNode = NULL;
if ((foundNode = Bank::searchForRow(busPacket->row, rowHeadNode)) == NULL)
Expand All @@ -88,46 +88,52 @@ void Bank::read(BusPacket* busPacket)
*(busPacket->data) = foundNode->data;
}
}

//i'd like to use this logic same as subarray....
void Bank::write(const BusPacket* busPacket)
{
// TODO: move all the error checking to BusPacket so once we have a bus
// packet,
// we know the fields are all legal

if (busPacket->column >= numCols)
{
ERROR("== Error - Bus Packet column " << busPacket->column << " out of bounds");
exit(-1);
//cout<<"== Error - Bus Packet column " << busPacket->column << " out of bounds and num_col is " <<numCols<<endl;
//ERROR("== Error - Bus Packet column " << busPacket->column << " out of bounds");
//exit(-1);
return;
}

// head of the list we need to search
shared_ptr<DataStruct> rowHeadNode = rowEntries[busPacket->column];
shared_ptr<DataStruct> foundNode = NULL;
if ((foundNode = Bank::searchForRow(busPacket->row, rowHeadNode)) == NULL)
{
// not found
shared_ptr<DataStruct> newRowNode = make_shared<DataStruct>();
// DataStruct* newRowNode = (DataStruct*)malloc(sizeof(DataStruct));
uintptr_t const_addr = 0x55ffffff;
uintptr_t addr = reinterpret_cast<uintptr_t>(busPacket->data);
//cout<<"busPacket->row: "<<busPacket->row<<" and bank is "<<busPacket->bank<<" and col is "<<busPacket->column<<endl;
if(addr>const_addr)
{
if ((foundNode = Bank::searchForRow(busPacket->row, rowHeadNode)) == NULL)
{
// not found
shared_ptr<DataStruct> newRowNode = make_shared<DataStruct>();
// DataStruct* newRowNode = (DataStruct*)malloc(sizeof(DataStruct));

// insert at the head for speed
// TODO: Optimize this data structure for speedier lookups?
newRowNode->row = busPacket->row;
if (busPacket->data)
newRowNode->data = *(busPacket->data);
newRowNode->next = rowHeadNode;
rowEntries[busPacket->column] = newRowNode;
}
else
{
// found it, just plaster in the new data
foundNode->data = *(busPacket->data);
if (DEBUG_BANKS)
// insert at the head for speed
// TODO: Optimize this data structure for speedier lookups?
newRowNode->row = busPacket->row;
if(busPacket->data)
newRowNode->data = *(busPacket->data);
newRowNode->next = rowHeadNode;
rowEntries[busPacket->column] = newRowNode;
}
else
{
PRINTN(" -- Bank " << busPacket->bank << " writing to physical address 0x" << hex
<< busPacket->physicalAddress << dec << ":");
busPacket->printData();
PRINT("");
// found it, just plaster in the new data
foundNode->data = *(busPacket->data);
if (DEBUG_BANKS)
{
PRINTN(" -- Bank " << busPacket->bank << " writing to physical address 0x" << hex
<< busPacket->physicalAddress << dec << ":");
busPacket->printData();
PRINT("");
}
}
}
}
5 changes: 3 additions & 2 deletions src/Bank.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "BusPacket.h"
#include "SimulatorObject.h"
#include "SystemConfiguration.h"
#include "SubArray.h"

namespace DRAMSim
{
Expand All @@ -51,21 +52,21 @@ class Bank
BurstType data;
std::shared_ptr<struct _DataStruct> next;
} DataStruct;

//how about use this in subarray level logic?
public:
// functions
Bank(ostream& simLog);

void read(BusPacket* busPacket);
void write(const BusPacket* busPacket);
BankState currentState;
unsigned numCols;

private:
// private member
std::vector<std::shared_ptr<DataStruct>> rowEntries;
ostream& dramsimLog;
static std::shared_ptr<DataStruct> searchForRow(unsigned row, std::shared_ptr<DataStruct> head);
unsigned numCols;
};
} // namespace DRAMSim

Expand Down
8 changes: 7 additions & 1 deletion src/BankState.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#ifndef BANKSTATE_H
#define BANKSTATE_H

#include <string>
#include <vector>

#include "BusPacket.h"
#include "SystemConfiguration.h"

Expand All @@ -42,7 +45,7 @@ enum CurrentBankState
RowActive,
Precharging,
Refreshing,
PowerDown
PowerDown,
};

class BankState
Expand All @@ -52,10 +55,13 @@ class BankState
public:
// Fields
CurrentBankState currentBankState;
//vector<CurrentBankState> currentBankStates;
unsigned openRowAddress;
//vector<unsigned> openRowAddresses; //exactly subsel....
uint64_t nextRead;
uint64_t nextWrite;
uint64_t nextActivate;
uint64_t nextSubSel; //subsel logic with activation....
uint64_t nextPrecharge;
uint64_t nextPowerUp;
BusPacketType lastCommand;
Expand Down
16 changes: 13 additions & 3 deletions src/Burst.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>

#include "FP16.h"
#include "npy.h"
Expand Down Expand Up @@ -169,7 +170,6 @@ union BurstType
fp16Data_[i] = (fp16)dis(gen);
}
}

string binToStr() const
{
stringstream ss;
Expand Down Expand Up @@ -300,7 +300,15 @@ union BurstType

return sum[0];
}

fp16 fp16max()
{
float maxValue = convertH2F(fp16Data_[0]);
for(int i = 1; i < 16; i++)
{
maxValue = std::max(maxValue, convertH2F(fp16Data_[i]));
}
return convertF2H(maxValue);
}
float fp32ReduceSum()
{
float sum = 0.0;
Expand Down Expand Up @@ -340,13 +348,15 @@ union BurstType
return ret;
}

fp16 fp16Data_[16];
uint8_t u8Data_[32];
float fp32Data_[8];
uint32_t u32Data_[8];
uint16_t u16Data_[16];
fp16 fp16Data_[16];
};



struct NumpyBurstType
{
vector<unsigned long> shape;
Expand Down
13 changes: 13 additions & 0 deletions src/BusPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ BusPacket::BusPacket(BusPacketType packtype, uint64_t physicalAddr, unsigned col
{
}

/*BusPacket::BusPacket(BusPacketType packtype, uint64_t physicalAddr, unsigned col, unsigned rw, unsigned r,
unsigned b, unsigned s, BurstType* dat, ostream& simLog, std::string tg)
: dramsimLog(simLog),
BusPacketType(packtype),
column(col),
row(rw),
subarray(s),
bank(b),
physicalAddress(physicalAddr),
data(dat),
tag(tg)
{
} //nothing help b*/
void BusPacket::print(uint64_t currentClockCycle, bool dataStart)
{
if (VERIFICATION_OUTPUT)
Expand Down
7 changes: 5 additions & 2 deletions src/BusPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ enum BusPacketType
PRECHARGE, // 3
REF, // 4
DATA, // 5
RFCSB
RFCSB,
SUBSEL
};

class BusPacket
Expand All @@ -57,10 +58,12 @@ class BusPacket
public:
// Fields
BusPacketType busPacketType;
unsigned column;
unsigned column; //important problem: buspacket has 256bit wide -->need cell logic
unsigned row;
unsigned subarray; //or psub; designate psub area by
unsigned bank;
unsigned rank;
unsigned chan;
uint64_t physicalAddress;
BurstType* data;
std::string tag;
Expand Down
1 change: 0 additions & 1 deletion src/CSVWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
Expand Down
Loading