-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C code simulation using Verilator #66
Comments
my apologies for the incomplete documentation, I am hoping to improve it very soon! The best starting point for simulating Vicuna with Verilator is to compile your program to a
The file
where If you do not want to dump any memory to a file you may simply use a
Note that simulation continues until your program attempts to access memory address 0 (which happens upon exceptions, thus an exception will halt simulation). To intentionally end simulation you may simply jump to address 0 using the assembly instruction Unfortunately, there is currently no printf or similar output for simulation (although that would certainly be a great addition). However, you could modify the Verilator simulation source file verilator_main.cpp. For instance, you could add some code to the if statement on line 183 that prints to stdout when writing a certain address, e.g.:
Please let me know if you encounter any issues while following these instructions. |
Thank you for your quick response @michael-platzer! I can do printf C function and replicate all the info you provided. If you wish I could provide the basic functions for C printf function. Example C code: #include <stdint.h>
#include <runtime.h>
#include <printf.h>
#define q_field 16
int16_t wires_idx[q_field][q_field] = {
{0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120},
{8,0,40,72,120,16,88,112,80,24,64,48,104,96,56,32},
{16,40,0,48,80,8,24,96,120,88,32,72,56,112,104,64},
{24,72,48,0,56,88,16,32,104,8,96,40,80,64,120,112},
{32,120,80,56,0,64,96,24,40,112,16,104,48,88,72,8},
{40,16,8,88,64,0,72,104,32,48,120,24,112,56,96,80},
{48,88,24,16,96,72,0,80,112,40,56,8,32,120,64,104},
{56,112,96,32,24,104,80,0,88,120,48,64,16,40,8,72},
{64,80,120,104,40,32,112,88,0,96,8,56,72,24,48,16},
{72,24,88,8,112,48,40,120,96,0,104,16,64,80,32,56},
{80,64,32,96,16,120,56,48,8,104,0,112,24,72,88,40},
{88,48,72,40,104,24,8,64,56,16,112,0,120,32,80,96},
{96,104,56,80,48,112,32,16,72,64,24,120,0,8,40,88},
{104,96,112,64,88,56,120,40,24,80,72,32,8,0,16,48},
{112,56,104,120,72,96,64,8,48,32,88,80,40,16,0,24},
{120,32,64,112,8,80,104,72,16,56,40,96,88,48,24,0}
};
int main(void)
{
int i = 0;
for(i=0; i<q_field;i++)
printf("wires_idx[0][i]: %d\n\r",wires_idx[0][i]);
printf("Hello world!\n\r");
asm volatile("jr x0;");
return 0;
} |
Hi @michael-platzer, It seems that CSR performance is not enabled in verilator, right? |
Hi @kuoyaoming93 thanks for the feedback! These CSR registers are part of the main core. I do not know whether these are enabled by default, but the documentation of Ibex and CV32E40X should have more details on these. FYI, I am about to merge a large PR that changes many of the RTL source files and introduces a new way to configure Vicuna. However, my instructions above for simulating using Verilator should still work. |
A slight inconvenience of the changes in #43 is that the Verilator 4.210 is now required to simulate Vicuna. If your distribution only features older versions, you can compile version 4.210 from source as follows:
Note that the last two lines are optional, you may as well run Verilator from the build directory. |
Hi @michael-platzer, thank you for your feedback. I will check in detail the config of Ibex, and see why I can access to mcycle(h) in FPGA implementation, but not in Verilator. |
Hi @michael-platzer
I'm working in the optimization of some algorithms in C, and I would like to use Vicuna to speedup the operations.
I don't have any FPGA board with me now, that's why I want to simulate all using Verilator, to extract some metrics regarding the improvement.
Thank you in advance,
Yao-Ming
The text was updated successfully, but these errors were encountered: