Lecture 5
Lecture 5
Lecture 5
Lecture # 5
Introduction to Logic Circuits
input A, B, CI ;
output S, CO ;
Concurrent Blocks
Blocks of code that seem to execute in the same point in time
7
Concurrent Blocks
Types
Procedural
Initial
Always
Continuous assignments
assign
8
Procedural blocks
Two Types
Initial:: executes only once at time zero
always: block is active throughout the simulation
Within each block, all statements executed sequentially
9
Initial Block
Continuous assignments
Single statement which executes continuously and does not
wait for any event to occur
Syntax
assign a = b + c;
12
Concurrent Execution
‘0’: Zero, Low, False, Logic Low, Ground, VSS, Negative Assertion
‘1’: One, High, True, Logic High, Power, VDD, VCC, Positive
Assertion
‘X’: Unknown: Occurs at Logical Conflict which cannot be
resolved
‘Z’: Hi-Z: High Impedance, Tri-stated, Disabled Driver
14
Sensitivity List
Wire:
Connects modules or primitives
Wires can’t store their values, must be driven
Wire can be one bit wide or more than one bit wide (vector)
Examples,
wire a; // declares a as a wire
wire x, y, z; // declares x, y, z as three wires
wire [7:0] b, c, d; // declares b, c, d as three 8-bit vector wires
default data type in Verilog
module ports are implicitly defined as wire by Verilog
18
Data Types in Verilog: Wire
Wire (example 1)
c is explicitly defined as a wire
three other wires in this module, y,
a, b, are also port modules
y, a, b are implicitly defined as
wires
19
Data Types in Verilog : Reg
Registers: Examples,
Registers (unlike wires) can reg a; // declares a as a
store values register
Registers
can be one bit, or reg x, y; // defines x and y
more than one bit (vectors) as two registers
Driven Outputs need to be of reg [4:0] b; // declares b
type reg as a 5-bit (vector) register
20
Data Types in Verilog (contd.)
Registers (example):
The output port q is defined as
a one bit register
q is assigned the value of
input d at the positive edge of
the input clk
21
Data Types in Verilog (contd.)
Integers
Integers are 32 bit wide in Verilog
Integers are signed numbers
example,
integer j, k, l; // declares three integers
Keyword ‘integer’, NOT ‘int’
Main difference between integer and reg is signed, reg is unsigned
Integers cannot have bit-selects ie. J [4:0]
Integers are not recommended for synthesis
22
Data Types in Verilog (contd.)
Integer: examples
integer j, k, l; // declares j, k, l as three integer
23
Difference between scalar and a
vector
Scalar: reg a, b
Vector: reg [4:0] A, B;
24
Strings
Declaration of parameters
parameter A = 2’b00, B = 2’b01, C = 2’b10;
parameter regsize = 8;
reg [regsize - 1:0]; /* illustrates use of parameter regsize */
26
FPGA Device Present on the Digilent
Spartan-3E Starter Kit Board