//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// ORPSoC SystemC Testbench ////
|
//// ORPSoC SystemC Testbench ////
|
//// ////
|
//// ////
|
//// Description ////
|
//// Description ////
|
//// ORPSoC Testbench file ////
|
//// ORPSoC Testbench file ////
|
//// ////
|
//// ////
|
//// To Do: ////
|
//// To Do: ////
|
//// Somehow allow tracing to begin later in the sim ////
|
//// Somehow allow tracing to begin later in the sim ////
|
//// ////
|
//// ////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Jeremy Bennett jeremy.bennett@embecosm.com ////
|
//// - Jeremy Bennett jeremy.bennett@embecosm.com ////
|
//// - Julius Baxter jb@orsoc.se ////
|
//// - Julius Baxter jb@orsoc.se ////
|
//// ////
|
//// ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2009 Authors and OPENCORES.ORG ////
|
//// Copyright (C) 2009 Authors and OPENCORES.ORG ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// later version. ////
|
//// later version. ////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// details. ////
|
//// details. ////
|
//// ////
|
//// ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// Public License along with this source; if not, download it ////
|
//// Public License along with this source; if not, download it ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
|
|
#include "OrpsocMain.h"
|
#include "OrpsocMain.h"
|
|
|
#include "Vorpsoc_top.h"
|
#include "Vorpsoc_top.h"
|
#include "OrpsocAccess.h"
|
#include "OrpsocAccess.h"
|
#include "MemoryLoad.h"
|
#include "MemoryLoad.h"
|
|
|
#include <SpTraceVcdC.h>
|
#include <SpTraceVcdC.h>
|
|
|
//#include "TraceSC.h"
|
//#include "TraceSC.h"
|
#include "ResetSC.h"
|
#include "ResetSC.h"
|
#include "Or1200MonitorSC.h"
|
#include "Or1200MonitorSC.h"
|
#include "UartSC.h"
|
#include "UartSC.h"
|
|
|
int SIM_RUNNING;
|
int SIM_RUNNING;
|
int sc_main (int argc,
|
int sc_main (int argc,
|
char *argv[] )
|
char *argv[] )
|
{
|
{
|
sc_set_time_resolution( 1, TIMESCALE_UNIT);
|
sc_set_time_resolution( 1, TIMESCALE_UNIT);
|
// CPU clock (also used as JTAG TCK) and reset (both active high and low)
|
// CPU clock (also used as JTAG TCK) and reset (both active high and low)
|
sc_time clkPeriod (BENCH_CLK_HALFPERIOD * 2.0, TIMESCALE_UNIT);
|
sc_time clkPeriod (BENCH_CLK_HALFPERIOD * 2.0, TIMESCALE_UNIT);
|
|
|
sc_clock clk ("clk", clkPeriod);
|
sc_clock clk ("clk", clkPeriod);
|
sc_signal<bool> rst;
|
sc_signal<bool> rst;
|
sc_signal<bool> rstn;
|
sc_signal<bool> rstn;
|
sc_signal<bool> rst_o;
|
sc_signal<bool> rst_o;
|
|
|
sc_signal<bool> jtag_tdi; // JTAG interface
|
sc_signal<bool> jtag_tdi; // JTAG interface
|
sc_signal<bool> jtag_tdo;
|
sc_signal<bool> jtag_tdo;
|
sc_signal<bool> jtag_tms;
|
sc_signal<bool> jtag_tms;
|
sc_signal<bool> jtag_trst;
|
sc_signal<bool> jtag_trst;
|
|
|
sc_signal<bool> uart_rx; // External UART
|
sc_signal<bool> uart_rx; // External UART
|
sc_signal<bool> uart_tx;
|
sc_signal<bool> uart_tx;
|
|
|
sc_signal<bool> spi_sd_sclk; // SD Card Memory SPI
|
sc_signal<bool> spi_sd_sclk; // SD Card Memory SPI
|
sc_signal<bool> spi_sd_ss;
|
sc_signal<bool> spi_sd_ss;
|
sc_signal<bool> spi_sd_miso;
|
sc_signal<bool> spi_sd_miso;
|
sc_signal<bool> spi_sd_mosi;
|
sc_signal<bool> spi_sd_mosi;
|
|
|
sc_signal<uint32_t> gpio_a; // GPIO bus - output only in verilator sims
|
sc_signal<uint32_t> gpio_a; // GPIO bus - output only in verilator sims
|
|
|
sc_signal<bool> spi1_mosi;
|
sc_signal<bool> spi1_mosi;
|
sc_signal<bool> spi1_miso;
|
sc_signal<bool> spi1_miso;
|
sc_signal<bool> spi1_ss;
|
sc_signal<bool> spi1_ss;
|
sc_signal<bool> spi1_sclk;
|
sc_signal<bool> spi1_sclk;
|
|
|
SIM_RUNNING = 0;
|
SIM_RUNNING = 0;
|
|
|
// Setup the name of the VCD dump file
|
// Setup the name of the VCD dump file
|
int VCD_enabled = 0;
|
int VCD_enabled = 0;
|
string dumpNameDefault("vlt-dump.vcd");
|
string dumpNameDefault("vlt-dump.vcd");
|
string testNameString;
|
string testNameString;
|
string vcdDumpFile;
|
string vcdDumpFile;
|
// VCD dump controling vars
|
// VCD dump controling vars
|
int dump_start_delay, dump_stop_set;
|
int dump_start_delay, dump_stop_set;
|
int dumping_now;
|
int dumping_now;
|
int dump_depth = 99; // Default dump depth
|
int dump_depth = 99; // Default dump depth
|
sc_time dump_start,dump_stop, finish_time;
|
sc_time dump_start,dump_stop, finish_time;
|
int finish_time_set = 0; // By default we will let the simulation finish naturally
|
int finish_time_set = 0; // By default we will let the simulation finish naturally
|
SpTraceVcdCFile *spTraceFile;
|
SpTraceVcdCFile *spTraceFile;
|
|
|
int time_val;
|
int time_val;
|
int cmdline_name_found=0;
|
int cmdline_name_found=0;
|
|
|
// Executable app load variables
|
// Executable app load variables
|
int do_program_file_load = 0; // Default: we don't require a file, we use the VMEM
|
int do_program_file_load = 0; // Default: we don't require a file, we use the VMEM
|
char* program_file; // Old char* style for program name
|
char* program_file; // Old char* style for program name
|
|
|
// Verilator accessor
|
// Verilator accessor
|
OrpsocAccess *accessor;
|
OrpsocAccess *accessor;
|
|
|
// Modules
|
// Modules
|
Vorpsoc_top *orpsoc; // Verilated ORPSoC
|
Vorpsoc_top *orpsoc; // Verilated ORPSoC
|
|
|
MemoryLoad *memoryload; // Memory loader
|
MemoryLoad *memoryload; // Memory loader
|
|
|
ResetSC *reset; // Generate a RESET signal
|
ResetSC *reset; // Generate a RESET signal
|
Or1200MonitorSC *monitor; // Handle l.nop x instructions
|
Or1200MonitorSC *monitor; // Handle l.nop x instructions
|
UartSC *uart; // Handle UART signals
|
UartSC *uart; // Handle UART signals
|
|
|
// Instantiate the Verilator model, VCD trace handler and accessor
|
// Instantiate the Verilator model, VCD trace handler and accessor
|
orpsoc = new Vorpsoc_top ("orpsoc");
|
orpsoc = new Vorpsoc_top ("orpsoc");
|
|
|
accessor = new OrpsocAccess (orpsoc);
|
accessor = new OrpsocAccess (orpsoc);
|
|
|
memoryload = new MemoryLoad (accessor);
|
memoryload = new MemoryLoad (accessor);
|
|
|
// Instantiate the SystemC modules
|
// Instantiate the SystemC modules
|
reset = new ResetSC ("reset", BENCH_RESET_TIME);
|
reset = new ResetSC ("reset", BENCH_RESET_TIME);
|
monitor = new Or1200MonitorSC ("monitor", accessor, memoryload, argc, argv);
|
monitor = new Or1200MonitorSC ("monitor", accessor, memoryload, argc, argv);
|
uart = new UartSC("uart"); // TODO: Probalby some sort of param
|
uart = new UartSC("uart"); // TODO: Probalby some sort of param
|
|
|
// Parse command line options
|
// Parse command line options
|
// Default is for VCD generation OFF, only turned on if specified on command line
|
// Default is for VCD generation OFF, only turned on if specified on command line
|
dump_start_delay = 0;
|
dump_start_delay = 0;
|
dump_stop_set = 0;
|
dump_stop_set = 0;
|
dumping_now = 0;
|
dumping_now = 0;
|
|
|
// Search through the command line parameters for options
|
// Search through the command line parameters for options
|
if (argc > 1)
|
if (argc > 1)
|
{
|
{
|
for(int i=1; i<argc; i++)
|
for(int i=1; i<argc; i++)
|
{
|
{
|
if ((strcmp(argv[i], "-d")==0) ||
|
if ((strcmp(argv[i], "-d")==0) ||
|
(strcmp(argv[i], "--vcdfile")==0))
|
(strcmp(argv[i], "--vcdfile")==0))
|
{
|
{
|
testNameString = (argv[i+1]);
|
testNameString = (argv[i+1]);
|
vcdDumpFile = testNameString;
|
vcdDumpFile = testNameString;
|
cmdline_name_found=1;
|
cmdline_name_found=1;
|
}
|
}
|
else if ((strcmp(argv[i], "-v")==0) ||
|
else if ((strcmp(argv[i], "-v")==0) ||
|
(strcmp(argv[i], "--vcdon")==0))
|
(strcmp(argv[i], "--vcdon")==0))
|
{
|
{
|
dumping_now = 1;
|
dumping_now = 1;
|
}
|
}
|
else if ( (strcmp(argv[i], "-e")==0) ||
|
else if ( (strcmp(argv[i], "-e")==0) ||
|
(strcmp(argv[i], "--endtime")==0) )
|
(strcmp(argv[i], "--endtime")==0) )
|
{
|
{
|
time_val = atoi(argv[i+1]);
|
time_val = atoi(argv[i+1]);
|
sc_time opt_end_time(time_val,TIMESCALE_UNIT);
|
sc_time opt_end_time(time_val,TIMESCALE_UNIT);
|
finish_time = opt_end_time;
|
finish_time = opt_end_time;
|
finish_time_set = 1;
|
finish_time_set = 1;
|
}
|
}
|
else if ( (strcmp(argv[i], "-f")==0) ||
|
else if ( (strcmp(argv[i], "-f")==0) ||
|
(strcmp(argv[i], "--program")==0) )
|
(strcmp(argv[i], "--program")==0) )
|
{
|
{
|
do_program_file_load = 1; // Enable program loading - will be done after sim init
|
do_program_file_load = 1; // Enable program loading - will be done after sim init
|
program_file = argv[i+1]; // Old char* style for program name
|
program_file = argv[i+1]; // Old char* style for program name
|
}
|
}
|
else if ( (strcmp(argv[i], "-s")==0) ||
|
else if ( (strcmp(argv[i], "-s")==0) ||
|
(strcmp(argv[i], "--vcdstart")==0) )
|
(strcmp(argv[i], "--vcdstart")==0) )
|
{
|
{
|
time_val = atoi(argv[i+1]);
|
time_val = atoi(argv[i+1]);
|
sc_time dump_start_time(time_val,TIMESCALE_UNIT);
|
sc_time dump_start_time(time_val,TIMESCALE_UNIT);
|
dump_start = dump_start_time;
|
dump_start = dump_start_time;
|
dump_start_delay = 1;
|
dump_start_delay = 1;
|
dumping_now = 0;
|
dumping_now = 0;
|
}
|
}
|
else if ( (strcmp(argv[i], "-t")==0) ||
|
else if ( (strcmp(argv[i], "-t")==0) ||
|
(strcmp(argv[i], "--vcdstop")==0) )
|
(strcmp(argv[i], "--vcdstop")==0) )
|
{
|
{
|
time_val = atoi(argv[i+1]);
|
time_val = atoi(argv[i+1]);
|
sc_time dump_stop_time(time_val,TIMESCALE_UNIT);
|
sc_time dump_stop_time(time_val,TIMESCALE_UNIT);
|
dump_stop = dump_stop_time;
|
dump_stop = dump_stop_time;
|
dump_stop_set = 1;
|
dump_stop_set = 1;
|
}
|
}
|
/* Depth setting of VCD doesn't appear to work,
|
/* Depth setting of VCD doesn't appear to work,
|
I think it's set during verilator script
|
I think it's set during verilator script
|
compile time */
|
compile time */
|
/* else if ( (strcmp(argv[i], "-p")==0) ||
|
/* else if ( (strcmp(argv[i], "-p")==0) ||
|
(strcmp(argv[i], "--vcddepth")==0) )
|
(strcmp(argv[i], "--vcddepth")==0) )
|
{
|
{
|
dump_depth = atoi(argv[i+1]);
|
dump_depth = atoi(argv[i+1]);
|
}*/
|
}*/
|
else if ( (strcmp(argv[i], "-h")==0) ||
|
else if ( (strcmp(argv[i], "-h")==0) ||
|
(strcmp(argv[i], "--help")==0) )
|
(strcmp(argv[i], "--help")==0) )
|
{
|
{
|
printf("\n ORPSoC Cycle Accurate model usage:\n");
|
printf("\n ORPSoC Cycle Accurate model usage:\n");
|
printf(" %s [-vh] [-f <file] [-d <file>] [-e <time>] [-s <time>] [-t <time>]",argv[0]);
|
printf(" %s [-vh] [-f <file] [-d <file>] [-e <time>] [-s <time>] [-t <time>]",argv[0]);
|
monitor->printSwitches();
|
monitor->printSwitches();
|
printf("\n\n");
|
printf("\n\n");
|
printf(" -h, --help\t\tPrint this help message\n");
|
printf(" -h, --help\t\tPrint this help message\n");
|
printf(" -e, --endtime\t\tStop the sim at this time (ns)\n");
|
printf(" -e, --endtime\t\tStop the sim at this time (ns)\n");
|
printf(" -f, --program\t\tLoad program from an OR32 ELF\n");
|
printf(" -f, --program\t\tLoad program from an OR32 ELF\n");
|
printf(" -v, --vcdon\t\tEnable VCD generation\n");
|
printf(" -v, --vcdon\t\tEnable VCD generation\n");
|
printf(" -d, --vcdfile\t\tEnable and specify target VCD file name\n");
|
printf(" -d, --vcdfile\t\tEnable and specify target VCD file name\n");
|
|
|
printf(" -s, --vcdstart\tEnable and delay VCD generation until this time (ns)\n");
|
printf(" -s, --vcdstart\tEnable and delay VCD generation until this time (ns)\n");
|
printf(" -t, --vcdstop\t\tEnable and terminate VCD generation at this time (ns)\n");
|
printf(" -t, --vcdstop\t\tEnable and terminate VCD generation at this time (ns)\n");
|
monitor->printUsage();
|
monitor->printUsage();
|
printf("\n");
|
printf("\n");
|
return 0;
|
return 0;
|
}
|
}
|
|
|
}
|
}
|
}
|
}
|
|
|
if(cmdline_name_found==0) // otherwise use our default VCD dump file name
|
if(cmdline_name_found==0) // otherwise use our default VCD dump file name
|
vcdDumpFile = dumpNameDefault;
|
vcdDumpFile = dumpNameDefault;
|
|
|
// Determine if we're going to setup a VCD dump:
|
// Determine if we're going to setup a VCD dump:
|
// Pretty much setting any option will enable VCD dumping.
|
// Pretty much setting any option will enable VCD dumping.
|
if ((cmdline_name_found) || (dumping_now) || (dump_start_delay) || (dump_stop_set))
|
if ((cmdline_name_found) || (dumping_now) || (dump_start_delay) || (dump_stop_set))
|
{
|
{
|
VCD_enabled = 1;
|
VCD_enabled = 1;
|
|
|
cout << "* Enabling VCD trace";
|
cout << "* Enabling VCD trace";
|
|
|
if (dump_start_delay)
|
if (dump_start_delay)
|
cout << ", on at time " << dump_start.to_string();
|
cout << ", on at time " << dump_start.to_string();
|
if (dump_stop_set)
|
if (dump_stop_set)
|
cout << ", off at time " << dump_stop.to_string();
|
cout << ", off at time " << dump_stop.to_string();
|
cout << endl;
|
cout << endl;
|
}
|
}
|
|
|
|
|
// Connect up ORPSoC
|
// Connect up ORPSoC
|
orpsoc->clk_pad_i (clk);
|
orpsoc->clk_pad_i (clk);
|
orpsoc->rst_pad_i (rstn);
|
orpsoc->rst_pad_i (rstn);
|
orpsoc->rst_pad_o (rst_o);
|
orpsoc->rst_pad_o (rst_o);
|
|
|
orpsoc->dbg_tck_pad_i (clk); // JTAG interface
|
orpsoc->dbg_tck_pad_i (clk); // JTAG interface
|
orpsoc->dbg_tdi_pad_i (jtag_tdi);
|
orpsoc->dbg_tdi_pad_i (jtag_tdi);
|
orpsoc->dbg_tms_pad_i (jtag_tms);
|
orpsoc->dbg_tms_pad_i (jtag_tms);
|
orpsoc->dbg_tdo_pad_o (jtag_tdo);
|
orpsoc->dbg_tdo_pad_o (jtag_tdo);
|
|
|
orpsoc->uart0_srx_pad_i (uart_rx); // External UART
|
orpsoc->uart0_srx_pad_i (uart_rx); // External UART
|
orpsoc->uart0_stx_pad_o (uart_tx);
|
orpsoc->uart0_stx_pad_o (uart_tx);
|
|
|
orpsoc->spi_sd_sclk_pad_o (spi_sd_sclk); // SD Card Memory SPI
|
orpsoc->spi_sd_sclk_pad_o (spi_sd_sclk); // SD Card Memory SPI
|
orpsoc->spi_sd_ss_pad_o (spi_sd_ss);
|
orpsoc->spi_sd_ss_pad_o (spi_sd_ss);
|
orpsoc->spi_sd_miso_pad_i (spi_sd_miso);
|
orpsoc->spi_sd_miso_pad_i (spi_sd_miso);
|
orpsoc->spi_sd_mosi_pad_o (spi_sd_mosi);
|
orpsoc->spi_sd_mosi_pad_o (spi_sd_mosi);
|
|
|
orpsoc->spi1_mosi_pad_o (spi1_mosi);
|
orpsoc->spi1_mosi_pad_o (spi1_mosi);
|
orpsoc->spi1_miso_pad_i (spi1_miso);
|
orpsoc->spi1_miso_pad_i (spi1_miso);
|
orpsoc->spi1_ss_pad_o (spi1_ss);
|
orpsoc->spi1_ss_pad_o (spi1_ss);
|
orpsoc->spi1_sclk_pad_o (spi1_sclk);
|
orpsoc->spi1_sclk_pad_o (spi1_sclk);
|
|
|
|
|
orpsoc->gpio_a_pad_io (gpio_a); // GPIO bus - output only in
|
orpsoc->gpio_a_pad_io (gpio_a); // GPIO bus - output only in
|
// verilator sims
|
// verilator sims
|
|
|
// Connect up the VCD trace handler
|
// Connect up the VCD trace handler
|
//trace->clk (clk); // Trace
|
//trace->clk (clk); // Trace
|
|
|
// Connect up the SystemC modules
|
// Connect up the SystemC modules
|
reset->clk (clk); // Reset
|
reset->clk (clk); // Reset
|
reset->rst (rst);
|
reset->rst (rst);
|
reset->rstn (rstn);
|
reset->rstn (rstn);
|
|
|
monitor->clk (clk); // Monitor
|
monitor->clk (clk); // Monitor
|
|
|
uart->clk (clk); // Uart
|
uart->clk (clk); // Uart
|
uart->uartrx (uart_rx); // orpsoc's receive line
|
uart->uartrx (uart_rx); // orpsoc's receive line
|
uart->uarttx (uart_tx); // orpsoc's transmit line
|
uart->uarttx (uart_tx); // orpsoc's transmit line
|
|
|
// Tie off signals
|
// Tie off signals
|
jtag_tdi = 1; // Tie off the JTAG inputs
|
jtag_tdi = 1; // Tie off the JTAG inputs
|
jtag_tms = 1;
|
jtag_tms = 1;
|
|
|
spi_sd_miso = 0; // Tie off master-in/slave-out of SD SPI bus
|
spi_sd_miso = 0; // Tie off master-in/slave-out of SD SPI bus
|
|
|
spi1_miso = 0;
|
spi1_miso = 0;
|
|
|
//#if VM_TRACE
|
//#if VM_TRACE
|
if (VCD_enabled)
|
if (VCD_enabled)
|
{
|
{
|
Verilated::traceEverOn (true);
|
Verilated::traceEverOn (true);
|
|
|
printf("* VCD dumpfile: %s\n", vcdDumpFile.c_str());
|
printf("* VCD dumpfile: %s\n", vcdDumpFile.c_str());
|
|
|
// Establish a new trace with its correct time resolution, and trace to
|
// Establish a new trace with its correct time resolution, and trace to
|
// great depth.
|
// great depth.
|
spTraceFile = new SpTraceVcdCFile ();
|
spTraceFile = new SpTraceVcdCFile ();
|
//spTraceFile->spTrace()->set_time_resolution (sc_get_time_resolution());
|
//spTraceFile->spTrace()->set_time_resolution (sc_get_time_resolution());
|
//setSpTimeResolution (sc_get_time_resolution ());
|
//setSpTimeResolution (sc_get_time_resolution ());
|
//traceTarget->trace (spTraceFile, 99);
|
//traceTarget->trace (spTraceFile, 99);
|
orpsoc->trace (spTraceFile, dump_depth);
|
orpsoc->trace (spTraceFile, dump_depth);
|
|
|
if (dumping_now)
|
if (dumping_now)
|
{
|
{
|
spTraceFile->open (vcdDumpFile.c_str());
|
spTraceFile->open (vcdDumpFile.c_str());
|
}
|
}
|
//#endif
|
//#endif
|
}
|
}
|
|
|
printf("* Beginning test\n");
|
//printf("* Beginning test\n");
|
|
|
// Init the UART function
|
// Init the UART function
|
uart->initUart(25000000, 115200);
|
uart->initUart(25000000, 115200);
|
|
|
if (do_program_file_load) // Did the user specify a file to load?
|
if (do_program_file_load) // Did the user specify a file to load?
|
{
|
{
|
cout << "* Loading program from " << program_file << endl;
|
cout << "* Loading program from " << program_file << endl;
|
if (memoryload->loadcode(program_file,0,0) < 0)
|
if (memoryload->loadcode(program_file,0,0) < 0)
|
{
|
{
|
cout << "* Error: executable file " << program_file << " not loaded" << endl;
|
cout << "* Error: executable file " << program_file << " not loaded" << endl;
|
}
|
}
|
}
|
}
|
else // Load SRAM from VMEM file
|
else // Load SRAM from VMEM file
|
{
|
{
|
accessor->do_ram_readmemh();
|
accessor->do_ram_readmemh();
|
}
|
}
|
|
|
SIM_RUNNING = 1;
|
SIM_RUNNING = 1;
|
|
|
// First check how we should run the sim.
|
// First check how we should run the sim.
|
if (VCD_enabled || finish_time_set)
|
if (VCD_enabled || finish_time_set)
|
{ // We'll run sim with step
|
{ // We'll run sim with step
|
|
|
if (!VCD_enabled && finish_time_set)
|
if (!VCD_enabled && finish_time_set)
|
{
|
{
|
// We just run the sim until the set finish time
|
// We just run the sim until the set finish time
|
sc_start((double)(finish_time.to_double()), TIMESCALE_UNIT);
|
sc_start((double)(finish_time.to_double()), TIMESCALE_UNIT);
|
SIM_RUNNING=0;
|
SIM_RUNNING=0;
|
sc_stop();
|
sc_stop();
|
// Print performance summary
|
// Print performance summary
|
monitor->perfSummary();
|
monitor->perfSummary();
|
|
// Do memdump if enabled
|
|
monitor->memdump();
|
}
|
}
|
else
|
else
|
{
|
{
|
if (dump_start_delay)
|
if (dump_start_delay)
|
{
|
{
|
// Run the sim until we want to dump
|
// Run the sim until we want to dump
|
sc_start((double)(dump_start.to_double()),TIMESCALE_UNIT);
|
sc_start((double)(dump_start.to_double()),TIMESCALE_UNIT);
|
// Open the trace file
|
// Open the trace file
|
spTraceFile->open (vcdDumpFile.c_str());
|
spTraceFile->open (vcdDumpFile.c_str());
|
dumping_now = 1;
|
dumping_now = 1;
|
}
|
}
|
|
|
if (dumping_now)
|
if (dumping_now)
|
{
|
{
|
// Step the sim and generate the trace
|
// Step the sim and generate the trace
|
// Execute until we stop
|
// Execute until we stop
|
while(!Verilated::gotFinish())
|
while(!Verilated::gotFinish())
|
{
|
{
|
if (SIM_RUNNING) // Changed by Or1200MonitorSC when finish NOP
|
if (SIM_RUNNING) // Changed by Or1200MonitorSC when finish NOP
|
sc_start (1,TIMESCALE_UNIT); // Step the sim
|
sc_start (1,TIMESCALE_UNIT); // Step the sim
|
else
|
else
|
{
|
{
|
spTraceFile->close();
|
spTraceFile->close();
|
break;
|
break;
|
}
|
}
|
|
|
spTraceFile->dump (sc_time_stamp().to_double());
|
spTraceFile->dump (sc_time_stamp().to_double());
|
|
|
if (dump_stop_set)
|
if (dump_stop_set)
|
{
|
{
|
if (sc_time_stamp() >= dump_stop)
|
if (sc_time_stamp() >= dump_stop)
|
{
|
{
|
// Close dump file
|
// Close dump file
|
spTraceFile->close();
|
spTraceFile->close();
|
// Now continue on again until the end
|
// Now continue on again until the end
|
if (!finish_time_set)
|
if (!finish_time_set)
|
sc_start();
|
sc_start();
|
else
|
else
|
{
|
{
|
// Determine how long we should run for
|
// Determine how long we should run for
|
sc_time sim_time_remaining =
|
sc_time sim_time_remaining =
|
finish_time - sc_time_stamp();
|
finish_time - sc_time_stamp();
|
sc_start((double)(sim_time_remaining.to_double()),
|
sc_start((double)(sim_time_remaining.to_double()),
|
TIMESCALE_UNIT);
|
TIMESCALE_UNIT);
|
// Officially stop the sim
|
// Officially stop the sim
|
sc_stop();
|
sc_stop();
|
// Print performance summary
|
// Print performance summary
|
monitor->perfSummary();
|
monitor->perfSummary();
|
|
// Do memdump if enabled
|
|
monitor->memdump();
|
}
|
}
|
break;
|
break;
|
}
|
}
|
}
|
}
|
if (finish_time_set)
|
if (finish_time_set)
|
{
|
{
|
if (sc_time_stamp() >= finish_time)
|
if (sc_time_stamp() >= finish_time)
|
{
|
{
|
// Officially stop the sim
|
// Officially stop the sim
|
sc_stop();
|
sc_stop();
|
// Close dump file
|
// Close dump file
|
spTraceFile->close();
|
spTraceFile->close();
|
|
// Do memdump if enabled
|
|
monitor->memdump();
|
// Print performance summary
|
// Print performance summary
|
monitor->perfSummary();
|
monitor->perfSummary();
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
else
|
else
|
{
|
{
|
// Simple run case
|
// Simple run case
|
|
// Ideally a "l.nop 1" will terminate the simulation gracefully
|
sc_start();
|
sc_start();
|
}
|
}
|
|
|
|
|
// Free memory
|
// Free memory
|
delete monitor;
|
delete monitor;
|
delete reset;
|
delete reset;
|
|
|
delete accessor;
|
delete accessor;
|
|
|
//delete trace;
|
//delete trace;
|
delete orpsoc;
|
delete orpsoc;
|
|
|
return 0;
|
return 0;
|
|
|
} /* sc_main() */
|
} /* sc_main() */
|
|
|