Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Xianan WANG
9/12/2017
1
Hardware Description Languages (HDL)
VHDL
Verilog
2
HDL Design Flow
Verify Design
Synthesize Circuits
3
Design Specification (SPEC)
entity 2_bit_full_adder is
Port (
A: in std_logic_vector (1 downto 0);
A[1:0] B: in std_logic_vector(1 downto 0);
S[1:0] Cin: in bit;
2-bit full adder S: out std_logic_vector(1 downto 0);
B[1:0] Cout: out bit);
end 2_bit_full_adder
Cin Cout
4
Behavioral Model:
used in program.
5
Structural Model:
structure.
6
A VHDL Example: Up-Down Counter
1. Counter adds(or
subtracts) 1 at
rising edge of
clock
clock
Up-Down Counter 2. When up_down = 0,
reset adds; when up_down
Counter[3:0]
= 1, subtracts
up_down 3. When reset = 1,
reset counter to
0000
7
Behavioral Model: Outline
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity up_down_counter is
port( clock: in std_logic;
reset: in std_logic;
up_down: in std_logic;
counter: out std_logic_vector(3 downto 0)
);
end up_down_counter;
9
Testbench: Verify functionality
10
Testbench: Outline
library ieee;
use ieee.std_logic_1164.all;
entity tb_up_down is
end tb_up_down; // empty entity
11
Testbench: Instantiate DUT
*DUT Design Under Test
12
Testbench: Map Ports
architecture tb_arch of tb_up_down is
signal clock: std_logic := '0';
signal reset: std_logic := '0';
signal up_down: std_logic := '0';
begin
uut: up_down_counter port map (
clock => clock,
reset => reset,
up_down => up_down,
counter => counter
);
end tb_arch;
13
Testbench: Generate and Feed Input(1)
architecture tb_arch of tb_up_down is
constant clock_period: time := 20 ns;
clock_process: process
begin
clock <= '0';
wait for clock_period/2;
clock <= '1';
wait for clock_period/2;
end process;
end tb_arch;
14
Testbench: Generate and Feed Input(2)
architecture tb_arch of tb_up_down is
stim_proc: process
begin
wait for 20 ns;
reset <= '1';
wait for 20 ns;
reset <= '0';
up_down <= '0';
wait for 200 ns;
up_down <= '1';
wait;
end process;
end tb_arch;
15
ModelSim: Create Project (1)
3. Click OK to confirm.
16
ModelSim: Create Project (2)
18
ModelSim: Simulate
1. Simulate -> Start Simulation;
3. Define resolution;
4. Press OK.
19
ModelSim: Simulate
1. Select all signals that you want
to observe;
20
ModelSim: Simulate
2. Press Run
21
1. Waveform is generated;
2. Verify functionality.
22