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
|
--********************************************************************************************************************--
--! @brief Testbench for decoder simulator
--********************************************************************************************************************--
library ieee;
use ieee.std_logic_1164.all;
use IEEE.numeric_std.all;
library STD;
use std.env.all;
use work.irqc_pif_pkg.all;
use work.ilos_sim_pkg.all;
--! Local libraries
library work;
--! Entity/Package Description
entity tb_irqc is
end entity tb_irqc;
architecture tb of tb_irqc is
-- Signal declarations
SIGNAL arst_sig: std_logic;
SIGNAL clk_sig: std_logic;
SIGNAL cs_sig: std_logic;
SIGNAL addr_sig: unsigned(2 DOWNTO 0);
SIGNAL wr_sig: std_logic;
SIGNAL rd_sig: std_logic;
SIGNAL din_sig: std_logic_vector(7 DOWNTO 0);
SIGNAL dout_sig: std_logic_vector(7 DOWNTO 0);
SIGNAL p2c_sig: t_p2c;
SIGNAL c2p_sig: t_c2p;
SIGNAL run_sig: std_logic;
signal sbi_if : t_sbi_if(addr(2 downto 0), wdata(7 downto 0), rdata(7 downto 0)) := init_sbi_if_signals(3, 8);
--! Component declaration for Behavioral Decoder
COMPONENT irqc_pif IS
PORT(
arst : in std_logic;
clk : in std_logic;
-- CPU interface
cs : in std_logic;
addr : in unsigned;
wr : in std_logic;
rd : in std_logic;
din : in std_logic_vector(7 downto 0);
dout : out std_logic_vector(7 downto 0) := (others => '0');
--
p2c : out t_p2c;
c2p : in t_c2p
);
END COMPONENT irqc_pif;
BEGIN
IRQC: irqc_pif PORT MAP (
arst => arst_sig,
clk => clk_sig,
cs => cs_sig,
addr => addr_sig,
wr => wr_sig,
rd => rd_sig,
din => din_sig,
dout => dout_sig,
p2c => p2c_sig,
c2p => c2p_sig
);
-- Clock generation with concurrent procedure call
clk_gen(clk_sig, 50.0E6, 0 fs, run_sig); -- 50 MHz clock
-- Time resolution show
-- assert FALSE report "Time resolution: " & time'image(time'succ(0 fs)) severity NOTE;
tb: PROCESS
BEGIN
run_sig <= '1';
arst_sig <= '1';
cs_sig <= '0';
addr_sig <= to_unsigned(0, addr_sig'length);
wr_sig <= '0';
rd_sig <= '0';
din_sig <= (others => '0');
c2p_sig.aro_irr <= (others => '0');
c2p_sig.aro_ipr <= (others => '0');
c2p_sig.aro_irq2cpu_allowed <= '0';
wait for 200 ns;
arst_sig <= '0';
wait for 205 nS;
rd_sig <= '1';
cs_sig <= '1';
wait for 20 ns;
addr_sig <= to_unsigned(C_ADDR_IER, addr_sig'length);
wait for 20 nS;
addr_sig <= to_unsigned(C_ADDR_IPR, addr_sig'length);
wait for 20 nS;
addr_sig <= to_unsigned(C_ADDR_IRQ2CPU_ALLOWED, addr_sig'length);
wait for 20 nS;
addr_sig <= to_unsigned(C_ADDR_IER, addr_sig'length);
din_sig <= X"15";
wr_sig <= '1';
rd_sig <= '0';
wait for 20 ns;
cs_sig <= '0';
wr_sig <= '0';
rd_sig <= '1';
cs_sig <= '1';
wait for 80 ns;
cs_sig <= '0';
rd_sig <= '0';
wait for 200 nS;
-- End simulation
run_sig <= '0';
wait for 200 nS;
finish;
END PROCESS tb;
end architecture tb;
|