-
Notifications
You must be signed in to change notification settings - Fork 2
/
fakeuart_tb.vhd
74 lines (57 loc) · 1.51 KB
/
fakeuart_tb.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use work.uart_comp.all;
use work.clockgen_comp.all;
ENTITY fakeuart_tb IS
END fakeuart_tb;
ARCHITECTURE behavior OF fakeuart_tb IS
--Inputs
signal WR_D : std_logic_vector(7 downto 0) := (others => '0');
signal ABUS : std_logic_vector(15 downto 0) := (others => '0');
signal WR_EN : std_logic := '0';
signal CPUCLK : std_logic := '0';
signal RX : std_logic := '1';
signal RST : std_logic := '1';
signal lockrst : std_logic;
--Outputs
signal RD_D : std_logic_vector(7 downto 0);
signal INT, TX : std_logic;
-- Clock period definitions
signal CLK : std_logic := '0';
constant CLK_period : time := 10 ns;
signal clkstatus : clockgen_status;
constant CPUCLK_period : time := 240 ns;
BEGIN
uclk : clockgen port map ( CLK, open, open, CPUCLK, open, clkstatus, RST );
lockrst <= RST or not(clkstatus.locked);
-- Instantiate the Unit Under Test (UUT)
uut: uart PORT MAP ( WR_D, RD_D, ABUS, WR_EN, INT, TX, RX, CPUCLK, RST );
-- Clock process definitions
CLK_process :process
begin
CLK <= '0';
wait for CLK_period/2;
CLK <= '1';
wait for CLK_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
wait for CLK_period*10;
rst <= '0';
wait for 705 ns;
ABUS <= X"FF01";
WR_D <= X"6d";
wait for CPUCLK_period * 2;
WR_EN <= '1';
wait for CPUCLK_period * 2;
WR_EN <= '0';
ABUS <= X"FF02";
WR_D <= X"FF";
wait for CPUCLK_period * 2;
WR_EN <= '1';
wait for CPUCLK_period * 2;
WR_EN <= '0';
wait;
end process;
END;