While writing a test bench for the full chip simul...
# caravel
a
While writing a test bench for the full chip simulation in /dv, what is the right way to assign values to the mprj_io pins? For instance, if I have a signal in user_project_wrapper connected to io_in[15], how might I simulate sending a 1 over that pin? Something like
assign mprj_io[15] = 1
will not compile because of invalid l-value error.
m
The LHS of an assign must be a wire not a reg
In this case replace it with: always (*) begin mprg_io[15] = 1 end
Unless you can change it from a reg to wire
or in a test bench, it is more comment to put it in an init block: init begin mprg_io[15] = 1; #10 mprg_io[15] = 0; ... end
If you look at dv/mprj_stimulus/mprj_stimulus_tb.v there are some examples
👍 1
a
The main issue is declaring it as wire leads to incorrect l-value error and declaring as reg leads to continuous assignment errors. Maybe the pins aren't designed to be assigned through the tb, but only through the firmware? Doesn't look like the given tests seem to be actively driving signals from the gpio pins. Maybe @Manar Abdelatty might have some additional info?
m
I don't quite understand. You definitely can't have a reg on the LHS of an assign. External to the Caravel module, it shouldn't matter what they are declared inside it so you can modify as needed in the test bench.
a
Basically, both of these cases will cause errors:
Copy code
wire [37:0] mprj_io;
// inside initial block  
assign mprj_io[16] = 1;
Copy code
reg [37:0] mprj_io;
// inside initial block  
mprj_io[16] = 1;
a
Interesting, it seems like mprj_io bits need to be assigned outside initial blocks. That ill make it tough to manually toggle certain signals after inserting delays. In the rgb test, what is driving enc0_a, etc? From the c file, I can see that they are set to user input but how are values sent over those?
m
maybe look at the dv tests that come with caravel_user_project, that's all done in verilog. Mine use cocotb
a
Looks like the best way is to create a reg and then assign the specific mprj_io bit to that reg and modify the reg value in an initial block