- Describe the main parts of a VHDL file
- Use Vivado development tool
- Be able to create a simulation testbenche and run the simulation
- Use De Morgan's and Distributive laws
-
Remind yourself the AND, OR, XOR gates.
-
Optional: If you want to use online EDA Playground tool, you will need Google account, Facebook account, or register your account on EDA Playground.
VHDL (VHSIC Hardware Description Language) is a programming language used to describe the behavior and structure of digital circuits. The acronym VHSIC (Very High Speed Integrated Circuits) in the language's name comes from the U.S. government program that funded early work on the standard. VHDL is a formal notation intended for use in all phases of the creation of electronic systems. Since it is both machine and human readable, it supports the design, development, verification, synthesis, and testing of hardware designs; the communication of hardware design data; and the maintenance, modification, and procurement of hardware.
Note: IEEE standards for VHDL language:
- IEEE Std 1076-1987
- IEEE Std 1076-1993
- IEEE Std 1076-2002
- IEEE Std 1076-2008
- IEEE Std 1076-2019
Vivado Design Suite is a comprehensive design environment developed by Xilinx (AMD) for the design, analysis, and implementation of programmable logic devices, such as FPGAs (Field-Programmable Gate Arrays) and SoCs (System on Chips). It provides a set of tools and features for digital design, synthesis, simulation, and implementation of electronic systems.
-
Run Vivado and create a new project:
- Project name:
BasicGates
- Project location: your working folder, such as
Documents
- Project type: RTL Project
- Create a new VHDL source file:
gates
- Do not add any constraints now
- Choose a default board:
Nexys A7-50T
(will be used later in the lab) - Click Finish to create the project
- Define I/O ports of new module
gates
:- Port name:
a
, Direction:in
b
,in
and_out
,out
or_out
,out
xor_out
,out
- Port name:
- Project name:
-
Open generated
gates.vhd
file in Design Sources and complete thearchitecture
part as follows.------------------------------------------------- -- Included libraries ------------------------------------------------- library ieee; use ieee.std_logic_1164.all; ------------------------------------------------- -- Entity declaration, I/O ports ------------------------------------------------- entity gates is port ( a : in std_logic; b : in std_logic; and_out : out std_logic; or_out : out std_logic; xor_out : out std_logic ); end gates; ------------------------------------------------- -- Architecture definition, Implementation design ------------------------------------------------- architecture Behavioral of gates is -- Declaration part, can be empty begin -- Body part -- 2-input AND gate and_out <= a and b; -- 2-input OR gate or_out <= a or b; -- XOR gate xor_out <= a xor b; end Behavioral;
Help: The
std_logic
type provides several values.type std_logic is ( 'U', -- Uninitialized state used as a default value 'X', -- Forcing unknown '0', -- Forcing zero. Transistor driven to GND '1', -- Forcing one. Transistor driven to VCC 'Z', -- High impedance. 3-state buffer outputs 'W', -- Weak unknown. Bus terminators 'L', -- Weak zero. Pull down resistors 'H', -- Weak one. Pulll up resistors '-' -- Don't care state used for synthesis and advanced modeling );
-
Take a look at the basic parts of the VHDL source code, such as entity, architecture, and testbench.
The usefull VHDL operators are shown in the table.
Operator Description <=
Value assignment and
Logical AND nand
Logical AND with negated output or
Logical OR nor
Logical OR with negated output not
Negation xor
Exclusive OR xnor
Exclusive OR with negated output -- comment
Comments -
The primary approach to testing VHDL designs involves creating a testbench. A testbench is essentially a separate VHDL file that stimulates the design under test (DUT) with various input values and monitors its outputs to verify correct functionality. The testbench typically includes DUT component instantiation and stimulus generation.
Navigate to File > Add Sources... Alt+A > Add or create simulation sources and proceed to create a new VHDL file named
tb_gates
(ensuring it has the same filename as the tested entity but prefixed withtb_
). This time, click OK to define an empty module. Subsequently, locate the newly created simulation file under Simulation Sources > sim_1.Generate the testbench file using the online generator, then copy and paste its contents into your
tb_gates.vhd
file. Afterwards, fill in the test cases within thestimuli
process.... stimuli : process begin -- EDIT Adapt initialization as needed b <= '0'; a <= '0'; wait for 100 ns; -- EDIT Add stimuli here wait; end process; end tb;
-
Use Flow > Run Simulation > Run Behavioral Simulation and run Vivado simulator. To see the whole simulated signals, it is recommended to select View > Zoom Fit.
Note: To cleanup generated files, close simulation window, right click to SIMULATION or Run Simulation option, and select Reset Behavioral Simulation.
-
Use Flow > Open Elaborated design and see the schematic after RTL analysis. Note that RTL (Register Transfer Level) represents digital circuit at the abstract level.
De Morgan's laws are two fundamental rules in Boolean algebra that are used to simplify Boolean expressions. There are two versions of De Morgan's laws. De Morgan's law for AND: The complement of the product of two operands is equal to the sum of the complements of the operands. De Morgan's law for OR: The complement of the sum of two operands is equal to the product of the complements of the operands.
- Use De Morgan's laws and modify the original function into a form with AND, OR, or NAND, NOR gates.
Note that the figure with the equations above was generated by Online LaTeX Equation Editor using the following code.
\begin{align*} f_{\textup{ORG}}(c,b,a) =&~ (\overline{c\cdot b}) + (\overline{b}\cdot a)\\ f_{\textup{AND}}(c,b,a) =&\\ f_{\textup{OR}}(c,b,a) =&\\ \end{align*}
-
Create a new Vivado project
deMorgan
and source filedemorgan.vhd
with the following I/O ports:- Port name:
a
, Direction:in
b
,in
c
,in
f_org
,out
f_and
,out
f_or
,out
Get inspired by Example of basic gates from EDA Playground, complete the
architecture
, add new simulation source filetb_demorgan.vhd
, and verify all three functions in Vivado simulator. - Port name:
-
Use Flow > Open Elaborated design and see the schematic after RTL analysis.
-
Choose one of the distributive laws and verify, using VHDL, that both sides of the equation represent the same logic function.
First Distributive law:
Second Distributive law:
-
You can also try several online graphics simulators, such as CircuitVerse, Logicly, CircuitLab, simulatorIO, LogicEmu to simulate logic circuits.
-
In addition to the professional Vivado tool, which requires significant local disk storage, other simulation tools are available, including TerosHDL and ghdl.
TerosHDL is an open-source tool designed to streamline FPGA development by providing a unified workflow for simulation and synthesis using VHDL. GHDL is a free and open-source VHDL simulator that is a popular choice for hobbyists and students. It is a good option for learning VHDL and for simulating small-scale designs.
- Try to install TerosHDL on Windows or Linux
- Try to install ghdl on Windows or Linux
-
Real Digital. Creating Your First Project in Vivado
-
Tomas Fryza. Example of basic OR, AND, XOR gates
-
CodeCogs. Online LaTeX Equation Editor
-
CircuitVerse. Online Digital Logic Circuit Simulator
-
Xilinx University Program. Vivado FPGA Design Flow on Zynq