-
Notifications
You must be signed in to change notification settings - Fork 415
Yosys+Odin #1798
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
Yosys+Odin #1798
Conversation
This is awesome. Thanks for working on this, Seyed. Liked and Subscribed :) |
@mithro would you please add |
I've added the |
ffc51c7
to
2b49e80
Compare
Looks like the basic sanitize tests are failing in the vpr router. Not sure why and whether it is related to this change or not. Presumably some memory corruption is occurring in the router, but that may be an underlying issue that some change in the benchmarks has triggered? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review so far (still working on it).
Generally looks good, but there are some places where:
- More high-level comments (file scope) on how things fit together would be useful.
- I think some long routines (e.g. FF) look fairly repetitive, so there's room for some refactoring and helper functions to reduce repeated code.
- The overview of this PR in the conversation tab is very good. I think that should be turned into a .md document and put in the Odin II source tree, or (probably even better) added to readthedocs (web page for vtr documentation) under an OdinII developer tab or some such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more suggestions.
Huge PR and a ton of work @sdamghan !
|
@tangxifan : I suspect the routing failures on the sanitized build are related to your recent rr-graph refactoring ... do you agree? Any ideas? |
Yes. I agree. I think some new APIs do not manage memory allocation well. I am on it now. Sorry for the issue. |
- Improving tehmap benchmark coverage Signed-off-by: Seyed Alireza Damghani <[email protected]>
- Improving techmap benchmark coverage - Regenerating expectation results signed-off-by: Seyed Alireza Damghani <[email protected]>
- regenerating expectation results Signed-off-by: Seyed Alireza Damghani <[email protected]>
- Updating benchmarks - improving techmap benchmark coverage - Regenerating expectated results Signed-off-by: Seyed Alireza Damghani <[email protected]>
- Adding support for $sdff sub-circuit signed-off-by: Seyed Alireza Damghani <[email protected]>
@QuantamHD - Can you take a look at this? |
@vaughnbetz I manually cancelled the job. You should be able to rerun by applying the |
Thanks @QuantamHD |
…enchmarks - regenerate expectation results of Odin/vtr Odin/full - regenerate vtr_reg_yosys_odin golden result Signed-off-by: Seyed Alireza Damghani <[email protected]>
@vaughnbetz modified benchmarks are merged into the VTR source tree, and duplicates are removed. Also, the include feature is now available for Yosys+Odin. I generated new QoR results and put them in a few tables in the PR description. Once @QuantamHD adds the new Kokoro runner for |
Merged in a golden result change to an unrelated regtest QoR change on the master. CI just kicked off again due to that. |
Hopefully that regtest passes within the QoR bounds; if not I'll try choosing the QoR data from this PR instead in the merge. It's the routing predictor off run, which tends to be noisy in cpu time. |
@vaughnbetz sounds good; please let me know if you would need further changes |
Committed an update to mcml's output count for vtr_reg_qor_chain_predictor_off's golden results. If this passes CI, will merge. |
Waiting for OdinII basic and Vtr nightly tests 2. (1 day so far -- hung?) |
@vaughnbetz Odin-II basic tests are already passed: It seems VTR nightly test 2 is hung; either we need to wait for it to meet the 72 hours timeout, or someone from the Google side could terminate it. |
Thanks @sdamghan . Merged. If you can watch/confirm that the Odin II basic test rename is all working fine in PRs that would be great; I'm assuming it showing up here is spurious and will go away after the merge. |
Thanks @vaughnbetz , I will definitely track the Odin-II CI tests |
Description
This PR adds the functionality of using Odin's technology mapping for a Yosys generated BLIF file in coarse grain format. Basically, the feature is added according to the following flow:
Yosys: A hardware design will be given to Yosys. Using the commands mentioned in synth.tcl script, Yosys generates a coarsen (not exploded into low-level logic) BLIF file. Technically, the generated BLIF file should have Yosys logic cells. such as $and, $logic_and, $add, $sub, $div, $pow, $mul, $mem and etc.
BLIF Reader: Odin-II is fed by the generated BLIF file as the main design. At this point, other options like architecture files can also be given to Odin-II as before.
BLIF Elaboration: The BLIF file will pass to the BLIF Elaboration phase, which basically, makes the netlist compatible with Odin-II's partial mapping. Worth noting to mention that some Yosys logic cells such as simple DFF or bitwise operations will be passed to the partial mapping phase intact. The first critical stage of the Yosys+Odin happens in the BLIF Elaboration phase since some logic cells like $pow, $div or $mul will be exploded into smaller components such as adders or shifters. Moreover, the block memories are being detected at this point; however, the hard-block mapping or memory-related optimization process will happen in the mid-phase between BLIF Elaboration and Partial mapping. The third phase for other logic cells, like logical nodes, will only include input/output ports reordering to make them compatible with the partial mapping structure.
3.1. Optimization: This phase includes some optimization and decision-making concerning Odin-II's logic cells mapping and the given architecture. For instance, memory blocks generated by Yosys will be split into smaller pieces. Basically, a memory block generated by Yosys, excluding hard blocks such as SPRAM or DPRAM, is a whole memory cell that includes all reading and writing ports. As a result, not only this memory cell needs to be split into memory nodes compatible with Odin-II's partial mapping and available hard blocks, but also a few potential optimizations such as memory size or port size reductions are available at this point. Generally, Odin-II categorizes Yosys memory blocks in two: Read-Only Memory (ROM) and Block Memory (BRAM). ROMs will be mapped to SPRAM or DPRAM based on the number of reading ports. BRAMs, are mostly mapped to DPRAMs. Only if the read and the write address are equal, the BRAM will be mapped to SPRAM. Another potential optimization for memories here is to check the memory depth and see if it can fit into LUTRAMs. Some thresholds have been set based on the 6-LUTs specifications in Stratix IV and later; however, the LUTRAM inference in this tool is not one of those complicated ones. In addition to memories, adders will be modified at this stage if available adder hard blocks exist in the architecture file. Indeed, an adder node will be split into a chain of single-bit adders. Modifications like adding carry ports happen here as well.
Partial mapping: The fourth phase slightly changed from what partial mapping was in Odin-II previously. In this phase, Odin-II would partially map the netlist to low-level logic. The second essential phase is happening here since the given circuit to Yosys would utilize the available hard blocks in the VTR flow. These hard blocks are comprising of the available hard blocks in the given architecture to the Odin-II. Worth noting here that the primitive modules specified in the vtr_flow directory are given to Yosys as a library. That means users can also use VTR primitive components such as
single_port_ram
,dual_port_ram
andadder
as before. (Note: the infrastructure for this feature is completely implemented in Yosys+Odin. However, there is an issue with Yosys in which it does not generate these hard blocks with the user-defined size in the design file. The issue is filed in the Yosys repository link. The temporary solution for this issue is to paste the definition of these modules in the given design from vtr_flow/primitive.v).Some notes worth mentioning:
_read
method, which is implemented based on the language structure. Currently, Odin-II only supports Verilog and BLIF as the input languages._write
method to write into output file based on the specified language.getline
method has been added tolibvtrutil
:getline
is defined in libvtrutil.getline
method is compatible with Windows and Linux new lines--fflegalize
is added to make all DFFs rising edge by adding inverters.Instruction to use:
The coarse-grain BLIF file and Yosys output log will be created in the same directory where the Odin-II output BLIF file is going to be placed
2.1. Generating Yosys BLIF file using
run_yosys.sh
script, located in "ODIN_II/regression_test/tools/"../run_yosys -V VERILOG_FILE
./run_yosys -t TASK.YCFG or TASKLIST
task.ycfg is like ordinary VTR task files; however, the user only needs to specify
circuit_dir
andcircuit_list_add
. In the end, this script creates a new directory with the task name at "/ODIN_II/regression_tests/benchmark/_BLIF/XXX" and puts all generated BLIF inside it.task.ycfg example:
include_circuits
option is not yet implemented in run_yosys.sh script.2.2. Odin-II can be fed by Yosys generated BLIF file using the following command:
Note: the other options, such as passing architecture files, Odin-II XML config files, etc., are the same.
###Changed or New Results
Due to the changes in VTR benchmarks, the golden results for some benchmarks need to be changed. You would find the comparison between the baseline (current VTR master branch) and the modified (recent changes) golden results in the following table:
Due to the changes in the ODIN_II/multiplier.cpp, the golden results for "nightly1/arithmetic_tasks/mult_const" benchmarks have changed. The comparison between the baseline (current VTR master branch) and the modified (recent changes) golden results in the following table:
Also, the comparison between the Yosys+Odin-II and Odin-II golden results for VTR benchmarks, based on the vtr_qor_reg_chain configuration is as follows:
Related Issue
#1830
#1831
Motivation and Context
Aim to use the Odin-II partial mapping stage, which performs hard logic inference and hard/soft trade-off decisions for such a tool as Yosys. The goal is to automate the decision between what to place in hard blocks or explode into gates. The current Yosys flow forces the user to decide the discrete circuit implementation manually. The approach taken by the synthesizer is to map all discrete components into an available hard block or to explode them when not available, not caring for the device capacity. Our goal is to improve device utilization and simplify the flow by automating this decision with architecture awareness.
How Has This Been Tested?
Odin-II and VTR benchmarks
Types of changes
Checklist: