Verilog Lab RDD
Verilog Lab RDD
Aims:
1. Understanding HDLs: Not your average C++ Code
2. Introduction to Verilog: Verilog 2005 & SystemVerilog
3. Toolchains: Editor, Icarus Verilog & GTK Wave
4. Basic Designs:
a. Adder
b. Mux
c. Flip Flops
5. Final Design: 8 Bit ALU
Iverilog & GTK Wave together form a very simple, functional & light weight CLI
based method to write, simulate & test all your designs in Verilog.
Basic Designs:
The Methodology:
1. Create a simple block diagram based on the circuit you wish to design.
It should be the pseudocode of your circuit and should define what
inputs and outputs you require.
2. Creating the Design File:
The Design file will contain the implementation of the function you wish
to synthesize. It will follow a standard template of Verilog programming
constructs.
This single design file is called a Module.
For complex designs: eg, CPU, a hierarchy of Modules will create a Tree
structure, with the Top File being the root node.
Following the rules of Abstraction helps to keep the implementation and
the I/O separate, making the overall hierarchy cleaner and easier to work
on.
Remember to keep certain test outputs in your design file so that you
have the ability to probe the important signals inside the
implementation itself.
3. Creating the Testbench:
Having designed the module itself, it is super important to test your
module.
Note: Testbenches are not supposed to be synthesizable. They are merely
there for verification and simulation purposes (for now).
A Testbench firstly instantiates the Module under Test. This process is
similar to creating an object of your self defined class.
The Testbench should ideally test all the conditions that the Module
under test may be exposed to.
Exhaustive Testing is the key to designs which work reliably.
4. Testing & Simulation:
Using Iverilog & GTK Wave, testbench outputs can be observed and
verified.
Completing this process yields a verified reliable design module!
Adder:
A basic Combinational circuit that can add/subtract multiple inputs to
provide one output. Can be made to accommodate a variety of signal
widths.
Mux:
The Multiplexer/Demultiplexer combo provides you with the ability to
utilize conditional statements inside your design, allowing you to create
if/else control structures as well as switch case statements.
Flip Flops:
The very basic element of all Sequential Circuits, understanding and
creating working flip flop designs helps out for a variety of bugs, such as
button debouncing and input /output delays.
Bonus:
The Datasheet states the presence of carry look ahead adders to improve the
addition/subtraction operation times.
Try if you can implement the Carry Look Ahead Adder and integrate it into this
design.
Tip:
4 Bit Carry Look Ahead Adder logic analysis are available online.
You may Daisy Chain two of them together to create the required design.
Create a separate module for Carry Look Ahead Adder and integrate it into the
ALU design along the other functions.
References:
1. Icarus Verilog Setup: It’s just an exe setup for windows. Linux & MacOS
users can use the terminal to directly install the required tools.
https://bleyer.org/icarus/
2. GTK Wave:
https://gtkwave.sourceforge.net/
Linux & MacOS users can again simply use the terminal to get the tools
installed easily.
4. Wikipedia: The Wiki Article for Verilog does a great job introducing the
language, its semantics & certain common beginner fallacies while also
providing methods to alleviate such problems.
https://en.wikipedia.org/wiki/Verilog
It also contains a lot of stuff that is nice to know for even advanced
projects, so that is up to the curiosity of the reader.