mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-18 21:25:47 +00:00
Merge branch 'main' into opt_addcin
This commit is contained in:
commit
5c3fbd2d63
11 changed files with 1505 additions and 8 deletions
116
tests/silimate/ffnormpol.ys
Normal file
116
tests/silimate/ffnormpol.ys
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
log -header "Normalize coarse and fine FF/latch polarities"
|
||||
log -push
|
||||
design -reset
|
||||
read_rtlil <<EOT
|
||||
module \top
|
||||
wire input 1 \clk
|
||||
wire input 2 \en
|
||||
wire input 3 \arst
|
||||
wire input 4 \srst
|
||||
wire input 5 \aload
|
||||
wire width 2 input 6 \set
|
||||
wire width 2 input 7 \clr
|
||||
wire width 2 input 8 \d
|
||||
wire width 2 input 9 \ad
|
||||
wire width 2 output 10 \q_dffe
|
||||
wire width 2 output 11 \q_adffe
|
||||
wire width 2 output 12 \q_sdffce
|
||||
wire width 2 output 13 \q_aldffe
|
||||
wire width 2 output 14 \q_dlatchsr
|
||||
wire width 2 output 15 \q_sr
|
||||
wire output 16 \q_fine
|
||||
|
||||
cell $dffe \dffe_neg
|
||||
parameter \CLK_POLARITY 1'0
|
||||
parameter \EN_POLARITY 1'0
|
||||
parameter \WIDTH 2
|
||||
connect \CLK \clk
|
||||
connect \EN \en
|
||||
connect \D \d
|
||||
connect \Q \q_dffe
|
||||
end
|
||||
|
||||
cell $adffe \adffe_neg
|
||||
parameter \CLK_POLARITY 1'0
|
||||
parameter \EN_POLARITY 1'0
|
||||
parameter \ARST_POLARITY 1'0
|
||||
parameter \ARST_VALUE 2'01
|
||||
parameter \WIDTH 2
|
||||
connect \CLK \clk
|
||||
connect \EN \en
|
||||
connect \ARST \arst
|
||||
connect \D \d
|
||||
connect \Q \q_adffe
|
||||
end
|
||||
|
||||
cell $sdffce \sdffce_neg
|
||||
parameter \CLK_POLARITY 1'0
|
||||
parameter \EN_POLARITY 1'0
|
||||
parameter \SRST_POLARITY 1'0
|
||||
parameter \SRST_VALUE 2'10
|
||||
parameter \WIDTH 2
|
||||
connect \CLK \clk
|
||||
connect \EN \en
|
||||
connect \SRST \srst
|
||||
connect \D \d
|
||||
connect \Q \q_sdffce
|
||||
end
|
||||
|
||||
cell $aldffe \aldffe_neg
|
||||
parameter \CLK_POLARITY 1'0
|
||||
parameter \EN_POLARITY 1'0
|
||||
parameter \ALOAD_POLARITY 1'0
|
||||
parameter \WIDTH 2
|
||||
connect \CLK \clk
|
||||
connect \EN \en
|
||||
connect \ALOAD \aload
|
||||
connect \D \d
|
||||
connect \AD \ad
|
||||
connect \Q \q_aldffe
|
||||
end
|
||||
|
||||
cell $dlatchsr \dlatchsr_neg
|
||||
parameter \EN_POLARITY 1'0
|
||||
parameter \SET_POLARITY 1'0
|
||||
parameter \CLR_POLARITY 1'0
|
||||
parameter \WIDTH 2
|
||||
connect \EN \aload
|
||||
connect \SET \set
|
||||
connect \CLR \clr
|
||||
connect \D \d
|
||||
connect \Q \q_dlatchsr
|
||||
end
|
||||
|
||||
cell $sr \sr_neg
|
||||
parameter \SET_POLARITY 1'0
|
||||
parameter \CLR_POLARITY 1'0
|
||||
parameter \WIDTH 2
|
||||
connect \SET \set
|
||||
connect \CLR \clr
|
||||
connect \Q \q_sr
|
||||
end
|
||||
|
||||
cell $_DFFE_NN_ \fine_dffe_neg
|
||||
connect \C \clk
|
||||
connect \E \en
|
||||
connect \D \d [0]
|
||||
connect \Q \q_fine
|
||||
end
|
||||
end
|
||||
EOT
|
||||
|
||||
ffnormpol
|
||||
check -assert
|
||||
|
||||
select -assert-count 0 r:CLK_POLARITY=0
|
||||
select -assert-count 0 r:EN_POLARITY=0
|
||||
select -assert-count 0 r:ARST_POLARITY=0
|
||||
select -assert-count 0 r:SRST_POLARITY=0
|
||||
select -assert-count 0 r:ALOAD_POLARITY=0
|
||||
select -assert-count 0 r:SET_POLARITY=0
|
||||
select -assert-count 0 r:CLR_POLARITY=0
|
||||
select -assert-count 1 t:$_DFFE_PP_
|
||||
select -assert-count 7 t:$not
|
||||
|
||||
design -reset
|
||||
log -pop
|
||||
188
tests/silimate/infer_icg.ys
Normal file
188
tests/silimate/infer_icg.ys
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
log -header "Infer $icg from latch-based clock gate with scan enable"
|
||||
log -push
|
||||
design -reset
|
||||
read_verilog -sv <<EOF
|
||||
module top(input logic CK, EN, SE, output logic Q);
|
||||
logic en_ff;
|
||||
logic enable;
|
||||
|
||||
assign enable = EN | SE;
|
||||
|
||||
always_latch
|
||||
if (!CK)
|
||||
en_ff = enable;
|
||||
|
||||
assign Q = CK & en_ff;
|
||||
endmodule
|
||||
EOF
|
||||
|
||||
hierarchy -auto-top
|
||||
proc
|
||||
opt
|
||||
select -assert-count 1 t:$dlatch
|
||||
select -assert-count 1 t:$and t:$logic_and
|
||||
select -assert-count 1 t:$or t:$logic_or
|
||||
select -assert-count 0 t:$icg
|
||||
|
||||
infer_icg
|
||||
clean
|
||||
check -assert
|
||||
|
||||
select -assert-count 1 t:$icg
|
||||
select -assert-count 0 t:$dlatch
|
||||
select -assert-count 0 t:$and t:$logic_and
|
||||
select -assert-count 0 t:$or t:$logic_or
|
||||
design -reset
|
||||
log -pop
|
||||
|
||||
log -header "Infer $icg from latch-based clock gate without scan enable"
|
||||
log -push
|
||||
design -reset
|
||||
read_verilog -sv <<EOF
|
||||
module top(input logic CK, EN, output logic Q);
|
||||
logic en_ff;
|
||||
|
||||
always_latch
|
||||
if (!CK)
|
||||
en_ff = EN;
|
||||
|
||||
assign Q = en_ff & CK;
|
||||
endmodule
|
||||
EOF
|
||||
|
||||
hierarchy -auto-top
|
||||
proc
|
||||
opt
|
||||
infer_icg
|
||||
clean
|
||||
check -assert
|
||||
|
||||
select -assert-count 1 t:$icg
|
||||
select -assert-count 0 t:$dlatch
|
||||
select -assert-count 0 t:$and t:$logic_and
|
||||
design -reset
|
||||
log -pop
|
||||
|
||||
log -header "Infer $icg from active-high latch on inverted clock"
|
||||
log -push
|
||||
design -reset
|
||||
read_verilog -sv <<EOF
|
||||
module top(input logic CK, EN, SE, output logic Q);
|
||||
logic en_ff;
|
||||
logic enable;
|
||||
logic nCK;
|
||||
|
||||
assign enable = EN | SE;
|
||||
assign nCK = !CK;
|
||||
|
||||
always_latch
|
||||
if (nCK)
|
||||
en_ff = enable;
|
||||
|
||||
assign Q = CK & en_ff;
|
||||
endmodule
|
||||
EOF
|
||||
|
||||
hierarchy -auto-top
|
||||
proc
|
||||
opt
|
||||
infer_icg
|
||||
clean
|
||||
check -assert
|
||||
|
||||
select -assert-count 1 t:$icg
|
||||
select -assert-count 0 t:$dlatch
|
||||
select -assert-count 0 t:$and t:$logic_and
|
||||
select -assert-count 0 t:$or t:$logic_or
|
||||
design -reset
|
||||
log -pop
|
||||
|
||||
log -header "Infer $icg from active-high latch on inverted clock without scan enable"
|
||||
log -push
|
||||
design -reset
|
||||
read_verilog -sv <<EOF
|
||||
module top(input logic CK, EN, output logic Q);
|
||||
logic en_ff;
|
||||
logic nCK;
|
||||
|
||||
assign nCK = !CK;
|
||||
|
||||
always_latch
|
||||
if (nCK)
|
||||
en_ff = EN;
|
||||
|
||||
assign Q = CK & en_ff;
|
||||
endmodule
|
||||
EOF
|
||||
|
||||
hierarchy -auto-top
|
||||
proc
|
||||
opt
|
||||
infer_icg
|
||||
clean
|
||||
check -assert
|
||||
|
||||
select -assert-count 1 t:$icg
|
||||
select -assert-count 0 t:$dlatch
|
||||
select -assert-count 0 t:$and t:$logic_and
|
||||
design -reset
|
||||
log -pop
|
||||
|
||||
log -header "Infer $icg from high-idle OR clock gate"
|
||||
log -push
|
||||
design -reset
|
||||
read_verilog -sv <<EOF
|
||||
module top(input logic CK, EN, SE, output logic Q);
|
||||
logic en_ff;
|
||||
logic enable;
|
||||
|
||||
assign enable = EN | SE;
|
||||
|
||||
always_latch
|
||||
if (CK)
|
||||
en_ff = enable;
|
||||
|
||||
assign Q = CK | !en_ff;
|
||||
endmodule
|
||||
EOF
|
||||
|
||||
hierarchy -auto-top
|
||||
proc
|
||||
opt
|
||||
infer_icg
|
||||
clean
|
||||
check -assert
|
||||
|
||||
select -assert-count 1 t:$icg
|
||||
select -assert-count 0 t:$dlatch
|
||||
select -assert-count 0 t:$or t:$logic_or
|
||||
design -reset
|
||||
log -pop
|
||||
|
||||
log -header "Infer $icg from high-idle OR clock gate without scan enable"
|
||||
log -push
|
||||
design -reset
|
||||
read_verilog -sv <<EOF
|
||||
module top(input logic CK, EN, output logic Q);
|
||||
logic en_ff;
|
||||
|
||||
always_latch
|
||||
if (CK)
|
||||
en_ff = EN;
|
||||
|
||||
assign Q = CK | !en_ff;
|
||||
endmodule
|
||||
EOF
|
||||
|
||||
hierarchy -auto-top
|
||||
proc
|
||||
opt
|
||||
infer_icg
|
||||
clean
|
||||
check -assert
|
||||
|
||||
select -assert-count 1 t:$icg
|
||||
select -assert-count 0 t:$dlatch
|
||||
select -assert-count 0 t:$or t:$logic_or
|
||||
design -reset
|
||||
log -pop
|
||||
117
tests/various/opt_andor_pmux.v
Normal file
117
tests/various/opt_andor_pmux.v
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
module andor_pmux_basic (
|
||||
input [2:0] sel,
|
||||
input [5:0] d,
|
||||
input a,
|
||||
output [1:0] y
|
||||
);
|
||||
assign y = ({2{sel == 3'd1}} & d[1:0]) |
|
||||
({2{sel == 3'd3}} & {d[2] & a, d[3]}) |
|
||||
({2{sel == 3'd6}} & 2'b01);
|
||||
endmodule
|
||||
|
||||
module andor_pmux_outer_enable (
|
||||
input [2:0] sel,
|
||||
input [3:0] d,
|
||||
input en,
|
||||
output [1:0] y
|
||||
);
|
||||
wire [1:0] body;
|
||||
|
||||
assign body = ({2{sel == 3'd2}} & {1'b0, d[0]}) |
|
||||
({2{sel == 3'd5}} & {d[1], d[2]}) |
|
||||
({2{sel == 3'd7}} & {d[3], 1'b1});
|
||||
assign y = {2{en}} & body;
|
||||
endmodule
|
||||
|
||||
module andor_pmux_duplicate (
|
||||
input [1:0] sel,
|
||||
input a,
|
||||
input b,
|
||||
input c,
|
||||
input d,
|
||||
input e,
|
||||
input f,
|
||||
output [1:0] y
|
||||
);
|
||||
assign y = ({2{sel == 2'd1}} & {a, b}) |
|
||||
({2{sel == 2'd1}} & {c, d}) |
|
||||
({2{sel == 2'd2}} & {e, f});
|
||||
endmodule
|
||||
|
||||
module andor_pmux_mixed_select_negative (
|
||||
input [1:0] sel_a,
|
||||
input [1:0] sel_b,
|
||||
input a,
|
||||
input b,
|
||||
output y
|
||||
);
|
||||
assign y = ((sel_a == 2'd1) & a) |
|
||||
((sel_b == 2'd2) & b);
|
||||
endmodule
|
||||
|
||||
module andor_pmux_wide_decode (
|
||||
input [3:0] sel,
|
||||
input [23:0] d,
|
||||
input q,
|
||||
output [3:0] y
|
||||
);
|
||||
assign y = ({4{sel == 4'd1}} & d[3:0]) |
|
||||
({4{sel == 4'd4}} & {d[4] & q, d[5], 1'b0, d[6]}) |
|
||||
({4{sel == 4'd7}} & d[10:7]) |
|
||||
({4{sel == 4'd9}} & {1'b1, d[11], d[12] & q, d[13]}) |
|
||||
({4{sel == 4'd12}} & d[17:14]) |
|
||||
({4{sel == 4'd15}} & {d[18], d[19], d[20], 1'b1});
|
||||
endmodule
|
||||
|
||||
module andor_pmux_shared_subtree (
|
||||
input [2:0] sel,
|
||||
input [3:0] d,
|
||||
input q,
|
||||
output y,
|
||||
output z
|
||||
);
|
||||
wire sub = ((sel == 3'd1) & d[0]) |
|
||||
((sel == 3'd3) & d[1]);
|
||||
|
||||
assign y = sub | ((sel == 3'd6) & d[2]);
|
||||
assign z = sub & q;
|
||||
endmodule
|
||||
|
||||
module andor_pmux_single_arm_negative (
|
||||
input [1:0] sel,
|
||||
input [1:0] d,
|
||||
output [1:0] y
|
||||
);
|
||||
assign y = ({2{sel == 2'd1}} & d) | 2'b00;
|
||||
endmodule
|
||||
|
||||
module andor_pmux_all_zero_negative (
|
||||
input [1:0] sel,
|
||||
output [1:0] y
|
||||
);
|
||||
assign y = ({2{sel == 2'd1}} & 2'b00) |
|
||||
({2{sel == 2'd2}} & 2'b00);
|
||||
endmodule
|
||||
|
||||
module andor_pmux_non_eq_leaf_negative (
|
||||
input [1:0] sel,
|
||||
input raw,
|
||||
input a,
|
||||
input b,
|
||||
output y
|
||||
);
|
||||
assign y = ((sel == 2'd1) & a) |
|
||||
(raw & b);
|
||||
endmodule
|
||||
|
||||
module andor_pmux_duplicate_complex (
|
||||
input [2:0] sel,
|
||||
input [8:0] d,
|
||||
input q,
|
||||
input r,
|
||||
output [2:0] y
|
||||
);
|
||||
assign y = ({3{sel == 3'd2}} & {d[0] & q, d[1], d[2]}) |
|
||||
({3{sel == 3'd2}} & {d[3], d[4] & r, d[5]}) |
|
||||
({3{sel == 3'd5}} & {d[6], d[7] & q, d[8] & r});
|
||||
endmodule
|
||||
152
tests/various/opt_andor_pmux.ys
Normal file
152
tests/various/opt_andor_pmux.ys
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
read_verilog opt_andor_pmux.v
|
||||
design -save read
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_basic
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 1 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_wide_decode
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 1 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_shared_subtree
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 1 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_single_arm_negative
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 0 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_all_zero_negative
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 0 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_non_eq_leaf_negative
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 0 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_duplicate_complex
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 1 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_outer_enable
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 1 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_duplicate
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 1 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top andor_pmux_mixed_select_negative
|
||||
proc
|
||||
opt_expr
|
||||
opt_clean
|
||||
design -save gold
|
||||
opt_andor_pmux
|
||||
opt_clean
|
||||
select -assert-count 0 t:$pmux
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports miter
|
||||
Loading…
Add table
Add a link
Reference in a new issue