Professional Documents
Culture Documents
Chapter-5
Logic Design with Behavioral Models of
Combinational and Sequential Logic
Circuit Structural
Schematic Model
User-Defined
Truth Table
Primitives
Boolean Continuous
Equations Assignments
Cyclic Behavioral Models:
Model edge sensitive functionality (e.g. posedge or
negedge of clock).
Cyclic Behavior is abstract – do not use hardware to
specify signal values.
Do not expire after the execution of last procedural
statements.
Execution can be unconditional or can be governed by
an optional event control expression.
Capable of modeling both edge sensitive and level
sensitive behavior.
A A_gt_B
Compare_32 A_lt_B
B A_eq_B
endmodule
Dataflow/RTL Models:
Describes concurrent operations on signals in a
sequential machine.
The computations are initiated at the active edge
of clk and completed in a time to be stored in a
register at the next active edge.
RTL model are written for a specific architecture
:that is, the registers, data paths and machine
operations and their schedule are known a
priori.
Blocking and Non-Blocking Operator:
endmodule
Simulation Result:
“Blocking Operator”
“Non-Blocking Operator”
Algorithm-Based Models:
Algorithms based models are abstract in nature.
It defines the sequence of procedural
assignment within a cyclic behaviour, the
execution of statement determines the storage
variable and output of the machine.
Eliminates the need of a priori architecture.
Algorithm model execute sequentially, without
an explicit architecture.
“Not all Algorithms can be implemented in hardware”
Linear Feedback Shift Register:
Reset
C3 C2 C1
R R R R
D S + D S + D S + D S
Y[4]
Clk Y[1] Clk Y[2] Clk Y[3] Clk
Clock
while (temp_reg)
begin
if (temp_reg [0] ) count =count+1;
temp_reg = temp_reg >> 1;
end
while (temp_reg)
begin
count =count + temp_reg[0];
temp_reg = temp_reg >> 1;
end
*** while loop will execute till the time temp register is not equal to zero ***
Difference between forever & always :
always @ (trigger)
begin: search_1
index = 0;
for ( index = 0; index <= 15; index = index+1 )
if ( word [index])
disable search_1;
end
Up- down Counter with and without the conditional output boxes
Barrel Shifter :
Used in digital signal processors to avoid
overflow problems by scaling the input and
output of a datapath operation.
Shifting the word to the right effectively divide
the word by a power of 2 whereas shifting to the
left multiplies the word by a power of 2.
It can be implemented using the combinational
logic as well as registered logic.
8-bit Barrel Shifter with Registered Output :
Example of 32-Word Register File :
assign Data_Out_1=Reg_file[Read_Addr_1];
assign Data_Out_2=Reg_file[Read_Addr_2];
always @ (posedge clock)
begin
if (Write_Enable)
Reg_file[Write_Addr]<=Data_in;
end
endmodule
Keypad Scanner and Encoder :
Keypad Code for Hexadecimal Scanner :
Key Row [3:0] Col [3:0] Code
0 0001 0001 0000
1 0001 0010 0001
2 0001 0100 0010
3 0001 1000 0011
4 0010 0001 0100
5 0010 0010 0101
6 0010 0100 0110
7 0010 1000 0111
8 0100 0001 1000
9 0100 0010 1001
A 0100 0100 1010
B 0100 1000 1011
C 1000 0001 1100
D 1000 0010 1101
E 1000 0100 1110
F 1000 1000 1111
ASM Chart for Keypad :
Text Bench Model for Hex-Keypad :
Row[0] Code[3]
Row[1] Code[2]
Key Grayhill 072
Signal X Row_Signal Row[2] Hex Keypad Code[1]
Generator 16
for Keys Code
Row[3] Code[0]
Generator
Valid
Col [3]
Col [2]
Col [1]
Col [0]
***www.grahill.com***
Summary :
Data types are broadly classified as net and wire.
Different systems can be implemented using Cyclic
Behavioral, Dataflow/RTL and Architectural based
model.
Different loop constructs which Verilog supports are:
for, while, repeat and forever.
Verilog supports two types of subprograms:
Task create a hierarchical organization of the procedural
statements within a verilog behavior.
Function substitute for an expression.
ASM charts are abstraction of the functionality of a
sequential machine and are used to model the behavior
of the system.