组合合成:更好的技术映射结果



使用以下脚本,我正在合成一个标准细胞库,我有一个库文件my_library.lib:

read_liberty -lib  my_library.lib
script yosys_readfiles.ys
proc; opt; memory; opt; fsm -norecode; opt
techmap; opt
dfflibmap -liberty my_library.lib
abc -liberty my_library.lib
hilomap -hicell LIB_TIEHI Y -locell LIB_TIELO Y
clean
write_verilog -noattr -noexpr output.v
stat

虽然这通常是有效的,但我发现有些逻辑没有有效地映射。例如,我有以下4路多路复用器的Verilog模型:

module mux4(
input  i0,
input  i1,
input  i2,
input  i3,
input  s0,
input  s1,
output z
);
reg    zint;
parameter tdelay = `default_gate_delay;
always @(i0 or i1 or i2 or i3 or s0 or s1) 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

Yosys将其综合为以下门级网表:

/* Generated by Yosys 0.5+ (git sha1 f13e387, gcc 5.3.1-8ubuntu2 -O2 -fstack-protector-strong -fPIC -Os) */
module mux4(i0, i1, i2, i3, s0, s1, z);
wire _00_;
wire _01_;
wire _02_;
wire _03_;
wire _04_;
wire _05_;
input i0;
input i1;
input i2;
input i3;
input s0;
input s1;
output z;
wire zint;
NAND3 _06_ (
.A(s1),
.B(s0),
.C(i3),
.Y(_04_)
);
INV _07_ (
.A(s1),
.Y(_05_)
);
NAND3 _08_ (
.A(_05_),
.B(s0),
.C(i1),
.Y(_00_)
);
INV _09_ (
.A(s0),
.Y(_01_)
);
NAND3 _10_ (
.A(_05_),
.B(_01_),
.C(i0),
.Y(_02_)
);
NAND3B _11_ (
.AN(s0),
.B(s1),
.C(i2),
.Y(_03_)
);
NAND4 _12_ (
.A(_02_),
.B(_00_),
.C(_03_),
.D(_04_),
.Y(z)
);
assign zint = z;
endmodule

由于我正在使用的库已经有一个MXI4单元格,所以我希望能得到类似于以下内容的内容:

module mux4(i0, i1, i2, i3, s0, s1, z);
input i0;
input i1;
input i2;
input i3;
input s0;
input s1;
output z;
MXI4 _12_ (
.A(i0),
.B(i1),
.C(i2),
.D(i3),
.S0(s0),
.S1(s1),
.Y(z)
);
endmodule

我想知道如何指导Yosys使用MXI4单元,而不是上面的级联NAND实例,因为这将导致面积的显著减少。对于这个特定的单元格,我可以使用与本答案中描述的相同的技术手动映射到MXI4单元格,但我担心在我的设计中可能还有其他(更复杂的)领域,这种手动映射要么不明显,要么不可行。

我尝试过的一件事是在我的合成脚本中的abc命令中添加以下选项,我在Reddit上找到了这个选项:

-script +strash;scorr;ifraig;retime,{D};strash;dch,-f;map,-M,1,{D}

但它也没有解决问题。(此外,我找不到关于这些ABC命令的任何文档,如果有任何帮助,我们也将不胜感激。)

以下ABC脚本应该能够映射MUX4,或者至少在使用与Yosys 0.7捆绑的ABC版本时是这样:

abc -liberty my_library.lib -script 
+strash;ifraig;scorr;dc2;dretime;strash;&get,-n;&dch,-f;&nf,{D};&put

从gitcommit8927e19开始,这是abc -liberty的新默认脚本。

最新更新