ParaNut SystemC Model
A SystemC Model of the ParaNut architecture
|
Helpers, Makros and performance measuring Classes used in most ParaNut files. More...
Classes | |
class | CEventDef |
Event definition class. More... | |
class | CPerfMon |
Performance monitor class. More... | |
class | CPerfMonCPU |
CPU performance monitor class. More... | |
Macros | |
#define | PN_CLOCK_TRIGGERED(method_name) SC_METHOD(method_name) sensitive << clk.pos(); |
Performance measuring... | |
enum | EEventsCPU { EV_ALU = 0 , EV_LOAD , EV_STORE , EV_JUMP , EV_OTHER , EV_IFETCH } |
CPU performance monitor events enum. More... | |
Basic types and constants... | |
typedef unsigned char | TByte |
Byte type (8 Bit). More... | |
typedef unsigned short | THalfWord |
Half word type (16 Bit). More... | |
typedef unsigned | TWord |
Word type (32 Bit). More... | |
typedef unsigned long long | TDWord |
Double word type (64 Bit). More... | |
#define | KB 1024 |
Number of Bytes in a Kilobyte. More... | |
#define | MB (1024 * 1024) |
Number of Bytes in a Megabyte. More... | |
#define | GB (1024 * 1024 * 1024) |
Number of Bytes in a Gigabyte. More... | |
#define | MIN(A, B) ((A) < (B) ? (A) : (B)) |
Minimum of A and B. More... | |
#define | MAX(A, B) ((A) > (B) ? (A) : (B)) |
Maximum of A and B. More... | |
#define | NUM_BITS(A) ((int)(ceil(log2 (A)))) |
Number of bits necessary to encode A. More... | |
#define | C(MEMBER) (MEMBER == t.MEMBER) |
Convenient macro to compare a member variable with the member of input t. More... | |
#define | C_ARR(MEMBER, NUM) ({ bool ret = 1; for (int n = 0; n < NUM; ++n) if (!C(MEMBER[n])) ret = 0; ret; }) |
Same as C(MEMBER), but for arrays. More... | |
#define | XLEN 32 |
Number of instruction/register Bits. More... | |
Dynamic Configuration.... | |
int | pn_cfg_vcd_level |
VCD trace level. More... | |
int | pn_cfg_insn_trace |
Internal simulation instruction trace level. More... | |
bool | pn_cfg_disable_cache |
Cache enable override. More... | |
bool | pn_cfg_debug_mode |
Interactive debug mode enable. More... | |
SystemC tracing... | |
bool | pn_trace_verbose |
Output verbose tracing information. More... | |
std::string | pn_GetTraceName (sc_object *obj, const char *name, int dim, int arg1, int arg2) |
Generates and returns a trace file compatible string. More... | |
#define | PN_TRACE(TF, OBJ) |
Add sc_object OBJ to the trace file TF. More... | |
#define | PN_TRACE_BUS(TF, OBJ, N_MAX) |
Add each sc_object of OBJ array/bus to the trace file TF. More... | |
#define | PN_TRACE_BUS_BUS(TF, OBJ, N_MAX, K_MAX) |
Add each sc_object of 2D OBJ array/bus to the trace file TF. More... | |
#define | PN_TRACE_R(TF, OBJ, MEMBER, STR) |
Helper macro for recursively calling sc_trace in own types/structs. More... | |
#define | PN_TRACE_R_BUS(TF, OBJ, MEMBER, STR, N_MAX) |
Helper macro for recursively calling sc_trace in own types/structs. More... | |
#define | PN_TRACE_R_BUS_BUS(TF, OBJ, MEMBER, STR, N_MAX, K_MAX) |
Helper macro for recursively calling sc_trace in own types/structs. More... | |
Testbench helpers... | |
sc_trace_file * | pn_trace_file |
ParaNut trace file pointer. More... | |
char * | pn_TbPrintf (const char *format,...) |
Testbench printf helper. More... | |
void | pn_TbAssert (bool cond, const char *msg, const char *filename, const int line) |
Testbench assert helper. More... | |
void | pn_TbInfo (const char *msg, const char *filename, const int line) |
Testbench information helper. More... | |
void | pn_TbWarning (const char *msg, const char *filename, const int line) |
Testbench warning helper. More... | |
void | pn_TbError (const char *msg, const char *filename, const int line) |
Testbench error helper. More... | |
template<typename T > | |
sc_core::sc_signal_in_if< T > const & | vh_const (T const &v) |
vvh_const type/struct (vhdl constant value equivalent) More... | |
char * | pn_DisAss (TWord insn) |
Dissassemble RISC-V instructions to C string. More... | |
#define | PN_ASSERT(COND) pn_TbAssert (COND, NULL, __FILE__, __LINE__) |
Testbench assert without message. More... | |
#define | PN_ASSERTF(COND, FMT) pn_TbAssert (COND, pn_TbPrintf FMT, __FILE__, __LINE__) |
Testbench assert with formatted message. More... | |
#define | PN_ASSERTM(COND, MSG) pn_TbAssert (COND, MSG, __FILE__, __LINE__) |
Testbench assert with message. More... | |
#define | PN_INFO(MSG) pn_TbInfo (MSG, __FILE__, __LINE__) |
Testbench info with message. More... | |
#define | PN_INFOF(FMT) pn_TbInfo (pn_TbPrintf FMT, __FILE__, __LINE__) |
Testbench info with formatted message. More... | |
#define | PN_WARNING(MSG) pn_TbWarning (MSG, __FILE__, __LINE__) |
Testbench warning with message. More... | |
#define | PN_WARNINGF(FMT) pn_TbWarning (pn_TbPrintf FMT, __FILE__, __LINE__) |
Testbench warning with formatted message. More... | |
#define | PN_ERROR(MSG) pn_TbError (MSG, __FILE__, __LINE__) |
Testbench error with message. More... | |
#define | PN_ERRORF(FMT) pn_TbError (pn_TbPrintf FMT, __FILE__, __LINE__) |
Testbench error with formatted message. More... | |
Static Configuration... | |
#define | PN_BIG_ENDIAN 0 |
System endianess configuration. More... | |
Helpers, Makros and performance measuring Classes used in most ParaNut files.
#define C | ( | MEMBER | ) | (MEMBER == t.MEMBER) |
Convenient macro to compare a member variable with the member of input t.
#define C_ARR | ( | MEMBER, | |
NUM | |||
) | ({ bool ret = 1; for (int n = 0; n < NUM; ++n) if (!C(MEMBER[n])) ret = 0; ret; }) |
Same as C(MEMBER), but for arrays.
#define GB (1024 * 1024 * 1024) |
Number of Bytes in a Gigabyte.
#define KB 1024 |
Number of Bytes in a Kilobyte.
#define MAX | ( | A, | |
B | |||
) | ((A) > (B) ? (A) : (B)) |
Maximum of A and B.
#define MB (1024 * 1024) |
Number of Bytes in a Megabyte.
#define MIN | ( | A, | |
B | |||
) | ((A) < (B) ? (A) : (B)) |
Minimum of A and B.
#define NUM_BITS | ( | A | ) | ((int)(ceil(log2 (A)))) |
Number of bits necessary to encode A.
#define PN_ASSERT | ( | COND | ) | pn_TbAssert (COND, NULL, __FILE__, __LINE__) |
Testbench assert without message.
Calls pn_TbAssert() with the condition COND, an empty message and the filename and line macros.
COND | is the condition to assert. |
#define PN_ASSERTF | ( | COND, | |
FMT | |||
) | pn_TbAssert (COND, pn_TbPrintf FMT, __FILE__, __LINE__) |
Testbench assert with formatted message.
Calls pn_TbAssert() with the condition COND, the formatted message according to FMT and the filename and line macros.
NOTE: You need to put the FMT argument in brackets (e.g. PN_ASSERTF(1, ("E: %d", 5));)
COND | is the condition to assert. |
FMT | is the format C string and all additional arguments needed to print if the assertion fails. |
#define PN_ASSERTM | ( | COND, | |
MSG | |||
) | pn_TbAssert (COND, MSG, __FILE__, __LINE__) |
Testbench assert with message.
Calls pn_TbAssert() with the condition COND, the supplied message MSG and the filename and line macros.
COND | is the condition to assert. |
MSG | is the C string to print if the assertion fails. |
#define PN_BIG_ENDIAN 0 |
System endianess configuration.
Can be used to switch between 0 - little endian and 1 - big endian for testing purposes.
CAUTION: For RISC-V this should always be 0.
#define PN_CLOCK_TRIGGERED | ( | method_name | ) | SC_METHOD(method_name) sensitive << clk.pos(); |
#define PN_ERROR | ( | MSG | ) | pn_TbError (MSG, __FILE__, __LINE__) |
Testbench error with message.
Calls pn_TbError() with the supplied message MSG and the filename and line macros.
MSG | is the C string to print. |
#define PN_ERRORF | ( | FMT | ) | pn_TbError (pn_TbPrintf FMT, __FILE__, __LINE__) |
Testbench error with formatted message.
Calls pn_TbError() with the formatted message according to FMT and the filename and line macros.
NOTE: You need to put the FMT argument in brackets (e.g. PN_ERRORF(("Val: %d", 5));)
FMT | is the format C string and all additional arguments needed to print. |
#define PN_INFO | ( | MSG | ) | pn_TbInfo (MSG, __FILE__, __LINE__) |
Testbench info with message.
Calls pn_TbInfo() with the supplied message MSG and the filename and line macros.
MSG | is the C string to print. |
#define PN_INFOF | ( | FMT | ) | pn_TbInfo (pn_TbPrintf FMT, __FILE__, __LINE__) |
Testbench info with formatted message.
Calls pn_TbInfo() with the formatted message according to FMT and the filename and line macros.
NOTE: You need to put the FMT argument in brackets (e.g. PN_INFO(("Val: %d", 5));)
FMT | is the format C string and all additional arguments needed to print. |
#define PN_TRACE | ( | TF, | |
OBJ | |||
) |
Add sc_object OBJ to the trace file TF.
Macro for easily adding the sc_object (port/signal) to a trace file. Uses pn_GetTraceName to generate the correct object name.
TF | is the trace file. |
OBJ | is the sc_object (port/signal). |
#define PN_TRACE_BUS | ( | TF, | |
OBJ, | |||
N_MAX | |||
) |
Add each sc_object of OBJ array/bus to the trace file TF.
Macro for easily adding the array/bus of sc_objects (port/signal) to a trace file. Uses pn_GetTraceName to generate the correct object name.
TF | is the trace file. |
OBJ | is the array/bus of sc_objects (port/signal). |
N_MAX | is number of array/bus elements. |
#define PN_TRACE_BUS_BUS | ( | TF, | |
OBJ, | |||
N_MAX, | |||
K_MAX | |||
) |
Add each sc_object of 2D OBJ array/bus to the trace file TF.
Macro for easily adding the two dimensional array/bus of sc_objects (port/signal) to a trace file. Uses pn_GetTraceName to generate the correct object name.
TF | is the trace file. |
OBJ | is the array/bus of sc_objects (port/signal). |
N_MAX | is number of array/bus elements in the first dimension. |
K_MAX | is number of array/bus elements in the second dimension. |
#define PN_TRACE_R | ( | TF, | |
OBJ, | |||
MEMBER, | |||
STR | |||
) |
Helper macro for recursively calling sc_trace in own types/structs.
Macro for easily adding a sc_object member (port/signal) of an sc_object to a trace file. Use PN_TRACE_R when overloading sc_trace for own types/structs to easily trace its members.
TF | is the trace file. |
OBJ | is the sc_objects having the member MEMBER. |
MEMBER | is the member sc_object (port/signal). |
STR | is the calling sc_trace string to which the member name will be appended. |
#define PN_TRACE_R_BUS | ( | TF, | |
OBJ, | |||
MEMBER, | |||
STR, | |||
N_MAX | |||
) |
Helper macro for recursively calling sc_trace in own types/structs.
Macro for easily adding each sc_object of an array member (ports/signals) of an sc_object to a trace file. Use PN_TRACE_R_BUS when overloading sc_trace for own types/structs to easily trace its members.
TF | is the trace file. |
OBJ | is the sc_objects having the member MEMBER. |
MEMBER | is the member sc_object (port/signal). |
STR | is the calling sc_trace string to which the member name + index will be appended. |
N_MAX | is number of MEMBER array/bus elements. |
#define PN_TRACE_R_BUS_BUS | ( | TF, | |
OBJ, | |||
MEMBER, | |||
STR, | |||
N_MAX, | |||
K_MAX | |||
) |
Helper macro for recursively calling sc_trace in own types/structs.
Macro for easily adding each sc_object of an two-dimensional array member (ports/signals) of an sc_object to a trace file. Use PN_TRACE_R_BUS_BUS when overloading sc_trace for own types/structs to easily trace its members.
TF | is the trace file. |
OBJ | is the sc_objects having the member MEMBER. |
MEMBER | is the member sc_object (port/signal). |
STR | is the calling sc_trace string to which the member name + index will be appended. |
N_MAX | is number of array/bus elements in the first dimension. |
K_MAX | is number of array/bus elements in the second dimension. |
#define PN_WARNING | ( | MSG | ) | pn_TbWarning (MSG, __FILE__, __LINE__) |
Testbench warning with message.
Calls pn_TbWarning() with the supplied message MSG and the filename and line macros.
MSG | is the C string to print. |
#define PN_WARNINGF | ( | FMT | ) | pn_TbWarning (pn_TbPrintf FMT, __FILE__, __LINE__) |
Testbench warning with formatted message.
Calls pn_TbWarning() with the formatted message according to FMT and the filename and line macros.
NOTE: You need to put the FMT argument in brackets (e.g. PN_WARNINGF(("Val: %d", 5));)
FMT | is the format C string and all additional arguments needed to print. |
#define XLEN 32 |
Number of instruction/register Bits.
typedef unsigned char TByte |
Byte type (8 Bit).
typedef unsigned long long TDWord |
Double word type (64 Bit).
typedef unsigned short THalfWord |
Half word type (16 Bit).
typedef unsigned TWord |
Word type (32 Bit).
enum EEventsCPU |
char* pn_DisAss | ( | TWord | insn | ) |
Dissassemble RISC-V instructions to C string.
Takes the 32 Bit RISC-V instruction insn and disassembles it into a human readable C string. Disassembles all instructions the ParaNut processor can execute (RV32IMA currently). Returns "? 0xHEX_VALUE_OF_INSN" if the instruction is unknown or invalid.
NOTE: The returned string is only valid until the next call to this function.
insn | is the instruction to disassemble. |
std::string pn_GetTraceName | ( | sc_object * | obj, |
const char * | name, | ||
int | dim, | ||
int | arg1, | ||
int | arg2 | ||
) |
Generates and returns a trace file compatible string.
Generates and returns a trace file compatible string using the supplied information to parse multidimensional inputs.
obj | is the sc_object (port/signal) pointer. |
name | is the base name appearing in the trace file. |
dim | is the number of dimensions the obj has (only 0 to 2 are supported). |
arg1 | is the number to add to the base name to represent the first dimension (should be 0 for dim < 1). |
arg2 | is the number to add to the base name + first dimension to represent the second dimension (should be 0 for dim < 2). |
void pn_TbAssert | ( | bool | cond, |
const char * | msg, | ||
const char * | filename, | ||
const int | line | ||
) |
Testbench assert helper.
Asserts condition cond and if it fails prints the supplied msg, filename and line to stderr, closes the pn_trace_file and aborts program execution.
Should be called through the PN_ASSERT(), PN_ASSERTF() and PN_ASSERTM() macros.
cond | is the condition to assert. |
msg | is a C string to print if the assertion fails. |
filename | is a C string to print if the assertion fails containig the source filename. |
line | is the line number in the source file to print if the assertion fails. |
void pn_TbError | ( | const char * | msg, |
const char * | filename, | ||
const int | line | ||
) |
Testbench error helper.
Prints the supplied msg to stderr with a defined header containing the current SytemC simulation time stamp, filename and line and the "(ERROR):" keyword. Also closes the pn_trace_file and exits the program execution with an error.
Should be called through the PN_ERROR() and PN_ERRORF() macros.
msg | is a C string to print. |
filename | is a C string to print containig the source filename. |
line | is the line number in the source file to print |
void pn_TbInfo | ( | const char * | msg, |
const char * | filename, | ||
const int | line | ||
) |
Testbench information helper.
Prints the supplied msg to stderr with a defined header containing the current SytemC simulation time stamp, filename and line and the "(INFO):" keyword.
Should be called through the PN_INFO() and PN_INFOF() macros.
msg | is a C string to print. |
filename | is a C string to print containig the source filename. |
line | is the line number in the source file to print. |
char* pn_TbPrintf | ( | const char * | format, |
... | |||
) |
Testbench printf helper.
Returns a C string formatted according to supplied format and addistional arguments.
format | is a C string that contains the text to be formatted. |
... | (additional arguments) are the parameters according to the format string. |
void pn_TbWarning | ( | const char * | msg, |
const char * | filename, | ||
const int | line | ||
) |
Testbench warning helper.
Prints the supplied msg to stderr with a defined header containing the current SytemC simulation time stamp, filename and line and the "(WARNING):" keyword.
Should be called through the PN_WARNING() and PN_WARNINGF() macros.
msg | is a C string to print. |
filename | is a C string to print containig the source filename. |
line | is the line number in the source file to print. |
sc_core::sc_signal_in_if<T> const& vh_const | ( | T const & | v | ) |
vvh_const type/struct (vhdl constant value equivalent)
This type can be used to easily connect ports or signals to a "constant" value.
typename | is the type the constant value will be applied to. |
v | is the constant value. |
|
extern |
Interactive debug mode enable.
Holds the debug mode enable bit set by the "-d" command line option supplied to the MParaNutSystem constructor. If set, the MParaNutSystem will set up a remote bitbang interface on port 9824 and waits for you to connect to it. Use OpenOCD and GDB to debug software running in the SystemC model.
See doc/paranut_manual.pdf for more information.
|
extern |
Cache enable override.
Holds the disable cache bit set by the "-c" command line option supplied to the MParaNutSystem constructor. If set, disables instruction and data caching irrespective of the value in the pncache CSR.
|
extern |
Internal simulation instruction trace level.
Holds the internal simulation instruction trace level set by the "-i" command line option supplied to the MParaNutSystem constructor.
|
extern |
VCD trace level.
Holds the VCD trace level (0 = no VCD file) set by the "-t" command line option supplied to the MParaNutSystem constructor.
|
extern |
ParaNut trace file pointer.
If set the trace file is closed using sc_close_vcd_trace_file() after errors and asserts.
|
extern |
Output verbose tracing information.
If set, the system modules will output verbose information when they trace their internal signals.