27 #if HAVE_IVERILOG_VPI_USER_H 28 #include <iverilog/vpi_user.h> 44 if (h>=devices.size()) {
45 vpi_printf(
"There has never been an AVR device with the handle %d.", h);
46 vpi_control(vpiFinish, 1);
50 vpi_printf(
"The AVR with handle %d has already been destroyed.", h);
51 vpi_control(vpiFinish, 1);
58 #define VPI_UNPACKS(name) \ 60 vpiHandle name = vpi_scan(argv); \ 62 vpi_printf("%s: " #name " parameter missing.\n", xx);\ 63 vpi_free_object(argv); \ 66 value.format = vpiStringVal; \ 67 vpi_get_value(name, &value); \ 69 std::string name = value.value.str; 71 #define VPI_UNPACKI(name) \ 73 vpiHandle name = vpi_scan(argv); \ 75 vpi_printf("%s: " #name " parameter missing.\n", xx);\ 76 vpi_free_object(argv); \ 79 value.format = vpiIntVal; \ 80 vpi_get_value(name, &value); \ 82 int name = value.value.integer; 84 #define VPI_UNPACKT(name) \ 86 vpiHandle name = vpi_scan(argv); \ 88 vpi_printf("%s: " #name " parameter missing.\n", xx);\ 89 vpi_free_object(argv); \ 92 value.format = vpiTimeVal; \ 93 vpi_get_value(name, &value); \ 95 t_vpi_time *name = value.value.time; 97 #define VPI_RETURN_INT(val) \ 98 value.format = vpiIntVal; \ 99 value.value.integer = (val); \ 100 vpi_put_value(ch, &value, 0, vpiNoDelay); \ 103 #define AVR_HCHECK() \ 104 if (!checkHandle(handle)) { \ 105 vpi_printf("%s: Invalid handle parameter.\n", xx); \ 109 #define VPI_BEGIN() \ 111 vpiHandle ch = vpi_handle(vpiSysTfCall, 0); \ 112 vpiHandle argv = vpi_iterate(vpiArgument, ch); 115 vpi_free_object(argv); 117 #define VPI_REGISTER_TASK(name) \ 119 s_vpi_systf_data tf_data; \ 120 tf_data.type = vpiSysTask; \ 121 tf_data.tfname = "$" #name; \ 122 tf_data.calltf = name ## _tf; \ 123 tf_data.compiletf = 0; \ 124 tf_data.sizetf = 0; \ 125 tf_data.user_data = (PLI_BYTE8 *)"$" #name; \ 126 vpi_register_systf(&tf_data); \ 129 #define VPI_REGISTER_FUNC(name) \ 131 s_vpi_systf_data tf_data; \ 132 tf_data.type = vpiSysFunc; \ 133 tf_data.tfname = "$" #name; \ 134 tf_data.calltf = name ## _tf; \ 135 tf_data.compiletf = 0; \ 136 tf_data.sizetf = 0; \ 137 tf_data.user_data = (PLI_BYTE8 *)"$" #name; \ 138 vpi_register_systf(&tf_data); \ 160 devices.push_back(dev);
162 dev->
Load(progname.c_str());
179 devices[handle]->Reset();
198 delete devices[handle];
216 devices[handle]->Step(no_hw);
230 uint64_t tfull=(time->low)<<32+((uint64_t) time->high);
249 Pin *pin=devices[handle]->GetPin(name.c_str());
269 Pin *pin=devices[handle]->GetPin(name.c_str());
332 devices[handle]->SetRWMem(address, val);
354 if (tracename.length()) {
356 for (
size_t i=0; i < devices.size(); i++)
357 devices[i]->trace_on=1;
360 for (
size_t i=0; i < devices.size(); i++)
361 devices[i]->trace_on=0;
375 std::vector<std::string> dargs;
376 dargs.push_back(dumparg);
static std::vector< AvrDevice * > devices
Basic AVR device, contains the core functionality.
static PLI_INT32 avr_tick_tf(char *xx)
static bool checkHandle(int h)
#define VPI_UNPACKI(name)
static PLI_INT32 avr_get_pin_tf(char *xx)
SystemConsoleHandler sysConHandler
The SystemConsoleHandler instance for common usage.
Pin class, handles input and output to external parts.
void(* vlog_startup_routines[])()
#define VPI_RETURN_INT(val)
#define VPI_UNPACKT(name)
static PLI_INT32 avr_get_rw_tf(char *xx)
static PLI_INT32 avr_set_rw_tf(char *xx)
void SetTraceFile(const char *name, unsigned int maxlines=0)
Sets the trace to file stream and enables tracing global.
static PLI_INT32 avr_get_pc_tf(char *xx)
#define VPI_REGISTER_FUNC(name)
T_Pinstate
Possible PIN states.
static PLI_INT32 avr_trace_tf(char *xx)
static AvrFactory & instance()
Singleton class access.
void stopApplication(void)
Stop processing on all dumpers and removes it from dumpers list.
#define VPI_REGISTER_TASK(name)
void StopTrace(void)
Stops tracing global, close file, if set, redirect trace to nullStream.
static SystemClock & Instance()
Returns the central SystemClock instance for the application.
T_Pinstate outState
discrete value of output stage
AvrDevice * makeDevice(const char *config)
static PLI_INT32 avr_dump_stop_tf(char *xx)
static PLI_INT32 avr_set_pin_tf(char *xx)
static void register_tasks()
void SetCurrentTime(SystemClockOffset of)
Set the simulation time to a dedicated value.
static PLI_INT32 avr_reset_tf(char *xx)
virtual void SetInState(const Pin &p)
handles the input value from net
void Load(const char *n)
Load flash, eeprom, signature, fuses from elf file, wrapper for LoadBFD or LoadSimpleELF.
static PLI_INT32 avr_destroy_tf(char *xx)
#define VPI_UNPACKS(name)
static DumpManager * Instance(void)
Singleton class access.
static PLI_INT32 avr_dump_start_tf(char *xx)
static PLI_INT32 avr_set_time_tf(char *xx)
void SetDumpTraceArgs(const std::vector< std::string > &traceopts, AvrDevice *dev)
Parse given trace options and open Dumper.
static PLI_INT32 avr_dump_arg_tf(char *xx)
static PLI_INT32 avr_create_tf(char *xx)