-
Notifications
You must be signed in to change notification settings - Fork 0
/
Testbench.vhd
90 lines (64 loc) · 1.6 KB
/
Testbench.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
library ieee, std;
use ieee.std_logic_1164.all;
use ieee.std_logic_textio.all;
use std.textio.all;
use IEEE.numeric_std.all;
entity Testbench is
end entity;
architecture arc of Testbench is
component IITB_Proc is
port (
clk,rst, inst_flag : in std_logic;
instruc : in std_logic_vector(15 downto 0));
end component;
signal clock, reset : std_logic;
signal instr : std_logic;
signal instruction : std_logic_vector(15 downto 0);
begin
dut_instance : IITB_Proc
port map(clk => clock, rst => reset, inst_flag => instr, instruc => instruction);
process
begin
clock <= '1';
reset <= '1';
instr <= '0';
wait for 10 ns;
clock <= '0';
wait for 10 ns;
for i in 0 to 20 loop --depends on number of instructions you want to insert. There are 15 types of instructions in total
reset <= '0';
clock <= '1';
instr <= '1';
--instruction <= instruction code
if(i=1) then
instruction <= "0000000000000001";
else
instruction <= "0000000000000000";
end if;
wait for 10 ns;
clock <= '0';
wait for 10 ns;
reset <= '0'; --for Sx state to happen and increment memory location
clock <= '1';
instr <= '0';
wait for 10 ns;
clock <= '0';
wait for 10 ns;
end loop;
clock <= '1';
reset <= '1'; --So that FSM goes to Sinit and PC becomes 0
instr <= '0';
wait for 10 ns;
clock <= '0';
wait for 10 ns;
for i in 0 to 50 loop
reset <= '0';
clock <= '1';
instr <= '0';
wait for 10 ns;
clock <= '0';
wait for 10 ns;
end loop;
wait;
end process;
end architecture;