OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/orpsocv2/bench/sysc/src
    from Rev 42 to Rev 44
    Reverse comparison

Rev 42 → Rev 44

/Or1200MonitorSC.cpp
5,6 → 5,7
// Copyright (C) 2008 Embecosm Limited <info@embecosm.com>
 
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
// Contributor Julius Baxter <jb@orsoc.se>
 
// This file is part of the cycle accurate model of the OpenRISC 1000 based
// system-on-chip, ORPSoC, built using Verilator.
28,8 → 29,12
 
#include <iostream>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
#include "Or1200MonitorSC.h"
#include "OrpsocMain.h"
 
 
SC_HAS_PROCESS( Or1200MonitorSC );
47,6 → 52,14
SC_METHOD (checkInstruction);
sensitive << clk.pos();
dont_initialize();
 
SC_METHOD (displayState);
logging_enabled = 0; // Default is logging disabled
exit_perf_summary_enabled = 1; // Simulation exit performance summary is on by default. Turn off with "-q" on the cmd line
sensitive << clk.pos();
dont_initialize();
 
start = clock();
} // Or1200MonitorSC ()
 
78,6 → 91,8
ts = sc_time_stamp().to_seconds() * 1000000000.0;
std::cout << std::fixed << std::setprecision (2) << ts;
std::cout << " ns: Exiting (" << r3 << ")" << std::endl;
if (exit_perf_summary_enabled) perfSummary();
if (logging_enabled != 0) statusFile.close();
sc_stop();
break;
 
106,3 → 121,120
 
} // checkInstruction()
 
//! Method to setup the files for outputting the state of the processor
 
//! This function will setup the output file, if enabled.
 
void
Or1200MonitorSC::init_displayState(int argc, char *argv[])
{
 
string logfileDefault("vlt-executed.log");
string logfileNameString;
 
// Parse the command line options
int cmdline_name_found=0;
if (argc > 1)
{
// Search through the command line parameters for the "-log" option
for(int i=1; i < argc; i++)
{
if (strcmp(argv[i], "-log")==0)
{
logfileNameString = (argv[i+1]);
cmdline_name_found=1;
break;
}
}
// Search through the command line parameters for the "-q","--no-perf-summary" option
for(int i=1; i < argc; i++)
{
if ((strcmp(argv[i], "-q")==0)||(strcmp(argv[i], "--no-perf-summary")==0))
{
exit_perf_summary_enabled = 0;
break;
}
}
 
}
 
if(cmdline_name_found==0) // No -log option specified so don't turn on logging
return;
 
statusFile.open(logfileNameString.c_str(), ios::out ); // open file to write to it
 
if(statusFile.is_open())
{
// If we could open the file then turn on logging
logging_enabled = 1;
cout << "Processor execution logged to file: " << logfileNameString << endl;
}
 
return;
 
}
 
//! Method to output the state of the processor
 
//! This function will output to a file, if enabled, the status of the processor
//! For now, it's just the PPC and instruction.
 
void
Or1200MonitorSC::displayState()
{
uint32_t wbinsn;
// Calculate how many instructions we've actually calculated by ignoring cycles where we're frozen, delay slots and flushpipe cycles
if ((!accessor->getWbFreeze()) && !(accessor->getExceptFlushpipe() && accessor->getExDslot()))
// Increment instruction counter
insn_count++;
 
if (logging_enabled == 0)
return; // If we didn't inialise a file, then just return.
 
// Output the state if we're not frozen and not flushing during a delay slot
if ((!accessor->getWbFreeze()) && !(accessor->getExceptFlushpipe() && accessor->getExDslot()))
{
// Print PC, instruction
statusFile << "\nEXECUTED("<< std::setfill(' ') << std::setw(11) << dec << insn_count << "): " << std::setfill('0') << hex << std::setw(8) << accessor->getWbPC() << ": " << hex << accessor->getWbInsn() << endl;
 
// Print general purpose register contents
for (int i=0; i<32; i++)
{
if ((i%4 == 0)&&(i>0)) statusFile << endl;
statusFile << std::setfill('0');
statusFile << "GPR" << dec << std::setw(2) << i << ": " << hex << std::setw(8) << (uint32_t) accessor->getGpr(i) << " ";
}
statusFile << endl;
 
statusFile << "SR : " << hex << std::setw(8) << (uint32_t) accessor->getSprSr() << " ";
statusFile << "EPCR0: " << hex << std::setw(8) << (uint32_t) accessor->getSprEpcr() << " ";
statusFile << "EEAR0: " << hex << std::setw(8) << (uint32_t) accessor->getSprEear() << " ";
statusFile << "ESR0 : " << hex << std::setw(8) << (uint32_t) accessor->getSprEsr() << endl;
 
}
 
return;
 
} // displayState()
 
//! Function to calculate the number of instructions performed and the time taken
void
Or1200MonitorSC::perfSummary()
{
double ts;
ts = sc_time_stamp().to_seconds() * 1000000000.0;
int cycles = ts / (BENCH_CLK_HALFPERIOD*2); // Number of clock cycles we had
 
clock_t finish = clock();
double elapsed_time = (double(finish)-double(start))/CLOCKS_PER_SEC;
// It took elapsed_time seconds to do insn_count instructions. Divide insn_count by the time to get instructions/second.
double ips = (insn_count/elapsed_time);
double mips = (insn_count/elapsed_time)/1000000;
std::cout << "Or1200Monitor: real time elapsed: " << elapsed_time << " seconds" << endl;
std::cout << "Or1200Monitor: simulated " << dec << cycles << " clock cycles, executed " << insn_count << " instructions" << endl;
std::cout << "Or1200Monitor: simulated insn/sec = " << ips << ", simulator mips = " << mips << endl;
return;
} // calculateMips()
 
