-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreg_inc_dec_tb.vhd
More file actions
149 lines (112 loc) · 2.97 KB
/
reg_inc_dec_tb.vhd
File metadata and controls
149 lines (112 loc) · 2.97 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
-- Julio Chavez
-- University of Florida
-- Small8 Microprocessor
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity reg_inc_dec_tb is
end reg_inc_dec_tb;
architecture TB of reg_inc_dec_tb is
component reg_inc_dec_16_bit_and_indexing
generic(width : positive := 8);
port(clk : in std_logic;
rst : in std_logic;
input : in std_logic_vector(width - 1 downto 0);
PC_inc : in std_logic;
PC_L_load : in std_logic;
PC_H_load : in std_logic;
PC_L_output : out std_logic_vector(width - 1 downto 0);
PC_H_output : out std_logic_vector(width - 1 downto 0));
end component reg_inc_dec_16_bit_and_indexing;
component reg_inc_dec
generic(width : positive := 8);
port(clk : in std_logic;
rst : in std_logic;
load : in std_logic;
inc : in std_logic;
dec : in std_logic;
input : in std_logic_vector(width - 1 downto 0);
output : out std_logic_vector(width - 1 downto 0));
end component reg_inc_dec;
constant WIDTH : positive := 8;
signal clk : std_logic;
signal rst : std_logic;
signal inc : std_logic;
signal dec : std_logic;
signal load : std_logic;
signal input : std_logic_vector(width - 1 downto 0);
signal output : std_logic_vector(width - 1 downto 0);
begin -- TB
U_REG_INC_DEC : reg_inc_dec
generic map(width => width)
port map(clk => clk,
rst => rst,
load => load,
inc => inc,
dec => dec,
input => input,
output => output);
process
begin
-- Default starting values
rst <= '1';
inc <= '0';
dec <= '0';
load <= '0';
clk <= '0';
wait for 10 ns;
clk <= '1';
wait for 10 ns;
clk <= '0';
rst <= '0';
clk <= '0';
wait for 10 ns;
clk <= '1';
wait for 10 ns;
clk <= '0';
load <= '1';
input <= x"EA";
clk <= '0';
wait for 10 ns;
clk <= '1';
wait for 10 ns;
clk <= '0';
clk <= '0';
wait for 10 ns;
clk <= '1';
wait for 10 ns;
clk <= '0';
clk <= '0';
wait for 10 ns;
clk <= '1';
wait for 10 ns;
clk <= '0';
clk <= '0';
wait for 10 ns;
clk <= '1';
wait for 10 ns;
clk <= '0';
load <= '0';
inc <= '1';
for i in 0 to 30 loop
clk <= '0';
wait for 10 ns;
clk <= '1';
wait for 10 ns;
clk <= '0';
end loop;
inc <= '0';
dec <= '1';
for i in 0 to 20 loop
clk <= '0';
wait for 10 ns;
clk <= '1';
wait for 10 ns;
clk <= '0';
end loop;
dec <= '0';
wait;
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end process;
end TB;