Unit 1
Unit 1
Daniel Llamocca
✓ DESIGN FLOW (Vivado Software)
▪ Synthesis: In this step, the VHDL code is examined for
syntax errors and warnings. While your code should be free
of syntax errors, watch out for warnings and critical
warnings. After this, we do behavioral simulation.
▪ Simulate Behavioral Model: We need to write a VHDL
file called ‘testbench’ where we specify the stimuli to the
logic circuit.
▪ Implement Design (Translate + Map + Place & Route)
▪ Generate Programming File: Here, a configuration file or
bitstream (.bit) is generated. This file will configure the
FPGA so that the logic circuit is implemented on it.
▪ Configure Target Device (Programming): The bitstream
file is written onto the FPGA configuration memory so that a
digital circuit is materialized. At this stage, we can verify
whether the hardware is actually working.
Daniel Llamocca
✓ LOGIC DATA TYPES
▪ Type: This is how data (digital signals or even abstract constructs like
variables) is specified in VHDL. Though different standards are available, a
common one is the IEEE std_logic_1164, that allows for these basic types:
▪ std_logic, std_logic_vector, std_logic_2d
▪ The std_logic type defines nine (9) possible states for a 1-bit signal:
▪ ‘U’ : Uninitialized
▪ ‘X’ : Forced Unknown
▪ ‘0’ : Zero
▪ ‘1’ : One
▪ ‘Z’ : High impedance
▪ ‘W’ : Weak unknown
▪ ‘L’ : Weak Zero
▪ ‘H’ : Weak One
▪ ‘-’ : Don’t care
▪ Other data types:
▪ array (group of signals, or group of groups)
▪ integer, user-defined
Daniel Llamocca
✓ LOGIC DATA TYPES:
▪ A digital circuit includes internal signals and external signals (also
called I/Os). In VHDL, I/O specification is called ‘mode’.
▪ Mode: Physical characteristics of inputs/outputs of a logic
circuit. The following modes are available in VHDL:
✓ IN : Input port of a circuit
C
x
B
F
A y
• Note: In VHDL, A B C are inputs (IN), F is an output
(OUT), and x and y are internal signals (signal).
Daniel Llamocca
✓ LOGIC GATES IN VHDL
▪ EXAMPLE: VHDL code: example.vhd
library ieee;
use ieee.std_logic_1164.all;
I/Os are specified here
entity example is
port ( A, B, C: in std_logic; A
F: out std_logic); B logic F
circuit
end example; C
Daniel Llamocca
✓ TESTBENCH GENERATION
▪ EXAMPLE: library ieee;
use ieee.std_logic_1164.all;
tb_example.vhd entity tb_example is
end tb_example;
architecture behavior of tb_example is
component example
the outputs
We retrieve
Unit
We provide
# Outputs OFF(0)
Daniel Llamocca
✓ VIVADO: I/O ASSIGNMENT
XDC file: Here, we map the I/Os of our circuit to physical FPGA
pins. In a board (e.g. Nexys-4), many FPGA pins are wired to
specific components (LEDs, switches, buttons, etc.).
▪ Example: Nexys-4 Artix-7 FPGA Board:
To connect the inputs a, b, c to SW2 SW1 SW0 and the output f to
LED0, we assign a, b, c, f to the corresponding FPGA pins (this
mapping information is provided by the board’s manufacturer).
▪ Vivado: The I/O standard and pin name must be specified for
every I/O port. Pin names are case-sensitive and must match
the port names as specified in the VHDL entity.
# Inputs▪ XDC file: example.xdc
set_property PACKAGE_PIN U9 [get_ports {a}]
set_property IOSTANDARD LVCMOS33 [get_ports {a}] FPGA pins: R7 U8 U9 T8
set_property PACKAGE_PIN U8 [get_ports {b}]
set_property IOSTANDARD LVCMOS33 [get_ports {b}] NEXYS 4
schematic names: SW2 SW1 SW0 LED0
set_property PACKAGE_PIN R7 [get_ports {c}] ON (1)
set_property IOSTANDARD LVCMOS33 [get_ports {c}]
OFF(0)
# Outputs
a b c f
set_property PACKAGE_PIN T8 [get_ports {f}] I/O VHDL names:
entity test is
port ( A: in std_logic_vector (3 downto 0);
-- A: |A3|A2|A1|A0|
y: out std_logic); A = A3A2A1A0
end test; A(3)
A(2)
y
architecture struct of test is A(1)
A(0)
begin
-- The circuit represents an AND gate
-- with 4 inputs: A(3), A(2), A(1), A(0)
y <= A(3) and A(2) and A(1) and A(0);
end struct;
Daniel Llamocca
✓ USE of std_logic_vector
▪ Here, we use this type in a testbench for ‘test’.
library ieee;
use ieee.std_logic_1164.all;
entity tb_test is
* The values for a signal of end tb_test;
type std_logic_vector
architecture behavior of tb_test is
can be specified in different component test
ways (see this testbench). port ( A: in std_logic_vector(3 downto 0);
F: out std_logic);
end component;
* A <=“0010”: It is -- Inputs
equivalent to: signal A: std_logic_vector(3 downto 0):= "0000";
-- Outputs
A(3)<=‘0’; A(2)<=‘0’; signal f: std_logic;
A(1)<=‘1’; A(0)<=‘0’; begin
uut: test port map (A=>A,F=>F);
stim_proc: process -- Stimulus process
begin
100 ns 120 ns 140 ns wait for 100 ns -- reset state
A 0000 0010 1111 1101
-- Stimuli:
A <= "0010"; wait for 20 ns;
F A <= x"F"; wait for 20 ns; -- A <="1111"
A <= "11"&"01"; wait for 20 ns; -- A <="1101"
wait;
end process;
Daniel Llamocca end;
✓ USE of std_logic_vector
▪ In the example, we use the std_logic_vector type for an output signal.
library ieee;
use ieee.std_logic_1164.all;
entity tst is
port ( A,B: in std_logic;
F: out std_logic_vector (3 downto 0);
-- F: |F3|F2|F1|F0
end tst;
A B F = F3F2F1F0
architecture struct of tst is F(3)
begin F(2)
Daniel Llamocca
✓ EXAMPLE: Security Combination
▪ A lock is opened only when a certain combination of
switches exist: Switches: 01101011
▪ The lock will be represented by 8 LEDs. Open Lock All
LEDS ON.
SW7 SW6 SW5 SW4 SW3 SW2 SW1 SW0
ON (1)
OFF (0)
LED7
LED6
LED5
LED4
LED3
LED2
LED1
LED0
➢ sec_comb.zip: sec_comb.vhd, tb_sec_comb.vhd,
sec_comb.ucf
Daniel Llamocca