Search code examples
yosys

Is it possible to remove clock input variable from the AIGER output?


Consider the example:

read_verilog ./tests/simple/fsm.v
synth -flatten -top fsm_test
abc -g AND
write_aiger -ascii -symbols hoho.aag

The resulting AIGER file contains input variable clk, which is dangling.
Is it possible to avoid introducing such clock input into AIGER?
Thanks.


Solution

  • Not automatically. The following options exist:

    1. Simply use the SystemVerilog $global_clock feature to avoid having a clock input at all. Use always @($global_clock) instead of always @(posedge clk) and then remove the clk input from your design.

    2. Remove the clock input near the end of your synthesis script. I.e. right before calling write_aiger call something like delete -input fsm_test/clk. This will turn the clock signal into a dangling wire internal to the module. You should avoid doing that before running a lot of optimization commands, or you risk Yosys optimizing away all your FFs. But doing that near the end of your script should be fine.

    3. You can combine 2. with mapping your FFs to $ff/$_FF_ cells (the kind of FF cells generated by $global_clock-blocks). The advantage of this approach is that it makes the clk wire truly unused, so there is no risk of optimizations messing with your FFs because they have an undriven clock input. I've now added a dff2ff.v techmap file in commit e7a984a that simplifies this a bit.

    Script for option 2:

    read_verilog ./tests/simple/fsm.v
    synth -flatten -top fsm_test
    abc -g AND
    delete -input fsm_test/clk
    write_aiger -ascii -symbols hoho.aag
    

    Script for option 3 (requires Yosys git commit e7a984a or later):

    read_verilog ./tests/simple/fsm.v
    hierarchy -top fsm_test
    proc
    techmap -map +/dff2ff.v
    delete fsm_test/clk
    synth -flatten 
    abc -g AND
    write_aiger -ascii -symbols hoho.aag