Vivado HLx
Fullform of verilog is Verify Logic
HDL : Hardware Description Language
Only for digital circuits
Cadence is used to analyze and make circuits.
Verilog is a Programming language, to make a circuit accordingly.
Hardware Description Language
12 Experiments, scheduled in the next 2months.
We'll be working on Data Flow Modelling
A word file has to be prepped for each lab, showcasing the results of each lab. The wordfile should contain RTL (Resistor Transistor Logic).
Open home screen of Vivado, under the Quick Start box, click on Create Project.
Extension of extension file : .v file
Select Project Type as RTL Project
Select board, as the circuit has to be contructed on a board
Artix-7 AC701 Evaluation Platform
While defining the project, also add module name
The program manager page opens, open the file (visible under sources tab)
Run simulation => run behavioural simulation
RTL Analysis => To visualize what combination of gates we have built
The wordfile should have the following :
The following gates have to be constructed :
Instead of using Force Constant (under RTL Analysis), we can also make use of textbench to test if our given program is correct.
Use TestBench
reg Data Type
Used to store data, values are retained until update
Vectors : Represent multi-bit buses
Memory : Used to model memories like ROM, RAM
Arrays : Collection of same types of variabes and accessed using the same name plus one or more indices
Parameters : constant values to be used in the program
Arithmetic
Logical ( negation, and, or )
Relational
Equality
Bitwise
Shift
Concatenation
Replication
Conditional
Difference between | and ||
Difference between >> and >>>
ans : >> preserved the sign bit triple >>> does not
Conditional
Symbol " ?: "
We only use, only when required
$strobe
Displays simulation data at the end of current simulation time
$monitor
Each time a variable or expression changes values, the entire argument is displayed at the end of time step
$stop
Suspends the simulation and puts simulator in inactive mode
$finish
Makes the simulator exit and pass the control to the OS
Continuous
Assign value when right hand side value changes
Implicit assignment
Independent of order
Executes in parallel and continues
Procedural
Value placed on variable remains unchanges, unless a new procedural assignment updates the variable with a different value.
Multiple procedural blocks in a module can execute concurrently
Two types of procedural assignment :
a. Initial : Execution starts at zero, executes only once
b. Always : Repeats continuosly
Delays
Block statements
Type of assignments :
Levels of Abstraction :
Implement Half Adder and Full Adder using Verilog
Sum = A_bar.B + A.B_bar
Carry = A.B
4bit adder
4bit subtractor
Multi Input, One Output
Design a 4x1 multiplexer
Further design 1x4 demux (data distributor)
We have covered half adder and full adder in combinational circuits
Write testbench for all cases (have select-line as inputs)
Generate sum-output of the full adder using a 4x1multiplexer.
Number of input bit required for full adder : 3
First draw out the structure for full adder, to generate required output
4x1 multiplexer requires 4inputs, but we have only 3 => To solve this, we try to minimize circuit
For 4inputs, 2select lines are also considered as inputs. Consider one input as 0, to minimize the circuit
Difficult way to achieve the same
Vary select lines, and depending on which select line is enabled, put signals S0, S1, S2, S3
S0 | S1 | Data Output Selected |
---|---|---|
0 | 0 | A |
0 | 1 | B |
1 | 0 | C |
1 | 1 | D |
Try the same to generate carry-output of full adder
Decoder circuit
4x1 Mux
8x1 Mux
Generate half-adder sum
Make parity generator using Mux
Generate full-adder sum
Topic : Finite State Machines (FSM)
Course to follow on NPTEL : Hardware Modelling Using Verilog
Present State | Next State |
---|---|
00 | 01 |
01 | 11 |
11 | 00 |
If we do not have next state, we have been provided a mathematical function for the same, through which we can infer next states, through a graphical depiction of the function.
Find the following from the flip-flop
DA, DB, Current State, Next State
To practice :
Construct a full adder using half adders.
Combinational
Output only depends only on the applied input values and not on the past history.
Sequential
Output not only depends on input, but also on state. The internal state also change with time. The number of states is finite and hence a sequential circuit is also referred to as a Finite State Machine.
Most of the practical circutis are sequential in nature, as having infinite states required infinite number of flip-flops.
FSM can be represented either in the form of a state table or in the form of a state transition diagram.
Mealy
Output depends on state + inputs
Moore
Output only depends on state
There are 3 lamps, Red Green and Yellow that should glow cyclically with a fixed time interval.
Some observations:
Denotion | State | Color |
---|---|---|
00 | S_0 | Red |
01 | S_1 | Green |
10 | S_2 | Yellow |
2 Bits are required to model this.
Comment on the solution
The synthesis tool will generate five flip flops - 2 for state and 3 for light.
The three output lines are also getting stored in flip-flops
- We have used non-blocking assignment triggered by clock edge.
But actually we do not need sepeare flip-flops for the outputs, as the outputs can be directly generated from the state.
Example 2
Design of a serial parity detector.
0 will indicate "even number of 1's seen so far
1 will indicate "odd number of 1's seen so far.
Also a Moore Machine
Example 3
Design of a sequence detector
A circuit accepts a serial bit stream "s" as input and prouces a serial bit stream "z" as output.
Whenever the bit pattern "0110" appears in the input stream, ut outputs z=1, at all other times z=0.
Overlapping occurrencess of the pattern are also detected
This is a Mealy Machine
Design a sequence detector for 01110
State diagram for the sequence detector :
State | Received Bit | Remark |
---|---|---|
s0 | - | Starting s0 |
s1 | 0 | 1bit received successfully |
s2 | 1 | 2bits received successfully |
s3 | 1 | 3bits received successfully |
s4 | 1 | 4bits received successfully |
One had to submit a doc containing RTL Logic, Code snapshots, testbench code and testbench output.