Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2013-2014 Spring
Hardware Description
Languages & Verilog HDL
21.04.2014
Hard to debug
2
1
Conventional Digital Design Steps
?
1. Determine inputs,
outputs and states
7. Implement using
discrete logic gate
ICs(74series)
4
2
FPGA
Field Programmable Gate Array
An IC that includes millions of programmable logic gates.
Can be programmed using :
- Schematic logic diagram
- Hardware description languages (VHDL, Verilog)
HDLs
3
The Purpose of HDLs
VHDL or Verilog?
4
Verilog Syntax
Abstraction Levels
Behavioral Level:
10
5
Gate Level Description
11
12
6
Verilog - Modules
13
14
7
Three-State Gates
15
16
8
Verilog Data Representation
1. Logic:
0 represent a logic 0 or false condition
1 represent a logic 1 or true condition
Z Output of an undriven tri-state driver High-Z value
x Models when un-initialized or unknown logic value
Initial state of registers
17
2. Number:
Ex: 8b1111_0000
8hF0
8d
Format: <size><base_format><number>
<size> - decimal specification of bits count
<base_format> - ' followed by arithmetic base of number
d or D decimal (default if no base
format given)
h or H hexadecimal
o or O octal
b or B binary
18
9
Gate Level Description - Example2
A B enable
D0
D1
D2
D3
19
and A1(and_out,A,B);
not N1(F,and_out);
endprimitive
10
Data Flow Level Description
Data flow modelling is used for describing the Boolean
equations of logic circuits.
The following operators are used to describe functions:
21
22
11
Data Flow Level Description - Example2
A B enable
D0
D1
D2
D3
23
24
12
Data Flow Level Description - Example4
1bit comparator
25
26
13
Behavioural Description &Always Blocks
always block executes always.
The @ symbol indicates that the block will be
triggered "at" the condition in parenthesis.
// C analogy:
while(1)
{
if(condition)
//Demonstrates the use of always block: do operation
module always_and_gate(Out,A,B); }
endmodule 27
28
14
Behavioral Description Example1
29
30
15
wire vs reg
wire reg
Represents a wire. Represents a register
Cannot store a value. (DFF).
Used for connection of Can store value.
blocks and/or registers. Use reg in sequential
Use wire in circuits.
combinational circuits.
31
Blocking vs Non-Blocking
Blocking Non-blocking
<variable> = <statement> <variable> <= <statement>
16
Blocking vs Non-Blocking
Initially assume:
A = 3; B = 5;
34
17
Behavioral Description Example4
Clock
35
36
18
Verilog Homework
1. Design a combinational circuit whose output is equal to one if the 4
bits input have more 1s than 0s and output should be zero if the
number of 0s are more than the number of 1s. If the number of 1s
are equal to the number of zeros (2 ones, 2 zeros) than the output
should be High-Z.
a. Design the circuit and write the logic function. (20p)
b. Write a module using the data flow description of the circuit. (use vector
representation for signals that are larger than 1 bit) (20p)
c. Write a module using the behavioral description of the circuit. (20p)
2. Using Verilogger simulator (You can download evaluation version from
http://www.megafileupload.com/en/file/521307/Verilogger-setup-rar.html or
http://speedy.sh/KfHKW/Verilogger-setup.rar or
http://www.fileswap.com/dl/gNDSK8MOCh );
a. Generate a test waveform that applies 4 bits input values of all
combinations(0000 to 1111).
b. Simulate the verilog codes you have written in part1(each of the data flow
and behavioral descriptions) using the test waveform. Plot the input/output
waveforms you obtained. (20p+20p) 37
References:
1. Digital Design, Mano and Kime, 4th edition.
2. IEEE Standard Description Language Based on the
Verilog(TM) Hardware Description Language.
3. Synopsys, FPGA Compiler II/FPGA Express: Verilog HDL
Reference Manual, Version 1999.05, May 1999.
4. Smith, D. R., and P. D. Franzon, Verilog Styles for Synthesis
of Digital Systems, Prentice Hall, 2000.
5. Ciletti, Michael D., Modeling, Synthesis, and Rapid
Prototyping with the Verilog DHL, Prentice Hall, 1999.
6. http://www.wikipedia.org/
Questions ? 38
19