Professional Documents
Culture Documents
Verilog Session2
Verilog Session2
Verilog Session2
Trainers
Imtiaz Ahmed Abdullah Ifrit
Design Verification Engineer Design Verification Engineer
Neural Semiconductor Ltd Neural Semiconductor Ltd
Topics – Session 2
1. Simulating RTL using Testbench.
2. Finite State Machines.
3. Waveform-Based Debugging.
4. Design Guidelines.
5. Examination – Session 2.
6. Further Guidance.
Fig 1: https://tremend.com/blog/advanced-technologies/functional-verification-lifting-the-veil/
Simulating RTL using Testbench
Introduction to Testbench
Design Consideration
1. Combinational logics are needed here because we
expect that as soon as inputs change, the output will
also change.
2. A checker is needed for identifying the largest input
before division operation only.
Example: Testbench -> Arithmetic logic unit (ALU)
Code
Problem Statement
Write a testbench that will check all four operations of the
Arithmetic Logic Unit RTL.
Design Consideration
1. Connect DUT properly with the testbench.
2. Ensure results checking for all four operations.
3. Ensure proper driving of stimulus and collect output
properly.
Example: Results -> Arithmetic logic unit (ALU)
Waveform
Output
Finite State Machines
Understanding State and State Machines
State State Machine
Imagine a traffic light. A Finite State Machine (FSM) is Imagine you're training a dog with clear commands. A
like that light for any system. The FSM can be in just Finite State Machine (FSM) is like a set of those
one situation at a time, like the light being red, yellow, commands for a machine (or even a computer
or green. Each situation, or state, has its own thing, program!). The machine follows these instructions one
like the light showing red means stop, yellow means step at a time, like waiting for a treat (state). Each step
caution, and green means go. tells the machine what to do next, depending on what it
"sees" (conditions). For example, if the dog sits (input),
it gets a treat (output).
2 As output is the function of the current state it is stable Output is the function of the current state and inputs so
for one clock cycle it may change during the state and hence may or
may not be stable for one clock cycle
3 Output is stable for one clock cycle and not prone to Output may change multiple times depending on
glitches or spikes changes in the input and hence prone to glitches or
hazards
4 It requires more number of states compared to Mealy The Mealy machine needs at least one state less
machine compared to the Moore machine
5 STA is easy as combinational paths between the STA is complex as combinational paths are
registers are shorter relatively larger area compared to Moore machine
6 Higher operating frequency compared to Mealy Less operating frequency compared to Moore machine
machine
Example : Understanding APB protocol
APB FSM
Master Slave
R
S E
WRITE E C
N E
D I Memory
READ E V
R E
R
Ref: https://verificationforall.wordpress.com/apb-protocol/
Example: Understanding APB Signals
Problem Statement
Design an RTL containing a memory that can store value.
You will have to write the RTL with proper logic. Data from
master to slave will follow APB protocol.
Design Consideration
1. Communicating using APB protocol.
2. Completing Write and Read operation without errors.
Ref: https://github.com/kumarraj5364/AMBA-APB-PROTOCOL/tree/main
Waveform Based Debugging
Ideal Waveform: APB
APB operations
Operations
1. WRITE: Sending data from the master device to a slave device on the bus
2. READ: Requesting data from a slave device and receiving it on the master device.
RTL
Synthesized results
RTL
Synthesized results
RTL
Synthesized results
If-Else with Else Missing
RTL
Synthesized Result
Synthesized Result
Latch vs Flip flop
Flip-Flop (Edge Sensitive)
1. If asynchronous reset signals are used, then use the dual edge synchronizer to
synchronize the internally generated reset signals.
2. Avoid use of driving the flip-flop output to the asynchronous reset of the
subsequent flip-flop as this can have race conditions.
3. Avoid the use of an asynchronous pulse generator as it creates issues in the design
and timing closure and even during the place and route.
4. If power consumption is the goal then only use the efficient ripple counter, but
there is performance degradation while using the ripple counters due to the
cumulative delay effect or the cascaded delay due to the individual propagation
delay of the flip-flop.
Examination – Session 2
Examination Overview
1. MCQ 10%
2. Short Questions 10%
3. Fixing Code Errors 20%
4. Design an RTL 30%
Session 2 70%
Review these resources and practice writing RTL for different scenarios for
better understanding.