Skip to content

Commit 4b00b22

Browse files
committed
Remove the ostream from Transaction; fix SST API
1 parent c06b896 commit 4b00b22

7 files changed

+45
-23
lines changed

MemoryController.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void MemoryController::receiveFromBus(BusPacket *bpacket)
114114
}
115115

116116
//add to return read data queue
117-
returnTransaction.push_back(new Transaction(RETURN_DATA, bpacket->physicalAddress, bpacket->data,dramsim_log));
117+
returnTransaction.push_back(new Transaction(RETURN_DATA, bpacket->physicalAddress, bpacket->data));
118118
totalReadsPerBank[SEQUENTIAL(bpacket->rank,bpacket->bank)]++;
119119

120120
// this delete statement saves a mindboggling amount of memory
@@ -650,8 +650,7 @@ void MemoryController::update()
650650
{
651651
if (DEBUG_BUS)
652652
{
653-
PRINTN(" -- MC Issuing to CPU bus : ");
654-
returnTransaction[0]->print();
653+
PRINTN(" -- MC Issuing to CPU bus : " << *returnTransaction[0]);
655654
}
656655
totalTransactions++;
657656

@@ -701,8 +700,7 @@ void MemoryController::update()
701700
PRINT("== Printing transaction queue");
702701
for (size_t i=0;i<transactionQueue.size();i++)
703702
{
704-
PRINTN(" " << i << "]");
705-
transactionQueue[i]->print();
703+
PRINTN(" " << i << "] "<< *transactionQueue[i]);
706704
}
707705
}
708706

MemorySystem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ bool MemorySystem::WillAcceptTransaction()
177177
bool MemorySystem::addTransaction(bool isWrite, uint64_t addr)
178178
{
179179
TransactionType type = isWrite ? DATA_WRITE : DATA_READ;
180-
Transaction *trans = new Transaction(type,addr,NULL,dramsim_log);
180+
Transaction *trans = new Transaction(type,addr,NULL);
181181
// push_back in memoryController will make a copy of this during
182182
// addTransaction so it's kosher for the reference to be local
183183

MultiChannelMemorySystem.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ ostream &MultiChannelMemorySystem::getLogFile()
421421
{
422422
return dramsim_log;
423423
}
424+
bool MultiChannelMemorySystem::addTransaction(const Transaction &trans)
425+
{
426+
// copy the transaction and send the pointer to the new transaction
427+
return addTransaction(new Transaction(trans));
428+
}
429+
424430
bool MultiChannelMemorySystem::addTransaction(Transaction *trans)
425431
{
426432
unsigned channelNumber = findChannelNumber(trans->address);

MultiChannelMemorySystem.h

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class MultiChannelMemorySystem : public SimulatorObject
4545
MultiChannelMemorySystem(const string &dev, const string &sys, const string &pwd, const string &trc, unsigned megsOfMemory, string *visFilename=NULL, const IniReader::OverrideMap *paramOverrides=NULL);
4646
virtual ~MultiChannelMemorySystem();
4747
bool addTransaction(Transaction *trans);
48+
bool addTransaction(const Transaction &trans);
4849
bool addTransaction(bool isWrite, uint64_t addr);
4950
bool willAcceptTransaction();
5051
bool willAcceptTransaction(uint64_t addr);

TraceBasedSim.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ int main(int argc, char **argv)
552552
if (line.size() > 0)
553553
{
554554
data = parseTraceFileLine(line, addr, transType,clockCycle, traceType,useClockCycle);
555-
trans = new Transaction(transType, addr, data, dramsim_logfile);
555+
trans = new Transaction(transType, addr, data);
556556
alignTransactionAddress(*trans);
557557

558558
if (i>=clockCycle)

Transaction.cpp

+28-11
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,46 @@
3737
#include "Transaction.h"
3838
#include "PrintMacros.h"
3939

40-
using namespace DRAMSim;
41-
using namespace std;
40+
using std::endl;
41+
using std::hex;
42+
using std::dec;
4243

43-
Transaction::Transaction(TransactionType transType, uint64_t addr, void *dat, ostream &dramsim_log_) :
44-
dramsim_log(dramsim_log_),
44+
namespace DRAMSim {
45+
46+
Transaction::Transaction(TransactionType transType, uint64_t addr, void *dat) :
4547
transactionType(transType),
4648
address(addr),
4749
data(dat)
4850
{}
4951

50-
void Transaction::print()
52+
Transaction::Transaction(const Transaction &t)
53+
: transactionType(t.transactionType)
54+
, address(t.address)
55+
, data(NULL)
56+
, timeAdded(t.timeAdded)
57+
, timeReturned(t.timeReturned)
5158
{
52-
if (transactionType == DATA_READ)
59+
#ifndef NO_STORAGE
60+
ERROR("Data storage is really outdated and these copies happen in an \n improper way, which will eventually cause problems. Please send an \n email to dramninjas [at] gmail [dot] com if you need data storage");
61+
abort();
62+
#endif
63+
}
64+
65+
ostream &operator<<(ostream &os, const Transaction &t)
66+
{
67+
if (t.transactionType == DATA_READ)
5368
{
54-
PRINT("T [Read] [0x" << hex << address << "]" << dec );
69+
os<<"T [Read] [0x" << hex << t.address << "]" << dec <<endl;
5570
}
56-
else if (transactionType == DATA_WRITE)
71+
else if (t.transactionType == DATA_WRITE)
5772
{
58-
PRINT("T [Write] [0x" << hex << address << "] [" << dec << data << "]" );
73+
os<<"T [Write] [0x" << hex << t.address << "] [" << dec << t.data << "]" <<endl;
5974
}
60-
else if (transactionType == RETURN_DATA)
75+
else if (t.transactionType == RETURN_DATA)
6176
{
62-
PRINT("T [Data] [0x" << hex << address << "] [" << dec << data << "]" );
77+
os<<"T [Data] [0x" << hex << t.address << "] [" << dec << t.data << "]" <<endl;
6378
}
79+
return os;
80+
}
6481
}
6582

Transaction.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "SystemConfiguration.h"
3939
#include "BusPacket.h"
4040

41-
using namespace std;
41+
using std::ostream;
4242

4343
namespace DRAMSim
4444
{
@@ -51,7 +51,6 @@ enum TransactionType
5151

5252
class Transaction
5353
{
54-
ostream &dramsim_log;
5554
Transaction();
5655
public:
5756
//fields
@@ -62,10 +61,10 @@ class Transaction
6261
uint64_t timeReturned;
6362

6463

64+
friend ostream &operator<<(ostream &os, const Transaction &t);
6565
//functions
66-
Transaction(TransactionType transType, uint64_t addr, void *data, ostream &dramsim_log_);
67-
68-
void print();
66+
Transaction(TransactionType transType, uint64_t addr, void *data);
67+
Transaction(const Transaction &t);
6968

7069
BusPacketType getBusPacketType()
7170
{
@@ -107,6 +106,7 @@ class Transaction
107106
}
108107
}
109108
};
109+
110110
}
111111

112112
#endif

0 commit comments

Comments
 (0)