使用以下脚本,我正在合成一个标准单元库,我有一个 lib 文件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
单元格,但我担心我的设计中可能还有其他(更复杂的)区域,这样的手动映射要么不是明显和/或不可行。
我尝试的一件事是将以下选项添加到我在 Reddit 上找到的abc
综合脚本中的命令中:
-script +strash;scorr;ifraig;retime,{D};strash;dch,-f;map,-M,1,{D}
但它也没有解决问题。(我也找不到关于其中一些 ABC 命令的任何文档,任何帮助也将不胜感激。)