【问题标题】:Why is this MUX with const. inputs not optimised away?为什么这个 MUX 带有 const。输入没有优化?
【发布时间】:2017-02-16 18:29:26
【问题描述】:

这是Combinatorial synthesis: Better technology mapping results 的后续问题。

我正在使用带有以下合成脚本的 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 实例始终在生成的网表中。

【问题讨论】:

  • 我不是 Yosys 专家,但我认为您需要使用 flatten 命令。根据documentation还有很多优化(opt)命令

标签: optimization verilog synthesis constant-expression yosys


【解决方案1】:
  1. 如果您想跨层次边界进行优化,您需要运行flatten

  2. 您可能希望在运行techmap 之前不久运行opt -full,但在运行fsmshare 等高级优化之后。

  3. JFYI:如果您不提供运行测试用例所需的所有文件,人们将无法重现您所说的内容。我没有你的my_library.lib,所以我什至懒得尝试运行你的代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-18
    • 1970-01-01
    • 2013-09-11
    • 2016-06-22
    • 1970-01-01
    • 1970-01-01
    • 2015-06-06
    相关资源
    最近更新 更多