Professional Documents
Culture Documents
CO Lab-15
CO Lab-15
CO Lab-15
Lab 15
Logic Distinction
Combination Logic
Compute output based on input only 𝑋
𝑆
Output is function of input
𝑌
Clock is not required in such logic blocks Combinational Logic
Sequential Logic 𝐶𝑜𝑢𝑡
Storing data 𝐶𝑖𝑛
Contains memory element
Registers 𝑖𝑛1 𝑂1
Clock is an essential element 𝑖𝑛2
Combinational Logic
𝑂2
𝐹𝑏
Memory
Sequential Elements
Register: stores data in a circuit
Uses a clock signal to determine when to update the stored value
Edge-triggered: update when 𝑪𝒍𝒌 changes from 0 to 1
Clk
D Q
D
Clk
Q
Template for inferring Physical Register
always@(posedge clk or posedge rst)
begin RegA
if (rst == 1)
data_in
begin
RegA <= 0;
end
else rst_n
begin
RegA <= data_in;
end
end
Behavioral Modeling - Assignment
A statement within a procedural block is called a procedural statement
a=?
always@(posedge clk) begin b=?
a <= 5;
b <= a;
end
Task 1 (Counter)
A counter is a circuit that can
count from some between
two numbers with a pre-
defined increment.
Write Verilog code for the
circuit shown in the figure
that counts in increments of 𝟏
starting at 𝟎.
Extend this code such that another input by the
name of Start controls if counting starts or not
Task-1
Extend on the previous code such
that you have a ROM (8 × 19) where
depth is 8 and each location is 19 bit
wide. ROM
Here the counter acts as an address Counter (Program
of ROM fetching each value from it. Start Data
Memory)
Clock
Module Calling
IN OUT
My_Design_1
ALU
rst
PC
Instr.
We intend to use the previously Memory Control out
build code and design a simple ALU Signals
based process which takes input Datapath
directly from instruction. Control Unit
ROM: 8𝑥19
PC: 3-bit Control Signals:
In this example control signals are as follows:
ALU: Based on previous week
• Opcode
• A
• B