URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc
- from Rev 51 to Rev 52
- ↔ Reverse comparison
Rev 51 → Rev 52
/trunk/orpsocv2/bench/sysc/include/OrpsocMain.h
55,4 → 55,8
//! CPU clock Half period in timescale units |
#define BENCH_CLK_HALFPERIOD 20 |
|
//! System's internal RAM size in byes - found in rtl/verilog/orpsoc_top.v, param for ram_wb module |
//! Currently is 32MB (8M words) |
#define ORPSOC_SRAM_SIZE (8388608*4) |
|
#endif // ORPSOC_MAIN__H |
/trunk/orpsocv2/bench/sysc/include/Or1200MonitorSC.h
73,7 → 73,11
|
// Method to print out the usage for each option |
void printUsage(); |
|
// Method to dump simulation's RAM contents at finish |
void memdump(); |
|
|
// The ports |
sc_in<bool> clk; |
|
80,6 → 84,7
private: |
|
#define DEFAULT_PROF_FILE "sim.profile" |
#define DEFAULT_MEMDUMP_FILE "vorpsoc_ram.dump" |
|
// Special NOP instructions |
static const uint32_t NOP_NOP = 0x15000000; //!< Normal nop instruction |
91,10 → 96,14
// Variables for processor status output |
ofstream statusFile; |
ofstream profileFile; |
int profiling_enabled; |
int logging_enabled; |
int exit_perf_summary_enabled; |
int insn_count; |
long long cycle_count; |
ofstream memdumpFile; |
string memdumpFileName; |
int do_memdump, memdump_start_addr, memdump_end_addr; |
|
//! Time measurement variable - for calculating performance of the sim |
clock_t start; |
/trunk/orpsocv2/bench/sysc/include/MemoryLoad.h
47,7 → 47,7
|
/* From abstract.h */ |
#define DEFAULT_MEMORY_START 0 |
#define DEFAULT_MEMORY_LEN 0x800000 |
//#define DEFAULT_MEMORY_LEN 0x800000 |
#define STACK_SIZE 20 |
#define LABELNAME_LEN 50 |
#define INSNAME_LEN 15 |
/trunk/orpsocv2/bench/sysc/src/Or1200MonitorSC.cpp
30,7 → 30,8
#include <iostream> |
#include <iomanip> |
#include <fstream> |
|
#include <sys/types.h> |
#include <netinet/in.h> |
using namespace std; |
|
#include "Or1200MonitorSC.h" |
58,8 → 59,12
|
string logfileDefault("vlt-executed.log"); |
string logfileNameString; |
int profiling_enabled = 0; |
profiling_enabled = 0; |
string profileFileName(DEFAULT_PROF_FILE); |
memdumpFileName = (DEFAULT_MEMDUMP_FILE); |
int memdump_start = 0; int memdump_end = 0; |
do_memdump = 0; // Default is not to do a dump of RAM at finish |
|
insn_count=0; |
cycle_count=0; |
|
88,16 → 93,55
(strcmp(argv[i], "--profile")==0)) |
{ |
profiling_enabled = 1; |
// Check for !end of command line and it's not a command |
// Check for !end of command line and that next thing is not a command |
if ((i+1 < argc)){ |
if(argv[i+1][0] != '-') |
profileFileName = (argv[i+1]); |
} |
} |
else if ((strcmp(argv[i], "-m")==0) || |
(strcmp(argv[i], "--mdump")==0)) |
{ |
do_memdump = 1; |
// Check for !end of command line and that next thing is not a command |
// or a memory address |
if (i+1 < argc) |
{ |
if((argv[i+1][0] != '-') && (strncmp("0x", argv[i+1],2) != 0)) |
{ |
// Hopefully this is the filename we want to use. |
// All addresses should have preceeding hex identifier 0x |
memdumpFileName = argv[i+1]; |
// We've used this next index, can safely increment i |
i++; |
} |
} |
if (i+1 < argc) |
{ |
if((argv[i+1][0] != '-') && (strncmp("0x", argv[i+1],2) == 0)) |
{ |
// Hopefully this is is the start address |
// All addresses should have preceeding hex identifier 0x |
sscanf( argv[i+1], "0x%x", &memdump_start); |
i++; |
} |
} |
if (i+1 < argc) |
{ |
if((argv[i+1][0] != '-') && (strncmp("0x", argv[i+1],2) == 0)) |
{ |
// Hopefully this is is the end address |
// All addresses should have preceeding hex identifier 0x |
sscanf( argv[i+1], "0x%x", &memdump_end); |
i++; |
} |
} |
} |
} |
} |
|
|
|
if (profiling_enabled) |
{ |
profileFile.open(profileFileName.c_str(), ios::out); // Open profiling log file |
138,8 → 182,45
start = clock(); |
} |
|
// Check sizes we were given from memory dump command line options first |
if (do_memdump) |
{ |
if ((memdump_start > ORPSOC_SRAM_SIZE) || (memdump_end > ORPSOC_SRAM_SIZE) || |
((memdump_start > memdump_end) && (memdump_end != 0))) |
{ |
do_memdump = 0; |
cout << "* Memory dump addresses range incorrect. Limit of memory is 0x" << hex << ORPSOC_SRAM_SIZE << ". Memory dumping disabled." << endl; |
} |
} |
|
if (do_memdump) |
{ |
// Were we given dump addresses? If not, we dump all of the memory |
// Size of memory isn't clearly defined in any one place. This could lead to |
// big problems when changing size of the RAM in simulation. |
|
if (memdump_start == 0 && memdump_end == 0) |
memdump_end = ORPSOC_SRAM_SIZE; |
|
if (memdump_start != 0 && memdump_end == 0) |
{ |
// Probably just got the single memorydump param |
// Interpet as a length from 0 |
memdump_end = memdump_start; |
memdump_start = 0; |
} |
|
if (memdump_start & 0x3) memdump_start &= ~0x3; // word-align the start address |
if (memdump_end & 0x3) memdump_end = (memdump_end+4) & ~0x3; // word-align the start address |
|
memdump_start_addr = memdump_start; |
memdump_end_addr = memdump_end; |
} |
|
|
|
|
|
// checkInstruction monitors the bus for special NOP instructionsl |
SC_METHOD (checkInstruction); |
sensitive << clk.pos(); |
153,7 → 234,7
void |
Or1200MonitorSC::printSwitches() |
{ |
printf(" [-l <file>] [-q] [-p [<file>]]"); |
printf(" [-l <file>] [-q] [-p [<file>]] [-m [<file>] [<0xstardaddr> <0xendaddr>]]"); |
} |
|
//! Print usage for the options of this module |
163,6 → 244,7
printf(" -p, --profile\t\tEnable execution profiling output to file (default "DEFAULT_PROF_FILE")\n"); |
printf(" -l, --log\t\tLog processor execution to file\n"); |
printf(" -q, --quiet\t\tDisable the performance summary at end of simulation\n"); |
printf(" -m, --memdump\t\tDump data from the system's RAM to a file on finish\n\n"); |
} |
|
//! Method to handle special instrutions |
181,9 → 263,15
uint32_t r3; |
double ts; |
|
cycle_count++; |
// Check the instruction when the freeze signal is low. |
if (!accessor->getWbFreeze()) |
//if (!accessor->getWbFreeze()) |
if ((!accessor->getWbFreeze()) && (accessor->getExceptType() == 0)) |
{ |
|
// Increment instruction counter |
insn_count++; |
|
// Do something if we have l.nop |
switch (accessor->getWbInsn()) |
{ |
193,7 → 281,9
std::cout << std::fixed << std::setprecision (2) << ts; |
std::cout << " ns: Exiting (" << r3 << ")" << std::endl; |
perfSummary(); |
if (logging_enabled != 0) statusFile.close(); |
if (logging_enabled) statusFile.close(); |
if (profiling_enabled) profileFile.close(); |
memdump(); |
SIM_RUNNING=0; |
sc_stop(); |
break; |
234,14 → 324,10
uint32_t o_b; // operand b |
struct label_entry *tmp; |
|
cycle_count++; |
// Instructions should be valid when freeze is low and there are no exceptions |
//if (!accessor->getExFreeze()) |
if ((!accessor->getWbFreeze()) && (accessor->getExceptType() == 0)) |
{ |
// Increment instruction counter |
insn_count++; |
|
//exinsn = accessor->getExInsn();// & 0x3ffffff; |
exinsn = accessor->getWbInsn(); |
// Check the instruction |
358,3 → 444,46
return; |
} // perfSummary |
|
|
//! Dump contents of simulation's RAM to file |
void |
Or1200MonitorSC::memdump() |
{ |
if (!do_memdump) return; |
uint32_t current_word; |
int size_words = (memdump_end_addr/4) - (memdump_start_addr/4); |
if (!(size_words > 0)) return; |
|
// First try opening the file |
memdumpFile.open(memdumpFileName.c_str(), ios::binary); // Open memorydump file |
if(memdumpFile.is_open()) |
{ |
// If we could open the file then turn on logging |
cout << "* Dumping system RAM from 0x" << hex << memdump_start_addr << "-0x" << hex << memdump_end_addr << " to file " << memdumpFileName << endl; |
|
// Convert memdump_start_addr to word address |
memdump_start_addr = memdump_start_addr / 4; |
while (size_words) |
{ |
// Read the data from the simulation memory |
current_word = accessor->get_mem(memdump_start_addr); |
//cout << hex << current_word << " "; |
/* |
cout << hex << ((current_word >> 24 ) & 0xff) << " "; |
cout << hex << ((current_word >> 16) & 0xff) << " "; |
cout << hex << ((current_word >> 8 ) & 0xff) << " " ; |
cout << hex << ((current_word >> 0 ) & 0xff) << " "; |
*/ |
// Change from whatever endian the host is (most |
// cases little) to big endian |
current_word = htonl(current_word); |
memdumpFile.write((char*) ¤t_word, 4); |
memdump_start_addr++; size_words--; |
} |
|
// Ideally we've now finished piping out the data |
// not 100% about the endianess of this. |
} |
memdumpFile.close(); |
|
} |
/trunk/orpsocv2/bench/sysc/src/OrpsocMain.cpp
308,7 → 308,7
//#endif |
} |
|
printf("* Beginning test\n"); |
//printf("* Beginning test\n"); |
|
// Init the UART function |
uart->initUart(25000000, 115200); |
339,7 → 339,9
SIM_RUNNING=0; |
sc_stop(); |
// Print performance summary |
monitor->perfSummary(); |
monitor->perfSummary(); |
// Do memdump if enabled |
monitor->memdump(); |
} |
else |
{ |
388,6 → 390,8
sc_stop(); |
// Print performance summary |
monitor->perfSummary(); |
// Do memdump if enabled |
monitor->memdump(); |
} |
break; |
} |
400,6 → 404,8
sc_stop(); |
// Close dump file |
spTraceFile->close(); |
// Do memdump if enabled |
monitor->memdump(); |
// Print performance summary |
monitor->perfSummary(); |
break; |
412,6 → 418,7
else |
{ |
// Simple run case |
// Ideally a "l.nop 1" will terminate the simulation gracefully |
sc_start(); |
} |
|