1 |
2 |
idiolatrie |
--------------------------------------------------------------------------------
|
2 |
|
|
-- layer[2] Testbench --
|
3 |
|
|
--------------------------------------------------------------------------------
|
4 |
|
|
-- Version: 1.0.0 --
|
5 |
|
|
-- VHDL: 2002 --
|
6 |
|
|
-- Sim: Modelsim 10.0a PE Student Edition --
|
7 |
|
|
-- --
|
8 |
|
|
--------------------------------------------------------------------------------
|
9 |
|
|
-- Copyright (C)2011 Mathias Hörtnagl <mathias.hoertnagl@gmail.comt> --
|
10 |
|
|
-- --
|
11 |
|
|
-- This program is free software: you can redistribute it and/or modify --
|
12 |
|
|
-- it under the terms of the GNU General Public License as published by --
|
13 |
|
|
-- the Free Software Foundation, either version 3 of the License, or --
|
14 |
|
|
-- (at your option) any later version. --
|
15 |
|
|
-- --
|
16 |
|
|
-- This program is distributed in the hope that it will be useful, --
|
17 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
|
18 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --
|
19 |
|
|
-- GNU General Public License for more details. --
|
20 |
|
|
-- --
|
21 |
|
|
-- You should have received a copy of the GNU General Public License --
|
22 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>. --
|
23 |
|
|
--------------------------------------------------------------------------------
|
24 |
|
|
library ieee;
|
25 |
|
|
use ieee.std_logic_1164.all;
|
26 |
|
|
use ieee.numeric_std.all;
|
27 |
|
|
|
28 |
|
|
library work;
|
29 |
|
|
use work.iwb.all;
|
30 |
|
|
use work.iwbm.all;
|
31 |
|
|
use work.icon.all;
|
32 |
|
|
use work.icpu.all;
|
33 |
|
|
use work.imem.all;
|
34 |
|
|
use work.iflash.all;
|
35 |
|
|
-- use work.iddr.all;
|
36 |
|
|
use work.ivga.all;
|
37 |
|
|
use work.ikeyb.all;
|
38 |
|
|
use work.ipit.all;
|
39 |
|
|
use work.iuart.all;
|
40 |
|
|
|
41 |
|
|
entity tb_icon is
|
42 |
|
|
end tb_icon;
|
43 |
|
|
|
44 |
|
|
architecture tb of tb_icon is
|
45 |
|
|
|
46 |
|
|
constant SIZE : positive := 11; -- address bus size
|
47 |
|
|
constant BUSS : positive := 32; -- address bus width
|
48 |
|
|
constant GRAN : positive := 8; -- granularity
|
49 |
|
|
|
50 |
|
|
signal SF_OE : std_logic;
|
51 |
|
|
signal SF_CE : std_logic;
|
52 |
|
|
signal SF_WE : std_logic;
|
53 |
|
|
signal SF_BYTE : std_logic;
|
54 |
|
|
-- signal SF_STS : in std_logic;
|
55 |
|
|
signal SF_A : std_logic_vector(23 downto 0);
|
56 |
|
|
signal SF_D : std_logic_vector(7 downto 0);
|
57 |
|
|
signal PF_OE : std_logic;
|
58 |
|
|
signal LCD_RW : std_logic;
|
59 |
|
|
signal LCD_E : std_logic;
|
60 |
|
|
signal SPI_ROM_CS : std_logic;
|
61 |
|
|
signal SPI_ADC_CONV : std_logic;
|
62 |
|
|
signal SPI_DAC_CS : std_logic;
|
63 |
|
|
|
64 |
|
|
signal SD_CK_N : std_logic;
|
65 |
|
|
signal SD_CK_P : std_logic;
|
66 |
|
|
signal SD_CKE : std_logic;
|
67 |
|
|
signal SD_BA : std_logic_vector(1 downto 0);
|
68 |
|
|
signal SD_A : std_logic_vector(12 downto 0);
|
69 |
|
|
signal SD_CMD : std_logic_vector(3 downto 0);
|
70 |
|
|
signal SD_DM : std_logic_vector(1 downto 0);
|
71 |
|
|
signal SD_DQS : std_logic_vector(1 downto 0);
|
72 |
|
|
signal SD_DQ : std_logic_vector(15 downto 0);
|
73 |
|
|
|
74 |
|
|
signal VGA_HSYNC : std_logic;
|
75 |
|
|
signal VGA_VSYNC : std_logic;
|
76 |
|
|
signal VGA_RED : std_logic;
|
77 |
|
|
signal VGA_GREEN : std_logic;
|
78 |
|
|
signal VGA_BLUE : std_logic;
|
79 |
|
|
|
80 |
|
|
signal PS2_CLK : std_logic;
|
81 |
|
|
signal PS2_DATA : std_logic;
|
82 |
|
|
|
83 |
|
|
signal RS232_DCE_RXD : std_logic;
|
84 |
|
|
signal RS232_DCE_TXD : std_logic;
|
85 |
|
|
|
86 |
|
|
signal ci : cpu_in_t;
|
87 |
|
|
signal co : cpu_out_t;
|
88 |
|
|
signal mi : master_in_t;
|
89 |
|
|
signal mo : master_out_t;
|
90 |
|
|
|
91 |
|
|
signal irq : std_logic_vector(7 downto 0);
|
92 |
|
|
signal pit_intr : std_logic;
|
93 |
|
|
|
94 |
|
|
signal brami, flasi, ddri, dispi, keybi, piti, uartri, uartti : slave_in_t;
|
95 |
|
|
signal bramo, flaso, ddro, dispo, keybo, pito, uartro, uartto : slave_out_t;
|
96 |
|
|
|
97 |
|
|
signal LED : std_logic_vector(7 downto 0);
|
98 |
|
|
|
99 |
|
|
signal CLK50_I : std_logic;
|
100 |
|
|
signal CLK25_I : std_logic;
|
101 |
|
|
signal CLK25P90_I : std_logic;
|
102 |
|
|
constant clk50_period : time := 20 ns;
|
103 |
|
|
|
104 |
|
|
signal RST_I : std_logic;
|
105 |
|
|
begin
|
106 |
|
|
|
107 |
|
|
irq <= "0000000" & pit_intr;
|
108 |
|
|
|
109 |
|
|
clk50 : process
|
110 |
|
|
begin
|
111 |
|
|
CLK50_I <= '0';
|
112 |
|
|
CLK25_I <= '0';
|
113 |
|
|
CLK25P90_I <= '1';
|
114 |
|
|
wait for clk50_period / 4;
|
115 |
|
|
CLK50_I <= '1';
|
116 |
|
|
CLK25_I <= '0';
|
117 |
|
|
CLK25P90_I <= '0';
|
118 |
|
|
wait for clk50_period / 4;
|
119 |
|
|
CLK50_I <= '0';
|
120 |
|
|
CLK25_I <= '1';
|
121 |
|
|
CLK25P90_I <= '0';
|
122 |
|
|
wait for clk50_period / 4;
|
123 |
|
|
CLK50_I <= '1';
|
124 |
|
|
CLK25_I <= '1';
|
125 |
|
|
CLK25P90_I <= '1';
|
126 |
|
|
wait for clk50_period / 4;
|
127 |
|
|
end process;
|
128 |
|
|
|
129 |
|
|
-----------------------------------------------------------------------------
|
130 |
|
|
-- MIPS I Cpu --
|
131 |
|
|
-----------------------------------------------------------------------------
|
132 |
|
|
cpu0 : cpu port map(
|
133 |
|
|
ci => ci,
|
134 |
|
|
co => co
|
135 |
|
|
);
|
136 |
|
|
|
137 |
|
|
-----------------------------------------------------------------------------
|
138 |
|
|
-- Cpu's Wishbone Master --
|
139 |
|
|
-----------------------------------------------------------------------------
|
140 |
|
|
uut1 : wbm port map(
|
141 |
|
|
ci => ci,
|
142 |
|
|
co => co,
|
143 |
|
|
mi => mi,
|
144 |
|
|
mo => mo,
|
145 |
|
|
LED => LED,
|
146 |
|
|
irq => irq
|
147 |
|
|
);
|
148 |
|
|
|
149 |
|
|
-----------------------------------------------------------------------------
|
150 |
|
|
-- Block Memory --
|
151 |
|
|
-----------------------------------------------------------------------------
|
152 |
|
|
-- NOTE: The starting point of execution.
|
153 |
|
|
mem0 : mem
|
154 |
|
|
port map(
|
155 |
|
|
si => brami,
|
156 |
|
|
so => bramo
|
157 |
|
|
);
|
158 |
|
|
|
159 |
|
|
-----------------------------------------------------------------------------
|
160 |
|
|
-- Flash Memory --
|
161 |
|
|
-----------------------------------------------------------------------------
|
162 |
|
|
flas : flash port map(
|
163 |
|
|
si => flasi,
|
164 |
|
|
so => flaso,
|
165 |
|
|
-- Non Wishbone Signals
|
166 |
|
|
SF_OE => SF_OE,
|
167 |
|
|
SF_CE => SF_CE,
|
168 |
|
|
SF_WE => SF_WE,
|
169 |
|
|
SF_BYTE => SF_BYTE,
|
170 |
|
|
--SF_STS => SF_STS,
|
171 |
|
|
SF_A => SF_A,
|
172 |
|
|
SF_D => SF_D,
|
173 |
|
|
PF_OE => PF_OE,
|
174 |
|
|
LCD_RW => LCD_RW,
|
175 |
|
|
LCD_E => LCD_E,
|
176 |
|
|
SPI_ROM_CS => SPI_ROM_CS,
|
177 |
|
|
SPI_ADC_CONV => SPI_ADC_CONV,
|
178 |
|
|
SPI_DAC_CS => SPI_DAC_CS
|
179 |
|
|
);
|
180 |
|
|
|
181 |
|
|
-----------------------------------------------------------------------------
|
182 |
|
|
-- DDR2 Memory --
|
183 |
|
|
-----------------------------------------------------------------------------
|
184 |
|
|
-- ddr2 : ddr port map(
|
185 |
|
|
-- si => ddri,
|
186 |
|
|
-- so => ddro,
|
187 |
|
|
--Non Wishbone Signals
|
188 |
|
|
-- clk0 => CLK25_I,
|
189 |
|
|
-- clk90 => CLK25P90_I,
|
190 |
|
|
-- SD_CK_N => SD_CK_N,
|
191 |
|
|
-- SD_CK_P => SD_CK_P,
|
192 |
|
|
-- SD_CKE => SD_CKE,
|
193 |
|
|
-- SD_BA => SD_BA,
|
194 |
|
|
-- SD_A => SD_A,
|
195 |
|
|
-- SD_CMD => SD_CMD,
|
196 |
|
|
-- SD_DM => SD_DM,
|
197 |
|
|
-- SD_DQS => SD_DQS,
|
198 |
|
|
-- SD_DQ => SD_DQ
|
199 |
|
|
-- );
|
200 |
|
|
|
201 |
|
|
-----------------------------------------------------------------------------
|
202 |
|
|
-- VGA 100x37 Text Display --
|
203 |
|
|
-----------------------------------------------------------------------------
|
204 |
|
|
disp : vga port map(
|
205 |
|
|
si => dispi,
|
206 |
|
|
so => dispo,
|
207 |
|
|
-- Non Wishbone Signals
|
208 |
|
|
VGA_HSYNC => VGA_HSYNC,
|
209 |
|
|
VGA_VSYNC => VGA_VSYNC,
|
210 |
|
|
VGA_RED => VGA_RED,
|
211 |
|
|
VGA_GREEN => VGA_GREEN,
|
212 |
|
|
VGA_BLUE => VGA_BLUE
|
213 |
|
|
);
|
214 |
|
|
|
215 |
|
|
-----------------------------------------------------------------------------
|
216 |
|
|
-- Keyboard --
|
217 |
|
|
-----------------------------------------------------------------------------
|
218 |
|
|
key : keyb port map(
|
219 |
|
|
si => keybi,
|
220 |
|
|
so => keybo,
|
221 |
|
|
-- Non-Wishbone Signals
|
222 |
|
|
PS2_CLK => PS2_CLK,
|
223 |
|
|
PS2_DATA => PS2_DATA,
|
224 |
|
|
intr => open
|
225 |
|
|
);
|
226 |
|
|
|
227 |
|
|
-----------------------------------------------------------------------------
|
228 |
|
|
-- Programmable Intervall Timer --
|
229 |
|
|
-----------------------------------------------------------------------------
|
230 |
|
|
pit0 : pit port map(
|
231 |
|
|
si => piti,
|
232 |
|
|
so => pito,
|
233 |
|
|
-- Non-Wishbone Signals
|
234 |
|
|
intr => pit_intr
|
235 |
|
|
);
|
236 |
|
|
|
237 |
|
|
-----------------------------------------------------------------------------
|
238 |
|
|
-- RS-232 Receiver --
|
239 |
|
|
-----------------------------------------------------------------------------
|
240 |
|
|
recv : uartr port map(
|
241 |
|
|
si => uartri,
|
242 |
|
|
so => uartro,
|
243 |
|
|
-- Non-Wishbone Signals
|
244 |
|
|
RS232_DCE_RXD => RS232_DCE_RXD
|
245 |
|
|
);
|
246 |
|
|
|
247 |
|
|
-----------------------------------------------------------------------------
|
248 |
|
|
-- RS-232 Transmitter --
|
249 |
|
|
-----------------------------------------------------------------------------
|
250 |
|
|
send : uartt port map(
|
251 |
|
|
si => uartti,
|
252 |
|
|
so => uartto,
|
253 |
|
|
-- Non-Wishbone Signals
|
254 |
|
|
RS232_DCE_TXD => RS232_DCE_TXD
|
255 |
|
|
);
|
256 |
|
|
|
257 |
|
|
-----------------------------------------------------------------------------
|
258 |
|
|
-- Shared Bus --
|
259 |
|
|
-----------------------------------------------------------------------------
|
260 |
|
|
sbus : intercon port map(
|
261 |
|
|
CLK50_I => CLK50_I,
|
262 |
|
|
CLK25_I => CLK25_I,
|
263 |
|
|
RST_I => RST_I,
|
264 |
|
|
mi => mi,
|
265 |
|
|
mo => mo,
|
266 |
|
|
brami => brami,
|
267 |
|
|
bramo => bramo,
|
268 |
|
|
flasi => flasi,
|
269 |
|
|
flaso => flaso,
|
270 |
|
|
ddri => ddri,
|
271 |
|
|
ddro => ddro,
|
272 |
|
|
dispi => dispi,
|
273 |
|
|
dispo => dispo,
|
274 |
|
|
keybi => keybi,
|
275 |
|
|
keybo => keybo,
|
276 |
|
|
piti => piti,
|
277 |
|
|
pito => pito,
|
278 |
|
|
uartri => uartri,
|
279 |
|
|
uartro => uartro,
|
280 |
|
|
uartti => uartti,
|
281 |
|
|
uartto => uartto
|
282 |
|
|
);
|
283 |
|
|
|
284 |
|
|
sti : process
|
285 |
|
|
begin
|
286 |
|
|
RST_I <= '1';
|
287 |
|
|
wait for 3*clk50_period/2;
|
288 |
|
|
RST_I <= '0';
|
289 |
|
|
wait; -- Important: no wait, no simulation.
|
290 |
|
|
end process;
|
291 |
|
|
end tb;
|