Skip to content

Commit 681b678

Browse files
committed
dfflibmap: cover enable inference with test
1 parent 5233636 commit 681b678

File tree

3 files changed

+51
-13
lines changed

3 files changed

+51
-13
lines changed

tests/techmap/dfflibmap-sim.v

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ always @(posedge CLK, posedge CLEAR, posedge PRESET)
2020
assign QN = ~Q;
2121

2222
endmodule
23+
24+
module dffe(input CLK, EN, D, output reg Q, output QN);
25+
26+
always @(negedge CLK)
27+
if (EN) Q <= D;
28+
29+
assign QN = ~Q;
30+
31+
endmodule

tests/techmap/dfflibmap.lib

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ library(test) {
55
ff("IQ", "IQN") {
66
next_state : "D";
77
clocked_on : "!CLK";
8-
}
8+
}
99
pin(D) {
1010
direction : input;
1111
}
@@ -19,7 +19,7 @@ library(test) {
1919
pin(QN) {
2020
direction: output;
2121
function : "IQN";
22-
}
22+
}
2323
}
2424
cell (dffsr) {
2525
area : 6;
@@ -30,7 +30,7 @@ library(test) {
3030
preset : "PRESET";
3131
clear_preset_var1 : L;
3232
clear_preset_var2 : L;
33-
}
33+
}
3434
pin(D) {
3535
direction : input;
3636
}
@@ -50,6 +50,30 @@ library(test) {
5050
pin(QN) {
5151
direction: output;
5252
function : "IQN";
53-
}
53+
}
54+
}
55+
cell (dffe) {
56+
area : 6;
57+
ff("IQ", "IQN") {
58+
next_state : "(D&EN) | (IQ&!EN)";
59+
clocked_on : "!CLK";
60+
}
61+
pin(D) {
62+
direction : input;
63+
}
64+
pin(EN) {
65+
direction : input;
66+
}
67+
pin(CLK) {
68+
direction : input;
69+
}
70+
pin(Q) {
71+
direction: output;
72+
function : "IQ";
73+
}
74+
pin(QN) {
75+
direction: output;
76+
function : "IQN";
77+
}
5478
}
5579
}

tests/techmap/dfflibmap.ys

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
read_verilog -icells <<EOT
22

3-
module top(input C, D, S, R, output [9:0] Q);
3+
module top(input C, D, E, S, R, output [11:0] Q);
44

55
$_DFF_P_ ff0 (.C(C), .D(D), .Q(Q[0]));
66
$_DFF_PP0_ ff1 (.C(C), .D(D), .R(R), .Q(Q[1]));
77
$_DFF_PP1_ ff2 (.C(C), .D(D), .R(R), .Q(Q[2]));
88
$_DFFSR_PPP_ ff3 (.C(C), .D(D), .R(R), .S(S), .Q(Q[3]));
99
$_DFFSR_NNN_ ff4 (.C(C), .D(D), .R(R), .S(S), .Q(Q[4]));
10+
$_DFFE_PP_ ff5 (.C(C), .D(D), .E(E), .Q(Q[5]));
1011

11-
assign Q[9:5] = ~Q[4:0];
12+
assign Q[11:6] = ~Q[5:0];
1213

1314
endmodule
1415

@@ -29,23 +30,25 @@ design -load orig
2930
dfflibmap -liberty dfflibmap.lib
3031
clean
3132

32-
select -assert-count 4 t:$_NOT_
33+
select -assert-count 5 t:$_NOT_
3334
select -assert-count 1 t:dffn
3435
select -assert-count 4 t:dffsr
35-
select -assert-none t:dffn t:dffsr t:$_NOT_ %% %n t:* %i
36+
select -assert-count 1 t:dffe
37+
select -assert-none t:dffn t:dffsr t:dffe t:$_NOT_ %% %n t:* %i
3638

3739
design -load orig
3840
dfflibmap -prepare -liberty dfflibmap.lib
3941

40-
select -assert-count 9 t:$_NOT_
42+
select -assert-count 11 t:$_NOT_
4143
select -assert-count 1 t:$_DFF_N_
4244
select -assert-count 4 t:$_DFFSR_PPP_
43-
select -assert-none t:$_DFF_N_ t:$_DFFSR_PPP_ t:$_NOT_ %% %n t:* %i
45+
select -assert-count 1 t:$_DFFE_NP_
46+
select -assert-none t:$_DFF_N_ t:$_DFFSR_PPP_ t:$_DFFE_NP_ t:$_NOT_ %% %n t:* %i
4447

4548
design -load orig
4649
dfflibmap -map-only -liberty dfflibmap.lib
4750

48-
select -assert-count 5 t:$_NOT_
51+
select -assert-count 6 t:$_NOT_
4952
select -assert-count 0 t:dffn
5053
select -assert-count 1 t:dffsr
5154

@@ -54,14 +57,16 @@ dfflibmap -prepare -liberty dfflibmap.lib
5457
dfflibmap -map-only -liberty dfflibmap.lib
5558
clean
5659

57-
select -assert-count 4 t:$_NOT_
60+
select -assert-count 5 t:$_NOT_
5861
select -assert-count 1 t:dffn
5962
select -assert-count 4 t:dffsr
60-
select -assert-none t:dffn t:dffsr t:$_NOT_ %% %n t:* %i
63+
select -assert-count 1 t:dffe
64+
select -assert-none t:dffn t:dffsr t:dffe t:$_NOT_ %% %n t:* %i
6165

6266
design -load orig
6367
dfflibmap -liberty dfflibmap.lib -dont_use *ffn
6468
clean
6569

6670
select -assert-count 0 t:dffn
6771
select -assert-count 5 t:dffsr
72+
select -assert-count 1 t:dffe

0 commit comments

Comments
 (0)