3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-13 04:28:18 +00:00

Fix the truth table for $_SR_* cells.

This brings the documented behavior for these cells in line with
$_DFFSR_* and $_DLATCHSR_*, which is that R has priority over S.
The models were already reflecting that behavior.

Also get rid of sim-synth mismatch in the models while we're at it.
This commit is contained in:
Marcelina Kościelnicka 2020-04-11 16:03:19 +02:00
parent 7ad8b24280
commit 53ba3cf718
3 changed files with 21 additions and 26 deletions

View file

@ -8,15 +8,14 @@ TEMPLATES = [
//- //-
//- Truth table: S R | Q //- Truth table: S R | Q
//- -----+--- //- -----+---
//- {S:0|1} {R:0|1} | x //- - {R:0|1} | 0
//- {S:0|1} {R:1|0} | 1 //- {S:0|1} - | 1
//- {S:1|0} {R:0|1} | 0 //- - - | q
//- {S:1|0} {R:1|0} | y
//- //-
module \$_SR_{S:N|P}{R:N|P}_ (S, R, Q); module \$_SR_{S:N|P}{R:N|P}_ (S, R, Q);
input S, R; input S, R;
output reg Q; output reg Q;
always @({S:neg|pos}edge S, {R:neg|pos}edge R) begin always @* begin
if (R == {R:0|1}) if (R == {R:0|1})
Q <= 0; Q <= 0;
else if (S == {S:0|1}) else if (S == {S:0|1})

View file

@ -469,15 +469,14 @@ endmodule
//- //-
//- Truth table: S R | Q //- Truth table: S R | Q
//- -----+--- //- -----+---
//- 0 0 | x //- - 0 | 0
//- 0 1 | 1 //- 0 - | 1
//- 1 0 | 0 //- - - | q
//- 1 1 | y
//- //-
module \$_SR_NN_ (S, R, Q); module \$_SR_NN_ (S, R, Q);
input S, R; input S, R;
output reg Q; output reg Q;
always @(negedge S, negedge R) begin always @* begin
if (R == 0) if (R == 0)
Q <= 0; Q <= 0;
else if (S == 0) else if (S == 0)
@ -493,15 +492,14 @@ endmodule
//- //-
//- Truth table: S R | Q //- Truth table: S R | Q
//- -----+--- //- -----+---
//- 0 1 | x //- - 1 | 0
//- 0 0 | 1 //- 0 - | 1
//- 1 1 | 0 //- - - | q
//- 1 0 | y
//- //-
module \$_SR_NP_ (S, R, Q); module \$_SR_NP_ (S, R, Q);
input S, R; input S, R;
output reg Q; output reg Q;
always @(negedge S, posedge R) begin always @* begin
if (R == 1) if (R == 1)
Q <= 0; Q <= 0;
else if (S == 0) else if (S == 0)
@ -517,15 +515,14 @@ endmodule
//- //-
//- Truth table: S R | Q //- Truth table: S R | Q
//- -----+--- //- -----+---
//- 1 0 | x //- - 0 | 0
//- 1 1 | 1 //- 1 - | 1
//- 0 0 | 0 //- - - | q
//- 0 1 | y
//- //-
module \$_SR_PN_ (S, R, Q); module \$_SR_PN_ (S, R, Q);
input S, R; input S, R;
output reg Q; output reg Q;
always @(posedge S, negedge R) begin always @* begin
if (R == 0) if (R == 0)
Q <= 0; Q <= 0;
else if (S == 1) else if (S == 1)
@ -541,15 +538,14 @@ endmodule
//- //-
//- Truth table: S R | Q //- Truth table: S R | Q
//- -----+--- //- -----+---
//- 1 1 | x //- - 1 | 0
//- 1 0 | 1 //- 1 - | 1
//- 0 1 | 0 //- - - | q
//- 0 0 | y
//- //-
module \$_SR_PP_ (S, R, Q); module \$_SR_PP_ (S, R, Q);
input S, R; input S, R;
output reg Q; output reg Q;
always @(posedge S, posedge R) begin always @* begin
if (R == 1) if (R == 1)
Q <= 0; Q <= 0;
else if (S == 1) else if (S == 1)

View file

@ -1633,7 +1633,7 @@ wire [WIDTH-1:0] pos_clr = CLR_POLARITY ? CLR : ~CLR;
genvar i; genvar i;
generate generate
for (i = 0; i < WIDTH; i = i+1) begin:bitslices for (i = 0; i < WIDTH; i = i+1) begin:bitslices
always @(posedge pos_set[i], posedge pos_clr[i]) always @*
if (pos_clr[i]) if (pos_clr[i])
Q[i] <= 0; Q[i] <= 0;
else if (pos_set[i]) else if (pos_set[i])