CSE372 Digital Systems Organization & Design Lab by Prof. Milo Martin Unit 1 - Synthesizeable Verilog
CSE372 Digital Systems Organization & Design Lab by Prof. Milo Martin Unit 1 - Synthesizeable Verilog
CSE372
Digital Systems Organization and Design
Lab
Prof. Milo Martin
Verilog HDL
Verilog
HDL History
1980s:
Verilog first introduced
Verilog inspired by the C programming language
VHDL standardized
1990s:
Verilog standardized (Verilog-1995 standard)
2000s:
Continued evolution (Verilog-2001 standard)
Synthesis vs Simulation
S
Out
Sequential Logic
Gate-level
Interface specification
Declarations
Internal wires, i.e., local variables
Wires also known as nets or signals
wire S_, AnS_, BnS;
10
12
mux2to1
mux2to1
mux2to1
mux2to1
endmodule
13
mux0
mux1
mux2
mux3
A[0],
A[1],
A[2],
A[3],
B[0],
B[1],
B[2],
B[3],
O[0]);
O[1]);
O[2]);
O[3]);
Connections by Name
Vectors of Wires
Wire vectors:
14
Operations
(Sel,
(Sel,
(Sel,
(Sel,
16
Operators
On vectors:
&, |, ~, ^ (bit-wise operation on all wires in vector)
E.g., assign vec1 = vec2 & vec3;
&, |, ^ (reduction on the vector)
E.g., assign wire1 = | vec1;
Even ==, != (comparisons) +, -, * (arithmetic), <<, >> (shifts)
But you cant use these, yet. Can you guess why?
Note: use with care, assume unsigned numbers
Verilog 2001: signed vs unsigned vectors, >>> operator
17
Conditional Operator
Miscellaneous
18
Examples:
assign out = S ? B : A;
==
==
==
==
2'b00
2'b01
2'b10
2'b11
?
?
?
?
a
b
c
d
:
:
:
: 1'b0;
Constants:
19
assign x = 3b011
The 3 is the number of bits
The b means binary - h for hex, d for decimal
The 011 are the digits (in binary in this case)
20
Arrays of Modules
Parameters
21
Verilog Pre-Processor
22
Parameter vs `define
Parameter only for per instance constants
`define for global constants
CSE 372 (Martin): Synthesizable Verilog
23
24
Common Errors
Common errors:
By J. Bhasker, 1998
To the point (<200 pages)
26
CSE372
Digital Systems Organization and Design
Lab
Prof. Milo Martin
Ten operations:
Addition, subtraction
Multiplication
And, or, not, xor
Shift left, logical shift right, arithmetic shift right
27
28
Goals:
Normal points
Honors points
Will distinguish the A- from A and A+
May bump others a third of a letter grade
29
Repeated Signals
0, 1
X: dont know, dont care
Z: high-impedance (no current flowing)
// 16 copies of x
Uses for x
Tells synthesis tool you dont care
Synthesis tool makes the most convenient circuit (fast, small)
Use with care, leads to synthesis dependent operation
Uses for z
Tri-state devices drive a zero, one, or nothing (z)
Many tri-states drive the same wire, all but one must be z
Makes some circuits very fast
Example: multiplexer
Why Verilog allows multiple assignments to same wire.
30
31
32
Simulation
Levels of Simulation
33
34
35
Current
State
Combinational
Logic
Output
Next State
36
Clocks Signals
Clocks signals are not normal signals
Travel on dedicated clock wires
Reach all parts of the chip
Special low-skew routing
Ramifications:
Never do logic operations on the clocks
If you want to add a write enable to a flip-flop:
Use a mux to route the old value back into it
Do not just and the write-enable signal with the clock!
37