46
46
#include " MemorySystem.h"
47
47
#include " MultiChannelMemorySystem.h"
48
48
#include " Transaction.h"
49
+ #include " IniReader.h"
49
50
50
51
51
52
using namespace DRAMSim ;
@@ -138,13 +139,13 @@ class TransactionReceiver
138
139
void usage ()
139
140
{
140
141
cout << " DRAMSim2 Usage: " << endl;
141
- cout << " DRAMSim -t tracefile -s system.ini -d ini/device.ini [-c #] [-p pwd] [-q] [-S 2048] [-n] [-o OPTION_A=1234]" <<endl;
142
+ cout << " DRAMSim -t tracefile -s system.ini -d ini/device.ini [-c #] [-p pwd] [-q] [-S 2048] [-n] [-o OPTION_A=1234,tRC=14,tFAW=19 ]" <<endl;
142
143
cout << " \t -t, --tracefile=FILENAME \t specify a tracefile to run " <<endl;
143
144
cout << " \t -s, --systemini=FILENAME \t specify an ini file that describes the memory system parameters " <<endl;
144
145
cout << " \t -d, --deviceini=FILENAME \t specify an ini file that describes the device-level parameters" <<endl;
145
146
cout << " \t -c, --numcycles=# \t\t specify number of cycles to run the simulation for [default=30] " <<endl;
146
147
cout << " \t -q, --quiet \t\t\t flag to suppress simulation output (except final stats) [default=no]" <<endl;
147
- cout << " \t -o, --option=OPTION_A=234\t\t\t overwrite any ini file option from the command line" <<endl;
148
+ cout << " \t -o, --option=OPTION_A=234,tFAW=14 \t\t\t overwrite any ini file option from the command line" <<endl;
148
149
cout << " \t -p, --pwd=DIRECTORY\t\t Set the working directory (i.e. usually DRAMSim directory where ini/ and results/ are)" <<endl;
149
150
cout << " \t -S, --size=# \t\t\t Size of the memory system in megabytes [default=2048M]" <<endl;
150
151
cout << " \t -n, --notiming \t\t\t Do not use the clock cycle information in the trace file" <<endl;
@@ -331,6 +332,40 @@ void alignTransactionAddress(Transaction &trans)
331
332
trans.address >>= throwAwayBits;
332
333
trans.address <<= throwAwayBits;
333
334
}
335
+
336
+ /* *
337
+ * Override options can be specified on the command line as -o key1=value1,key2=value2
338
+ * this method should parse the key-value pairs and put them into a map
339
+ **/
340
+ IniReader::OverrideMap *parseParamOverrides (const string &kv_str)
341
+ {
342
+ IniReader::OverrideMap *kv_map = new IniReader::OverrideMap ();
343
+ size_t start = 0 , comma=0 , equal_sign=0 ;
344
+ // split the commas if they are there
345
+ while (1 )
346
+ {
347
+ equal_sign = kv_str.find (' =' , start);
348
+ if (equal_sign == string::npos)
349
+ {
350
+ break ;
351
+ }
352
+
353
+ comma = kv_str.find (' ,' , equal_sign);
354
+ if (comma == string::npos)
355
+ {
356
+ comma = kv_str.length ();
357
+ }
358
+
359
+ string key = kv_str.substr (start, equal_sign-start);
360
+ string value = kv_str.substr (equal_sign+1 , comma-equal_sign-1 );
361
+
362
+ (*kv_map)[key] = value;
363
+ start = comma+1 ;
364
+
365
+ }
366
+ return kv_map;
367
+ }
368
+
334
369
int main (int argc, char **argv)
335
370
{
336
371
int c;
@@ -341,12 +376,8 @@ int main(int argc, char **argv)
341
376
string pwdString;
342
377
unsigned megsOfMemory=2048 ;
343
378
bool useClockCycle=true ;
344
-
345
- bool overrideOpt = false ;
346
- string overrideKey = " " ;
347
- string overrideVal = " " ;
348
- string tmp = " " ;
349
- size_t equalsign;
379
+
380
+ IniReader::OverrideMap *paramOverrides = NULL ;
350
381
351
382
unsigned numCycles=1000 ;
352
383
// getopt stuff
@@ -357,6 +388,7 @@ int main(int argc, char **argv)
357
388
{" deviceini" , required_argument, 0 , ' d' },
358
389
{" tracefile" , required_argument, 0 , ' t' },
359
390
{" systemini" , required_argument, 0 , ' s' },
391
+
360
392
{" pwd" , required_argument, 0 , ' p' },
361
393
{" numcycles" , required_argument, 0 , ' c' },
362
394
{" option" , required_argument, 0 , ' o' },
@@ -415,11 +447,7 @@ int main(int argc, char **argv)
415
447
useClockCycle=false ;
416
448
break ;
417
449
case ' o' :
418
- tmp = string (optarg );
419
- equalsign = tmp.find_first_of (' =' );
420
- overrideKey = tmp.substr (0 ,equalsign);
421
- overrideVal = tmp.substr (equalsign+1 ,tmp.size ()-equalsign+1 );
422
- overrideOpt = true ;
450
+ paramOverrides = parseParamOverrides (string (optarg ));
423
451
break ;
424
452
case ' ?' :
425
453
usage ();
@@ -474,6 +502,7 @@ int main(int argc, char **argv)
474
502
475
503
476
504
MultiChannelMemorySystem *memorySystem = new MultiChannelMemorySystem (deviceIniFilename, systemIniFilename, pwdString, traceFileName, megsOfMemory);
505
+ memorySystem->overrideParams (paramOverrides);
477
506
478
507
479
508
#ifdef RETURN_TRANSACTIONS
0 commit comments