Closed lpawelcz closed 12 months ago
Thank you for filing a detailed issue! In your example, it doesn't look like anything includes el2_pdef.vh
. With the include added el2_lib.sv
, I get:
module el2_btb_tag_hash (
pc,
hash
);
parameter [17:0] pt = 18'h00a09;
input wire [((pt[17-:9] + pt[8-:9]) + pt[8-:9]) + pt[8-:9]:pt[17-:9] + 1] pc;
output wire [pt[8-:9] - 1:0] hash;
assign hash = {(pc[((pt[17-:9] + pt[8-:9]) + pt[8-:9]) + pt[8-:9]:((pt[17-:9] + pt[8-:9]) + pt[8-:9]) + 1] ^ pc[(pt[17-:9] + pt[8-:9]) + pt[8-:9]:(pt[17-:9] + pt[8-:9]) + 1]) ^ pc[pt[17-:9] + pt[8-:9]:pt[17-:9] + 1]};
endmodule
Ohhh, you are right! Thank you very much for pointing that out. I experimented a little bit with that and it looks like we can also get the same result with changing the sv2v
command by adding the header to FILES
:
sv2v -I ./inc -w el2_lib.v el2_lib.sv inc/el2_pdef.vh
This way I don't have to modify the sources but on the other hand I loose the ability to use -w adjacent
because sv2v would exit with: Refusing to write adjacent to "inc/el2_pdef.vh" because that path does not end in ".sv"
It turns out that my initial problem was just incorrect sv2v usage.
You may also be interested in the write directory feature I just pushed. It's discussed at the end of #218.
That looks awesome, I'll surely test that out. Thanks a lot!
@lpawelcz Is there anything more to work on for this issue?
Oh sorry for the delay, I think we can close this issue as the problem was on my side. Thank you for your help, I really appreciate that. I also started using this new write directory feature and I must say it is super helpful :)
Hi @zachjs, I tried to use sv2v to convert VeeR EL2 core to Verilog but I came across this behavior where sv2v does not convert correctly module parameters which are included from header files and are defined as struct.
You can reproduce the issue with the following example.
directory structure:
inc/el2_pdef.vh:
inc/el2_param.vh:
el2_lib.sv:
Here is the result of converting
el2_lib.sv
withsv2v -I ./inc -w adjacent el2_lib.sv
toel2_lib.v
:For more context here is the syntax error from yosys:
I believe parameter
pt
should be unfolded into separate parameters:BTB_ADDR_HI
andBTB_BTAG_SIZE
and the references in the module should also take this into account.Another thing worth noting about this issue is that it is not strictly related to parameter being included inside the module definition because we can modify
el2_lib.sv
and manually include the parameter like so:and we would still get exactly the same result in converted verilog.