Professional Documents
Culture Documents
Verilog
Combinational Logic in Verilog
Lecture # 04
Today’s Lecture
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)
Moving to Data Flow Model
Dataflow Level
Characterized by assign statement
Allows Expressions, Operators, Operands
Example:
wire c
assign c = a + b;
Example
wire d;
assign d = a || b; // explicit continuous assignment
Example
wire d = a || b; //implicit continuous assignment
Data Flow for full adder
[SHO]
Port Connection Styles
Instantiating a Module in another block
[SHO]
This
method is
better for
block with
greater no.
of ports
Combinational Logic
Output is Boolean
function of its input
variables on
instantaneous basis
CIL
Verilog Operators
Logical Right Logical Left
Arithmetic operators: +, -, *, /, %
Bitwise operators: &, |, ~, ^, ^~
Reduction operators: &, ~&, |, ~|, ^
~4'b0001 = 1110
4'b0001 & 4'b1001 = 0001
4'b0001 | 4'b1001 = 1001
& 4'b1001 = 0 // And across all the bits, Can be used
to raise flags such as waiting for a 1 from multiple
inputs
| 4'b1001 = 1
4'b1001 << 1 = 0010
4'b1001 >> 1 = 0100
{4'b1001,4'b1111} = 10011111 // Can be used to
concatenate wires/buses
Date Flow: conditional operator
module mux21(
input in1,in2,sel,
output out);