-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_uartcp.vhd
130 lines (112 loc) · 3.41 KB
/
test_uartcp.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
------------------------------------------------------------------------
entity test_uartcp is
end test_uartcp;
------------------------------------------------------------------------
architecture behavioral of test_uartcp is
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT uarttx
PORT(
clk : IN std_logic;
ready : OUT std_logic;
clear : IN std_logic;
clearacc : OUT std_logic;
dataout : IN std_logic_vector(7 downto 0);
datain : OUT std_logic_vector(7 downto 0);
load : IN std_logic
);
END COMPONENT;
COMPONENT uartrx
PORT(
clk : IN std_logic;
ready : OUT std_logic;
clear : IN std_logic;
clearacc : OUT std_logic;
dataout : IN std_logic_vector(7 downto 0);
datain : OUT std_logic_vector(7 downto 0);
load : IN std_logic
);
END COMPONENT;
--Inputs
signal clk : std_logic := '0';
signal clear : std_logic := '0';
signal clear2 : std_logic := '0';
signal dataout : std_logic_vector(7 downto 0) := (others => '0');
signal load : std_logic := '0';
signal load2 : std_logic := '0';
--Outputs
signal ready : std_logic;
signal ready2 : std_logic;
signal clearacc : std_logic;
signal datain : std_logic_vector(7 downto 0);
-- Clock period definitions
constant clk_period : time := 10 ns;
signal str : string(1 to 256) := (others => nul);
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut2: uarttx PORT MAP (
clk => clk,
ready => ready2,
clear => clear2,
clearacc => open,
dataout => dataout,
datain => open,
load => load2
);
uut: uartrx PORT MAP (
clk => clk,
ready => ready,
clear => clear,
clearacc => clearacc,
dataout => "00000000",
datain => datain,
load => load
);
-- 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
variable idx : integer := 0;
variable d : STD_LOGIC_VECTOR(7 downto 0);
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for clk_period*10;
for idx in str'range loop
assert ready = '0' report "Ready!" severity failure;
load <= '1';
wait for clk_period;
load <= '0';
clear2 <= '0';
wait for clk_period;
assert ready = '1' report "Not ready!" severity failure;
--d := datain;
--d := not d;
--str(idx) <= character'val(conv_integer(d));
str(idx) <= character'val(conv_integer(not datain));
assert ready2 = '0' report "Ready2!" severity failure;
--dataout <= conv_std_logic_vector(character'pos(str(idx)), 8);
--dataout <= conv_std_logic_vector(idx-1, 8);
dataout <= not datain;
load2 <= '1';
clear <= '1';
wait for clk_period;
load2 <= '0';
clear <= '0';
wait for clk_period;
assert ready2 = '1' report "Not ready2!" severity failure;
clear2 <= '1';
end loop;
wait;
end process;
END;