EE-307 Fpga Based System Design: Lecture # 03
EE-307 Fpga Based System Design: Lecture # 03
EE-307 Fpga Based System Design: Lecture # 03
Verilog
Combinational Logic in Verilog
Lecture # 03
2 Verilog Basics
Today’s Lecture
Modules in Verilog
Instantiating a Module
Gate Level Modeling in Verilog
Verilog
4
HW or SW ?
Verilog --- Programming language ?
Verilog
HW Description
In H/W Everything is always active
Creates your Datapath/Circuit
Its simulation is Event Based
The synthesis tool understands only a subset of
Verilog, the part of Verilog called ‘RTL Verilog’
Is Verilog Simulation event based
?
Others
Integer, Real, Time, Arrays, Strings, Parameters
Examples
wire [low# : high#] or wire [high# : low#]
The first # defines the MSB
Example
Wire [2:0] a = 3’b001; // Bit 2 is the MSB (Use This)
Wire [0:2] a = 3’b001; // Bit 0 is the MSB
Assigning value to a part-select of vector
wire [31:0] a,b,c;
a[31] = 1’b1
//Above means we are making the MSB of a equal to 1
You can’t change the order of MSB after declaration
Comments //
Number Specification
2’b11 // 2 bit binary number
Without base formatdecimal numbers e.g. 11 is a decimal no.
Without size simulator/machine specific, e.g: ‘h11 is a 32 bit no.
12’hCDF // 12 bit hex number
-3’d1 // 3 bit 2’s complement of 1
Keywords & Identifiers
wire Write_enable; // wire is a keyword & Write_enable is an identifier
Logic Values: 0,1 & ..X,Z
Unknown Value: X, e.g. Un-initialized value, A net driven by two primitives
High Impedance:
It is important Z, e.g. Tristate
to remember Buffer,
that there is noBi-directional I/O
X (unknown value) in a real circuit [SHO]
What shall be the value of
a, b and c
Gate-Level modelling
Verilog gate Primitives
Dataflow Modelling
Continuous Assignment using assign statement
Expressions, Operators, Operands
Behavioural Modelling
Structured Procedures: Initial & always blocks
Blocking & Non-blocking statements
HLL Higher language constructs (if, switch, case, loops)
Verilog Module
HA
HA
FA
Verilog HALF Adder & FULL Adder
module HA_GateLevel(
input a, b ,
output c_out, sum
);
xor x1 (sum,a,b);
and and1 (c_out,a,b);
endmodule
gate_name instance_name(out,in1,in2)
[CIL]
Basic Verilog Module
Verilog 2001 Verilog 1995
Module Declaration & module HA_GateLevel( module HA_GateLevel (a,b,c_o,s_o);
Port Listing
input a, b , input a,b;
output c_o, s_o output c_o, s_o;
Intermediate );
Connections, Wire
Declarations