Snug12 Slides Final
Snug12 Slides Final
Discussion Topics
Don Mills
A little history
Past papers provide details on these topics
Clifford Cummings, full_case parallel_case, the Evil Twins of Verilog
Synthesis
Clifford Cummings, SystemVerilogs priority & uniqueA Solution to
Verilogs full_case & parallel_case Evil Twins!
Stuart Sutherland, SystemVerilog Saves the Daythe Evil Twins are
Defeated! unique and priority are the new Heroes
Don Mills and Clifford Cummings, "RTL Coding Styles That Yield
Simulation and Synthesis Mismatches
Stuart Sutherland and Don Mills, Standard Gotchas, Subtleties in the
Verilog and SystemVerilog Standards That Every Engineer Should
Know
Shalom Bresticker, Just When You Thought it Was Safe to Start Coding
AgainReturn of the SystemVerilog Gotchas
Don Mills, Being Assertive With Your X
3
Don Mills
Discussion Topics
Don Mills
Case items
always_comb begin
case (sel)
2'b00 : out
2'b01 : out
2'b10 : out
2'b11 : out
default : out
endcase
end
=
=
=
=
=
a;
b;
c;
d;
'X;
BORING
Don Mills
Case statement
always_comb begin
case (sel)
2'b00 : out = a;
2'b01 : out = b;
2'b10 : out = c;
endcase
end
always_comb begin
case (sel)
2'b00 : out
2'b01 : out
2'b10 : out
2b11 : out
endcase
end
=
=
=
=
a;
b;
c;
d;
Don Mills
always_comb begin
case (sel)
2'b00 : out
2'b01 : out
2'b10 : out
2'b11 : out
default : out
endcase
end
=
=
=
=
=
a;
b;
c;
d;
'X;
Don Mills
sel
0
1
X
a
dead
dead
dead
b
beef
beef
beef
OR
always_comb
out = sel ? a : b;
out
dead
beef
beef
sel
0
1
X
a
dead
dead
dead
b
beef
beef
beef
out
dead
beef
xexx
dead
dead
dead
Don Mills
casex X or Z or ? (another
symbol for Z) are dont cares in
case items or case expression
Don Mills
Don Mills
Don Mills
Discussion Topics
12
Don Mills
Synthesis Directives
Lots of papers on directives and SV
enhancements
full_case
parallel_case
Often represented the code differently in
synthesis than in simulation
Should only be used with inverse case
statement type coding
Note:
13
Don Mills
and synthesis
Provides simulation warnings of possible latch type
code
Unfortunately does not issue warning for all latch
conditions
14
Don Mills
always_comb begin
unique case (sel)
2'b00 : begin out1
out2
end
2'b01 : out2 = b;
2'b10 : out1 = c;
default : begin out1
out2
end
endcase
end
15
Don Mills
= a1;
= a2;
= a1;
= a2;
always_comb begin
out1 = a1;
out2 = a2;
unique case (sel)
2'b00 : begin out1 = a1;
out2 = a2;
end
2'b01 : out2 = b;
2'b10 : out1 = c;
endcase
end
Don Mills
= a1;
= a2;
= a1;
= b;
always_comb begin
out1 = a1;
out2 = a2;
case (sel)
2'b01 : out2 = b;
2'b10 : out1 = c;
endcase
end
= c;
= a2;
= a1;
= a2;
Don Mills
always_comb begin
out1 = a1;
out2 = a2;
unique0 case (sel)
2'b01 : out2 = b;
2'b10 : out1 = c;
endcase
end
Don Mills
Discussion Topics
19
Don Mills
YES
Asynchronous Set/Reset Flip-Flops manage
IC fuses for chip configuration
Google search microprocessor fuses
20
Don Mills
posedge clk
or negedge rst_n
or negedge set_n
);
if
(!rst_n) q <= '0;
else if (!set_n) q <= '1;
else
q <= d;
0
10
clk
rst_n
set_n
d
q
16hDEAD
X
16h0000
16hDEAD
16h0000
16hDEAD
?
21
Don Mills
posedge clk
or negedge rst_n
or negedge set_n
NOTE: rst_n has
priority over set_n
`ifndef SYNTHESIS
or posedge (rst_n & ~set_n)
`endif
);
This code will
if
(!rst_n) q <= '0;
simulate and
else if (!set_n) q <= '1;
synthesize correctly
else
q <= d;
0
10
clk
rst_n
set_n
d
q
22
16hBA5E
X
16h0000
16hBA5E
16h0000
16hFFFF
16hBA5E
Don Mills
Discussion Topics
23
Don Mills
variable declaration
IEEE 1800-2009
logic and bit define a value set:
4 state or 2 state
Don Mills
a,
logic b,
c,
Currently, presto
inout
still reads by the
inout wire
1800-2005 rules:inout tri
logic by itself inout
logic
implied var logic
output
output
25
d,
e,
f,
g,
h,
logic k);
Why do I care??
Variables may only have a
single source.
Variable inputs may limit
simulation optimization.
Possibly an issue for large
designs
Don Mills
26
a,
logic b,
logic c,
inout
inout wire
inout tri
inout
logic
output
output
d,
e,
f,
g,
//infers
//infers
//infers
//infers
wire
wire
wire
wire
h,
logic k);
Don Mills
logic
logic
logic
logic
a,
logic b,
logic c,
inout
inout wire
inout tri
logic
inout
output
output
27
d,
e,
f,
g,
Don Mills
Personal preferences
Option 1 (Cliff Cummings - reviewer)
Use logic everywhere
except when a signal is multi-driven, then use wire
Don Mills
Conclusion
casez, casex, case inside
Use immediate assertion with casex or case inside
Don Mills