-
Notifications
You must be signed in to change notification settings - Fork 422
Resolve slang errors in VTR benchmarks #3195
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
base: master
Are you sure you want to change the base?
Conversation
I've begun testing the fixed verilog with my setup for yosys-slang and I'm getting failing benchmarks. and_latch.v - PASSED I stopped here because I felt like most other benchmarks would be getting similar errors. I'm not sure, but maybe it is because I disabled the UndrivenPass for slang #3169? The UndrivenPass was causing the vtr_primitives.v to error out. |
@loglav03 Can you do the following:
|
One small additional update. After installing the slang plugin from source on top of Yosys 0.54 and hiding the specify blocks in vtr_flow/primitives.v behind `ifdef wrappers, I was able to do the following simple experiment:
This command sequence completed successfully. So I think we need to focus on what issues in the test setup are interfering with a successful parse. |
Update: thanks to the traffic on #3181, I was able to quickly find my way to a portion of the testing that was being done, and use it to design a follow-up experiment. From a yosys command line, I did the following:
Note that the parmys vtr_primitives.v file used in and When I execute the above commands, I obtain the following errors similar to those reported by @loglav03
Something is preventing the read_slang command from seeing that the single_port_ram and dual_port_ram blocks are parameterized unless the primitives are read in as part of the same read_slang command as the benchmark. I've tried a few different things to try to resolve this, but don't have a working recipe just yet. Note that the parameters are present in the modules after executing read_verilog, as evidenced by the following yosys output:
|
After more digging, I found an open issue in yosys-slang that describes similar results to what I am seeing: Note that the proposed workaround involves always reading the library verilog and the user verilog with the same command. I'm not clear on whether that solution is workable for the VTR tests or not, @loglav03: thoughts? |
@petergrossmann21 I confirm read_slang won't see the parameters on modules loaded into Yosys with read_verilog. If you require to mix read_verilog and read_slang, the following workaround is available: First you load the modules as required with read_verilog. Second you load the user design with read_slang, at the same time you describe the pre-existing modules as blackboxes. E.g. for your dual_port_ram primitive you would add the following to the read_slang file list:
This way slang understands the parameters and their influence over port widths which is critical for correct elaboration. When involving blackboxes make sure to specify the top with |
One point which surprises me about your scripts is that you apply |
@loglav03 @vaughnbetz What are your thoughts about reducing the proposed workaround to practice? Are there any issues precluding doing as suggested in the synthesis scripts? |
The workaround seems fine to me. I'd just check the resource count and cpd results before and after the changes to ensure we haven't accidentally broken something. If the scripts are using an odd command or an order that doesn't always work we should change them. |
@petergrossmann21 It's worth a shot. I don't believe there's anything blocking us from trying this. I already attempted the workaround by adding the single_port and duel_port ram primitives described as blackboxes to a seperate file and added it in as an include file to be added to the file list along with the user verilog. This resulted in this: ERROR: Attempted to add new module named '\dual_port_ram', but a module by that name already exists |
@loglav03 The key part is that for slang the module is wrapped in
Alternatively it should have the |
The "module by that name already exists" error might have also been caused by leaving out |
@petergrossmann21 I just tried to run read_slang on both the vtr_primitives.v and ch_intrinsics.v (include file) and it gave me this error:
It looks like you previously has success with running
So I'm not sure why yours passed and mine didn't since it seems like yosys-slang doesn't currently support specify blocks. I ran my test through the synthesis.tcl script by running run_vtr_flow.py on my own benchmark directory with vtr_primitives.v and ch_intrinsics.v I think this means we need to only be calling read_verilog on vtr_primitives and will need to go down the workaround route that was proposed. I will continue trying things out and see if I can get something working. |
@povik @petergrossmann21 - I was able to get this working without throwing the "module by that name already exists" error and shows
However, I'm running into the same issue I was having above. These modules get read by read_slang and throw
I'm not experienced with verilog, so I'm not sure if there's a possible workaround with the specify blocks that won't break anything. |
Hi @loglav03 If you're getting this output:
I think you haven't specified the top with |
This is what I have set up in the tcl script:
The file that defines the single and dual port ram modules as blackboxes is included in the $readfile |
Got it. The module specified with --top should be the user design top. |
@povik Thank you for taking the time to help with this. @petergrossmann21 I managed to get the synthesis script set up in a way that passes verilog benchmarks that were previously failing with yosys-slang. When slang is enabled, it does this in the synthesis script where -DNO_SPECIFY is a macro that prevents slang from reading the specify blocks in vtr_primitives. So, with this macro, I was able to read the user design verilog along with vtr_primitives with the same read_slang command. This resulted in the benchmarks (listed below) passing. For the test I used, I made my own copy of the vtr_reg_nightly_test3/vtr_reg_qor with your fixed benchmarks substituted in for the old ones to test these benchmarks. It doesn't cover all of the ones you modified, but I would say the other ones would probably pass as well if we were to test them. I haven't checked the golden results with these yet so that's something I still have to do. Modified portion of synthesis.tcl:
Example of the guard on specify blocks:
Benchmarks that passed:
|
Update on the above workaroundThe benchmarks had passed through the entire flow but they are failing a large amount of golden results (if not all of them). So this method doesn't seem like its feasible, and we will need find another workaround. |
Can you provide details on the nature of the failure? Is this a QoR check or a functional check which is failing? |
Do I understand the screenshot correctly that the result is much smaller than expected? It looks like the design did not get read in correctly and got optimized out, or the wrong module is getting synthesized. |
You are correct these results are much smaller than expected. There's even some that are showing Single port ram:
Dual port ram:
It might also be because I don't have it reading the vtr_primitives correctly with the user design? I get this at the start of the output for yosys, and it looks like its reading it properly, but I'm not sure what the warning is for ch_intrinsics.v. Also vtr_primitives is being read by read_slang along with the user design in the same command, so I'm not sure if it would need an equivalent -lib. Maybe that could be a reason?
|
@loglav03 Based on this part in the output
I see you are still not setting the top. Please pass a |
So I ran this in the synthesis.tcl This passed through the entire yosys stage, but when it reached the VPR stage (packing, placing, routing) it threw this error:
Not sure what this means or how it can be fixed. @vaughnbetz @AlexandreSinger @povik - Any thoughts? |
This PR attempts to resolve errors and warnings encountered when running slang on the VTR benchmarks.
In broad strokes, there are three types of errors that were fixed:
reg
where needed because they are used in always blocks.Every attempt was made to make these edits minimally invasive, up to and including leaving odd whitespace intact along with any number of other syntax/style choices that would not normally be acceptable in professional-grade HDL code.
In addition to these changes, a redundant compiler directive was converted to a parameter in mkDelayWorker32B.v to attempt to preserve design intent. Depending upon exactly how yosys was processing the redundant directive, this may or may not change synthesis results for this benchmark.
Related Issue
This work supports #3169
Motivation and Context
The goal of this PR is to make the circuits slang-clean so they can be reliably used with that plugin in yosys.
How Has This Been Tested?
Initial testing has been done only running slang locally on each Verilog file and by obtaining the following result
Types of changes
Checklist: