2017-02-15 55 views
0

这是Combinatorial synthesis: Better technology mapping results的后续问题。为什么这个MUX与const。输入未被优化掉?

我使用Yosys(0.5+ (git sha1 f13e387, gcc 5.3.1-8ubuntu2 -O2 -fstack-protector-strong -fPIC -Os)版)以下的合成脚本:

read_liberty -lib my_library.lib 
read_verilog test.v 
hierarchy -check -top test 
proc; opt; memory; opt; fsm -norecode; opt 
techmap; opt 
dfflibmap -liberty my_library.lib 
abc -liberty my_library.lib -script \ 
    +strash;ifraig;scorr;dc2;dretime;strash;&get,-n;&dch,-f;&nf,{D};&put 
hilomap -hicell LIB_TIEHI Y -locell LIB_TIELO Y 
clean 
write_verilog -noattr -noexpr output.v 
stat 

...来合成以下Verilog代码(test.v):

module mux4(
    input i0, i1, i2, i3, 
    input s0, s1, 
    output z); 
    reg zint; 
    always @(*) begin 
    case ({s1, s0}) 
     2'b00: zint = i0; 
     2'b01: zint = i1; 
     2'b10: zint = i2; 
     2'b11: zint = i3; 
     default: zint = i3; 
    endcase 
    end 
    assign z = zint; 
endmodule 

module test (
    input a,b,c,d, 
    output result 
); 
    mux4 inst (
    .i0(a), .i1(b), .i2(c), .i3(d), 
    .s0(1'b0), .s1(1'b0),   # constants here! 
    .z(result) 
); 
endmodule 

的合成结果包括一个LIB_MUX4实例,其中S0S1均与两个LIB_TIELO实例相连。

为什么不Yosys看到S0S1是恒定的,并且输出减少这样的事情

module test(a, b, c, d, result); 
    input a; 
    input b; 
    input c; 
    input d; 
    output result; 
    assign result = a; 
endmodule 

呢?

我尝试使用clean -purgeopt_muxtreeopt_clean命令,但没有成功 - 静态LIB_MUX实例总是在产生的网络表。

+1

我不是Yosys的专家,但我认为你需要使用['flatten'](http://www.clifford.at/yosys/cmd_flatten.html)命令。根据[documentation](http://www.clifford.at/yosys/documentation.html),还有很多优化('opt')命令。 – Greg

回答

1
  1. 如果您希望跨层次边界进行优化,则需要运行flatten

  2. 你可能想运行不久以前techmap运行opt -full,但运行的高层次优化,例如fsmshare后。 JFYI:如果您没有提供运行测试用例所需的所有文件,用户将无法重现您正在谈论的内容。我没有你的my_library.lib,所以我甚至懒得试图运行你的代码。

相关问题