Professional Documents
Culture Documents
2006-SNUG-Boston Standard Gotchas Presentation PDF
2006-SNUG-Boston Standard Gotchas Presentation PDF
What is a gotcha?
Why do standards have gotchas?
Summary
2 of 20
Don Mills, Microchip
Stu Sutherland
What Is A Gotcha? Sutherland
HD
training engineers
L
to be SystemVerilog Wizards
5 of 20
Don Mills, Microchip
Stu Sutherland
Whats In This Paper Sutherland
HD
training engineers
L
to be SystemVerilog Wizards
always @(state)
case (state)
00: // do State 0 stuff
01: // do State 1 stuff
10: // do State 2 stuff
Gotcha!
11: // do State 3 stuff
endcase
Hint:
Hint: There
There are
are 10
10 types
types of
of people
people in
in the
the world
world
those
those that
that know
know binary,
binary, and
and those
those that
that dont!
dont!
To avoid this Gotcha
Use unique case to detect the error
Use based numbers to fix the problem (e.g 2b10) 8 of 20
Don Mills, Microchip
Gotcha: Literal Numbers Are Stu Sutherland
Sutherland
Zero-extended to Their Size training engineers HD
L
to be SystemVerilog Wizards
If the size does not match the number of bits in the value:
If the left-most bit of value is 0 or 1, the value is left-extended with 0
If the left-most bit of value is Z, the value is left-extended with Z
If the left-most bit of value is X, the value is left-extended with X
Buta signed value is not sign-extended!
8hA unsigned value extends to 00001010 8shA is
8shA is not
not sign-extended
sign-extended
8shA signed value extends to 00001010 because
because the
the sign
sign bit
bit is
is the
the
MSB
MSB of
of the
the size,
size, not
not the
the
Gotcha! MSB
MSB ofof the
the value!
value!
To avoid this Gotcha
Engineers need to learn Verilogs sign extension rules! 9 of 20
Don Mills, Microchip
Gotcha: Importing Enumerated Stu Sutherland
Sutherland
Types from Packages training engineers HD
L
to be SystemVerilog Wizards
If State is
If State WAITE, adding
is WAITE, adding 11 results
results in nState having
in nState having 3b010
3b010 (the
(the value
value of
of LOAD)
LOAD)
If State is LOAD, adding 1 results in nState having 3b011 (not in the enumerated list!)
If State is WAITE, adding 1 results in nState having 3b101 (not in the enumerated list!)
At start of simulation, State and nState have 3bxxx (not in the enumerated list!)
Module
Module chip
chip can
can use RESET, but
use RESET, RESET is
but RESET is not
not defined
defined in
in chip
chip
Gotcha!
||
|| is
is the
the logical-OR
logical-OR operator;
operator; If
If aa is
is 1,
1, and
and bb changes
changes
always @(a || b)
Sensitive
Sensitive toto changes
changes on
on the
the result
result of
of from
from 00 to
to 1,
1, the
the block
block
sum = a + b;
the test is true, OR is true
the test is a true, OR is b true
a b will not
will not trigger
trigger
stuart@sutherland.com don.mills@microchip.com
20 of 20