Update docs | Revert/Update emulator.cc
This commit is contained in:
@@ -191,8 +191,9 @@ When building the verilator simulator there are some additional options:
|
|||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
make VERILATOR_THREADS=8
|
make VERILATOR_THREADS=8 NUMACTL=1
|
||||||
|
|
||||||
The ``VERILATOR_THREADS=<num>`` option enables the compiled Verilator simulator to use ``<num>`` parallel threads.
|
The ``VERILATOR_THREADS=<num>`` option enables the compiled Verilator simulator to use ``<num>`` parallel threads.
|
||||||
On a multi-socket machine, you will want to make sure all threads are on the same socket by using ``numactl``.
|
On a multi-socket machine, you will want to make sure all threads are on the same socket by using ``NUMACTL=1`` to enable ``numactl``.
|
||||||
You can also just use the ``numa_prefix`` wrapper, which is a simple wrapper around ``numactl`` that runs your verilated simulator like this: ``$(numa_prefix) ./simulator-<name> <simulator-args>``.
|
By enabling this, you will use CHipyard's ``numa_prefix`` wrapper, which is a simple wrapper around ``numactl`` that runs your verilated simulator like this: ``$(numa_prefix) ./simulator-<name> <simulator-args>``.
|
||||||
|
Note that both these flags are mutually exclusive, you can use either independently (though it makes sense to use ``NUMACTL`` just with ``VERILATOR_THREADS=8`` during a Verilator simulation).
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
extern tsi_t* tsi;
|
extern tsi_t* tsi;
|
||||||
extern dtm_t* dtm;
|
extern dtm_t* dtm;
|
||||||
extern remote_bitbang_t * jtag;
|
extern remote_bitbang_t * jtag;
|
||||||
extern int dramsim;
|
|
||||||
|
|
||||||
static uint64_t trace_count = 0;
|
static uint64_t trace_count = 0;
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
@@ -129,37 +128,38 @@ int main(int argc, char** argv)
|
|||||||
uint64_t max_cycles = -1;
|
uint64_t max_cycles = -1;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
bool print_cycles = false;
|
bool print_cycles = false;
|
||||||
// Port numbers are 16 bit unsigned integers.
|
// Port numbers are 16 bit unsigned integers.
|
||||||
uint16_t rbb_port = 0;
|
uint16_t rbb_port = 0;
|
||||||
#if VM_TRACE
|
#if VM_TRACE
|
||||||
const char* vcdfile_name = NULL;
|
const char* vcdfile_name = NULL;
|
||||||
FILE * vcdfile = NULL;
|
FILE * vcdfile = NULL;
|
||||||
uint64_t start = 0;
|
uint64_t start = 0;
|
||||||
#endif
|
#endif
|
||||||
int verilog_plusargs_legal = 1;
|
int verilog_plusargs_legal = 1;
|
||||||
|
|
||||||
dramsim = 0;
|
opterr = 1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"cycle-count", no_argument, 0, 'c' },
|
{"cycle-count", no_argument, 0, 'c' },
|
||||||
{"help", no_argument, 0, 'h' },
|
{"help", no_argument, 0, 'h' },
|
||||||
{"max-cycles", required_argument, 0, 'm' },
|
{"max-cycles", required_argument, 0, 'm' },
|
||||||
{"seed", required_argument, 0, 's' },
|
{"seed", required_argument, 0, 's' },
|
||||||
{"rbb-port", required_argument, 0, 'r' },
|
{"rbb-port", required_argument, 0, 'r' },
|
||||||
{"verbose", no_argument, 0, 'V' },
|
{"verbose", no_argument, 0, 'V' },
|
||||||
{"dramsim", no_argument, 0, 'D' },
|
{"permissive", no_argument, 0, 'p' },
|
||||||
|
{"permissive-off", no_argument, 0, 'o' },
|
||||||
#if VM_TRACE
|
#if VM_TRACE
|
||||||
{"vcd", required_argument, 0, 'v' },
|
{"vcd", required_argument, 0, 'v' },
|
||||||
{"dump-start", required_argument, 0, 'x' },
|
{"dump-start", required_argument, 0, 'x' },
|
||||||
#endif
|
#endif
|
||||||
HTIF_LONG_OPTIONS
|
HTIF_LONG_OPTIONS
|
||||||
};
|
};
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
#if VM_TRACE
|
#if VM_TRACE
|
||||||
int c = getopt_long(argc, argv, "-chm:s:r:v:Vx:D", long_options, &option_index);
|
int c = getopt_long(argc, argv, "-chm:s:r:v:Vx:po", long_options, &option_index);
|
||||||
#else
|
#else
|
||||||
int c = getopt_long(argc, argv, "-chm:s:r:VD", long_options, &option_index);
|
int c = getopt_long(argc, argv, "-chm:s:r:Vpo", long_options, &option_index);
|
||||||
#endif
|
#endif
|
||||||
if (c == -1) break;
|
if (c == -1) break;
|
||||||
retry:
|
retry:
|
||||||
@@ -172,7 +172,8 @@ int main(int argc, char** argv)
|
|||||||
case 's': random_seed = atoi(optarg); break;
|
case 's': random_seed = atoi(optarg); break;
|
||||||
case 'r': rbb_port = atoi(optarg); break;
|
case 'r': rbb_port = atoi(optarg); break;
|
||||||
case 'V': verbose = true; break;
|
case 'V': verbose = true; break;
|
||||||
case 'D': dramsim = 1; break;
|
case 'p': opterr = 0; break;
|
||||||
|
case 'o': opterr = 1; break;
|
||||||
#if VM_TRACE
|
#if VM_TRACE
|
||||||
case 'v': {
|
case 'v': {
|
||||||
vcdfile_name = optarg;
|
vcdfile_name = optarg;
|
||||||
@@ -207,8 +208,10 @@ int main(int argc, char** argv)
|
|||||||
#endif
|
#endif
|
||||||
else if (arg.substr(0, 12) == "+cycle-count")
|
else if (arg.substr(0, 12) == "+cycle-count")
|
||||||
c = 'c';
|
c = 'c';
|
||||||
else if (arg == "+dramsim")
|
else if (arg == "+permissive")
|
||||||
c = 'D';
|
c = 'p';
|
||||||
|
else if (arg == "+permissive-off")
|
||||||
|
c = 'o';
|
||||||
// If we don't find a legacy '+' EMULATOR argument, it still could be
|
// If we don't find a legacy '+' EMULATOR argument, it still could be
|
||||||
// a VERILOG_PLUSARG and not an error.
|
// a VERILOG_PLUSARG and not an error.
|
||||||
else if (verilog_plusargs_legal) {
|
else if (verilog_plusargs_legal) {
|
||||||
@@ -240,9 +243,13 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
htif_option++;
|
htif_option++;
|
||||||
}
|
}
|
||||||
std::cerr << argv[0] << ": invalid plus-arg (Verilog or HTIF) \""
|
if(opterr) {
|
||||||
<< arg << "\"\n";
|
std::cerr << argv[0] << ": invalid plus-arg (Verilog or HTIF) \""
|
||||||
c = '?';
|
<< arg << "\"\n";
|
||||||
|
c = '?';
|
||||||
|
} else {
|
||||||
|
c = 'p';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
@@ -264,10 +271,10 @@ done_processing:
|
|||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
htif_argc = 1 + argc - optind;
|
|
||||||
htif_argv = (char **) malloc((htif_argc) * sizeof (char *));
|
// set argc/v in vpi_get_vlog_info
|
||||||
htif_argv[0] = argv[0];
|
htif_argc = argc;
|
||||||
for (int i = 1; optind < argc;) htif_argv[i++] = argv[optind++];
|
htif_argv = argv;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "using random seed %u\n", random_seed);
|
fprintf(stderr, "using random seed %u\n", random_seed);
|
||||||
@@ -293,6 +300,9 @@ done_processing:
|
|||||||
}
|
}
|
||||||
#endif // VM_TRACE
|
#endif // VM_TRACE
|
||||||
|
|
||||||
|
// RocketChip currently only supports RBB port 0, so this needs to stay here
|
||||||
|
jtag = new remote_bitbang_t(rbb_port);
|
||||||
|
|
||||||
signal(SIGTERM, handle_sigterm);
|
signal(SIGTERM, handle_sigterm);
|
||||||
|
|
||||||
bool dump;
|
bool dump;
|
||||||
@@ -339,10 +349,10 @@ done_processing:
|
|||||||
trace_count++;
|
trace_count++;
|
||||||
}
|
}
|
||||||
// for verilator multithreading. need to do 1 loop before checking if
|
// for verilator multithreading. need to do 1 loop before checking if
|
||||||
// tsi exists, since tsi is created by verilated thread on the first
|
// tsi exists, since tsi is created by verilated thread on the first
|
||||||
// serial_tick.
|
// serial_tick.
|
||||||
while ((!dtm || !dtm->done()) &&
|
while ((!dtm || !dtm->done()) &&
|
||||||
(!jtag || !jtag->done()) &&
|
(!jtag || !jtag->done()) &&
|
||||||
(!tsi || !tsi->done()) &&
|
(!tsi || !tsi->done()) &&
|
||||||
!tile->io_success && trace_count < max_cycles);
|
!tile->io_success && trace_count < max_cycles);
|
||||||
|
|
||||||
@@ -382,6 +392,5 @@ done_processing:
|
|||||||
if (tsi) delete tsi;
|
if (tsi) delete tsi;
|
||||||
if (jtag) delete jtag;
|
if (jtag) delete jtag;
|
||||||
if (tile) delete tile;
|
if (tile) delete tile;
|
||||||
if (htif_argv) free(htif_argv);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user