/TraceSC.cpp
49,18 → 49,27
 
// Setup the name of the VCD dump file
string dumpNameDefault("vlt-dump.vcd");
string dumpSuffix("-vlt.vcd");
string dumpDir("../results/"); // Note: hardcoded to store all VCDs in the ../results dir
string testNameString;
string vcdDumpFile;
if (argc > 1) // If we were passed a name on the command line, use it
 
// Search through the command line parameters for the "-vcd" option
int cmdline_name_found=0;
if (argc > 1)
{
for(int i=1; i<argc; i++)
{
testNameString = (argv[1]);
vcdDumpFile = dumpDir + testNameString + dumpSuffix;
if (strcmp(argv[i], "-vcd")==0)
{
testNameString = (argv[i+1]);
vcdDumpFile = testNameString;
cmdline_name_found=1;
break;
}
}
else // otherwise use our default VCD dump file name
vcdDumpFile = dumpDir + dumpNameDefault;
}
 
if(cmdline_name_found==0) // otherwise use our default VCD dump file name
vcdDumpFile = dumpNameDefault;
Verilated::traceEverOn (true);
/OrpsocAccess.cpp
5,6 → 5,7
// Copyright (C) 2008 Embecosm Limited <info@embecosm.com>
 
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
// Contributor Julius Baxter <jb@orsoc.se>
 
// This file is part of the cycle accurate model of the OpenRISC 1000 based
// system-on-chip, ORPSoC, built using Verilator.
34,6 → 35,8
#include "Vorpsoc_top_or1200_top.h"
#include "Vorpsoc_top_or1200_cpu.h"
#include "Vorpsoc_top_or1200_ctrl.h"
#include "Vorpsoc_top_or1200_except.h"
#include "Vorpsoc_top_or1200_sprs.h"
#include "Vorpsoc_top_or1200_rf.h"
#include "Vorpsoc_top_or1200_dpram.h"
 
47,6 → 50,8
OrpsocAccess::OrpsocAccess (Vorpsoc_top *orpsoc_top)
{
or1200_ctrl = orpsoc_top->v->i_or1k->i_or1200_top->or1200_cpu->or1200_ctrl;
or1200_except = orpsoc_top->v->i_or1k->i_or1200_top->or1200_cpu->or1200_except;
or1200_sprs = orpsoc_top->v->i_or1k->i_or1200_top->or1200_cpu->or1200_sprs;
rf_a = orpsoc_top->v->i_or1k->i_or1200_top->or1200_cpu->or1200_rf->rf_a;
 
} // OrpsocAccess ()
63,7 → 68,39
 
} // getWbFreeze ()
 
//! Access for the except_flushpipe signal
 
//! @return The value of the or1200_except.except_flushpipe signal
 
bool
OrpsocAccess::getExceptFlushpipe ()
{
return or1200_except->except_flushpipe;
 
} // getExceptFlushpipe ()
 
//! Access for the ex_dslot signal
 
//! @return The value of the or1200_except.ex_dslot signalfac
 
bool
OrpsocAccess::getExDslot ()
{
return or1200_except->ex_dslot;
 
} // getExDslot ()
 
//! Access for the wb_pc register
 
//! @return The value of the or1200_except.wb_insn register
 
uint32_t
OrpsocAccess::getWbPC ()
{
return (or1200_except->get_wb_pc) ();
 
} // getWbPC ()
 
//! Access for the wb_insn register
 
//! @return The value of the or1200_ctrl.wb_insn register
90,3 → 127,49
return (rf_a->get_gpr) (regNum);
 
} // getGpr ()
 
 
//! Access for the sr register
 
//! @return The value of the or1200_sprs.sr register
 
uint32_t
OrpsocAccess::getSprSr ()
{
return (or1200_sprs->get_sr) ();
 
} // getSprSr ()
 
//! Access for the epcr register
 
//! @return The value of the or1200_sprs.epcr register
 
uint32_t
OrpsocAccess::getSprEpcr ()
{
return (or1200_sprs->get_epcr) ();
 
} // getSprEpcr ()
 
//! Access for the eear register
 
//! @return The value of the or1200_sprs.eear register
 
uint32_t
OrpsocAccess::getSprEear ()
{
return (or1200_sprs->get_eear) ();
 
} // getSprEear ()
 
//! Access for the esr register
 
//! @return The value of the or1200_sprs.esr register
 
uint32_t
OrpsocAccess::getSprEsr ()
{
return (or1200_sprs->get_esr) ();
 
} // getSprEsr ()
 
/OrpsocMain.cpp
160,6 → 160,9
// Init the UART function
uart->initUart(25000000, 115200);
 
// Turn on logging by setting the "-log logfilename" option on the command line
monitor->init_displayState(argc, argv);
 
// Execute until we stop
sc_start ();
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.