| 1 |
9 |
steckol |
-------------------------------------------------------------------------------
|
| 2 |
|
|
--
|
| 3 |
|
|
-- Design: tinyVLIW8 soft-core processor
|
| 4 |
|
|
-- Author: Oliver Stecklina <stecklina@ihp-microelectronics.com>
|
| 5 |
|
|
-- Date: 24.10.2013
|
| 6 |
|
|
-- File: sysArch_tb.vhd
|
| 7 |
|
|
--
|
| 8 |
|
|
-------------------------------------------------------------------------------
|
| 9 |
|
|
--
|
| 10 |
|
|
-- Description : System architecture testbench. Using a ROM initialized by
|
| 11 |
|
|
-- ihex file to simplify system tests.
|
| 12 |
|
|
--
|
| 13 |
|
|
-------------------------------------------------------------------------------
|
| 14 |
|
|
--
|
| 15 |
|
|
-- Copyright (C) 2015 IHP GmbH, Frankfurt (Oder), Germany
|
| 16 |
|
|
--
|
| 17 |
|
|
-- This code is free software. It is licensed under the EUPL, Version 1.1
|
| 18 |
|
|
-- or - as soon they will be approved by the European Commission - subsequent
|
| 19 |
|
|
-- versions of the EUPL (the "License").
|
| 20 |
|
|
-- You may redistribute this code and/or modify it under the terms of this
|
| 21 |
|
|
-- License.
|
| 22 |
|
|
-- You may not use this work except in compliance with the License.
|
| 23 |
|
|
-- You may obtain a copy of the License at:
|
| 24 |
|
|
--
|
| 25 |
|
|
-- http://joinup.ec.europa.eu/software/page/eupl/licence-eupl
|
| 26 |
|
|
--
|
| 27 |
|
|
-- Unless required by applicable law or agreed to in writing, software
|
| 28 |
|
|
-- distributed under the License is distributed on an "AS IS" basis,
|
| 29 |
|
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 30 |
|
|
-- See the License for the specific language governing permissions and
|
| 31 |
|
|
-- limitations under the License.
|
| 32 |
|
|
--
|
| 33 |
|
|
-------------------------------------------------------------------------------
|
| 34 |
|
|
|
| 35 |
3 |
steckol |
library IEEE;
|
| 36 |
|
|
use IEEE.std_logic_1164.all;
|
| 37 |
|
|
|
| 38 |
|
|
entity sysArch_tb is
|
| 39 |
|
|
end sysArch_tb;
|
| 40 |
|
|
|
| 41 |
|
|
architecture beh of sysArch_tb is
|
| 42 |
|
|
|
| 43 |
|
|
component sysArch
|
| 44 |
|
|
port (
|
| 45 |
|
|
-- clock input
|
| 46 |
|
|
clk : in std_logic;
|
| 47 |
|
|
|
| 48 |
|
|
-- instruction bus
|
| 49 |
|
|
instMemAddr : out std_logic_vector(10 downto 0);
|
| 50 |
|
|
instMemDataIn : in std_logic_vector(31 downto 0);
|
| 51 |
|
|
instMemEn_n : out std_logic;
|
| 52 |
|
|
|
| 53 |
|
|
-- data bus
|
| 54 |
|
|
dataMemAddr : out std_logic_vector(7 downto 0);
|
| 55 |
|
|
dataMemDataIn : in std_logic_vector(7 downto 0);
|
| 56 |
|
|
dataMemDataOut : out std_logic_vector(7 downto 0);
|
| 57 |
|
|
dataMemEn_n : out std_logic;
|
| 58 |
|
|
dataMemWr_n : out std_logic;
|
| 59 |
|
|
|
| 60 |
|
|
ioAddr : out std_logic_vector(7 downto 0);
|
| 61 |
|
|
ioDataIn : in std_logic_vector(7 downto 0);
|
| 62 |
|
|
ioDataOut : out std_logic_vector(7 downto 0);
|
| 63 |
|
|
ioWrEn_n : out std_logic;
|
| 64 |
|
|
ioRdEn_n : out std_logic;
|
| 65 |
|
|
|
| 66 |
|
|
-- interrupt handling
|
| 67 |
|
|
irqLine : in std_logic;
|
| 68 |
|
|
irqLineAck : out std_logic;
|
| 69 |
|
|
|
| 70 |
|
|
-- general purpose IO
|
| 71 |
|
|
gpio_in : in std_logic_vector(7 downto 0);
|
| 72 |
|
|
gpio_out : out std_logic_vector(7 downto 0);
|
| 73 |
|
|
gpio_dir : out std_logic_vector(7 downto 0);
|
| 74 |
|
|
|
| 75 |
|
|
spi_clk : OUT STD_LOGIC; -- SPI clock
|
| 76 |
|
|
spi_cs : OUT STD_LOGIC; -- SPI slave select, active level configurable
|
| 77 |
|
|
spi_mosi : OUT STD_LOGIC; -- SPI master output, slave input
|
| 78 |
|
|
spi_miso : IN STD_LOGIC; -- SPI master input, slave output
|
| 79 |
|
|
|
| 80 |
|
|
stall_n : in std_logic;
|
| 81 |
|
|
stalled_n : out std_logic;
|
| 82 |
|
|
|
| 83 |
|
|
-- reset input
|
| 84 |
|
|
rst_n : in std_logic
|
| 85 |
|
|
);
|
| 86 |
|
|
end component;
|
| 87 |
|
|
|
| 88 |
|
|
component lib_tb_clock32kHz is
|
| 89 |
|
|
port (
|
| 90 |
|
|
signal clk : out std_logic;
|
| 91 |
|
|
signal rst_n : out std_logic
|
| 92 |
|
|
);
|
| 93 |
|
|
end component;
|
| 94 |
|
|
|
| 95 |
|
|
component dataMem
|
| 96 |
|
|
PORT (
|
| 97 |
|
|
address : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
|
| 98 |
|
|
data : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
|
| 99 |
|
|
inclock : IN STD_LOGIC;
|
| 100 |
|
|
outclock : IN STD_LOGIC;
|
| 101 |
|
|
wren : IN STD_LOGIC;
|
| 102 |
|
|
q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
|
| 103 |
|
|
);
|
| 104 |
|
|
end component dataMem;
|
| 105 |
|
|
|
| 106 |
|
|
component lib_tb_rom32bit is
|
| 107 |
|
|
generic ( fileName : string );
|
| 108 |
|
|
port (
|
| 109 |
|
|
signal addr : in std_logic_vector(10 downto 0);
|
| 110 |
|
|
signal dataOut : out std_logic_vector(31 downto 0);
|
| 111 |
|
|
signal en_n : in std_logic
|
| 112 |
|
|
);
|
| 113 |
|
|
end component;
|
| 114 |
|
|
|
| 115 |
|
|
component gendelay
|
| 116 |
|
|
generic (n: integer := 1);
|
| 117 |
|
|
port (
|
| 118 |
|
|
a_in : in std_logic;
|
| 119 |
|
|
a_out : out std_logic
|
| 120 |
|
|
);
|
| 121 |
|
|
end component;
|
| 122 |
|
|
|
| 123 |
|
|
signal clk_s : std_logic;
|
| 124 |
|
|
|
| 125 |
|
|
signal dataAddr_s : std_logic_vector(7 downto 0);
|
| 126 |
|
|
signal dataIn_s : std_logic_vector(7 downto 0);
|
| 127 |
|
|
signal dataOut_s : std_logic_vector(7 downto 0);
|
| 128 |
|
|
signal dataEn_n_s : std_logic;
|
| 129 |
|
|
signal dataEnDly_n_s : std_logic;
|
| 130 |
|
|
signal dataWr_n_s : std_logic;
|
| 131 |
|
|
signal dataWr_s : std_logic;
|
| 132 |
|
|
|
| 133 |
|
|
signal instAddr_s : std_logic_vector(10 downto 0);
|
| 134 |
|
|
signal instData_s : std_logic_vector(31 downto 0);
|
| 135 |
|
|
signal instEn_n_s : std_logic;
|
| 136 |
|
|
|
| 137 |
|
|
signal gpio_in_s : std_logic_vector(7 downto 0);
|
| 138 |
|
|
signal gpio_out_s : std_logic_vector(7 downto 0);
|
| 139 |
|
|
signal gpio_dir_s : std_logic_vector(7 downto 0);
|
| 140 |
|
|
|
| 141 |
|
|
signal stall_n_s : std_logic := '1';
|
| 142 |
|
|
signal stalled_n_s : std_logic;
|
| 143 |
|
|
|
| 144 |
|
|
signal ioAddr_s : std_logic_vector(7 downto 0) := (others => '0');
|
| 145 |
|
|
signal ioDataIn_s : std_logic_vector(7 downto 0) := (others => '0');
|
| 146 |
|
|
signal ioDataOut_s : std_logic_vector(7 downto 0);
|
| 147 |
|
|
signal ioWrEn_n_s : std_logic := '1';
|
| 148 |
|
|
signal ioRdEn_n_s : std_logic := '1';
|
| 149 |
|
|
|
| 150 |
|
|
signal irqLine_s : std_logic;
|
| 151 |
|
|
signal irqLineAck_s : std_logic := '0';
|
| 152 |
|
|
|
| 153 |
|
|
signal spiClk_s : std_logic;
|
| 154 |
|
|
signal spiCs_s : std_logic;
|
| 155 |
|
|
signal spiMosi_s : std_logic;
|
| 156 |
|
|
signal spiMiso_s : std_logic := '0';
|
| 157 |
|
|
|
| 158 |
|
|
signal dataInClk_s : std_logic;
|
| 159 |
|
|
signal dataOutClk_s : std_logic;
|
| 160 |
|
|
|
| 161 |
|
|
signal rst_n_s : std_logic := '1';
|
| 162 |
|
|
|
| 163 |
|
|
begin
|
| 164 |
|
|
|
| 165 |
|
|
sysArch_i : sysArch
|
| 166 |
|
|
port map(
|
| 167 |
|
|
clk => clk_s,
|
| 168 |
|
|
|
| 169 |
|
|
-- instruction bus
|
| 170 |
|
|
instMemAddr => instAddr_s,
|
| 171 |
|
|
instMemDataIn => instData_s,
|
| 172 |
|
|
instMemEn_n => instEn_n_s,
|
| 173 |
|
|
|
| 174 |
|
|
-- data bus
|
| 175 |
|
|
dataMemAddr => dataAddr_s,
|
| 176 |
|
|
dataMemDataIn => dataIn_s,
|
| 177 |
|
|
dataMemDataOut => dataOut_s,
|
| 178 |
|
|
dataMemEn_n => dataEn_n_s,
|
| 179 |
|
|
dataMemWr_n => dataWr_n_s,
|
| 180 |
|
|
|
| 181 |
|
|
ioAddr => ioAddr_s,
|
| 182 |
|
|
ioDataIn => ioDataIn_s,
|
| 183 |
|
|
ioDataOut => ioDataOut_s,
|
| 184 |
|
|
ioWrEn_n => ioWrEn_n_s,
|
| 185 |
|
|
ioRdEn_n => ioRdEn_n_s,
|
| 186 |
|
|
|
| 187 |
|
|
irqLine => irqLine_s,
|
| 188 |
|
|
irqLineAck => irqLineAck_s,
|
| 189 |
|
|
|
| 190 |
|
|
-- general purpose IO
|
| 191 |
|
|
gpio_in => gpio_in_s,
|
| 192 |
|
|
gpio_out => gpio_out_s,
|
| 193 |
|
|
gpio_dir => gpio_dir_s,
|
| 194 |
|
|
|
| 195 |
|
|
spi_clk => spiClk_s,
|
| 196 |
|
|
spi_cs => spiCs_s,
|
| 197 |
|
|
spi_mosi => spiMosi_s,
|
| 198 |
|
|
spi_miso => spiMiso_s,
|
| 199 |
|
|
|
| 200 |
|
|
stall_n => stall_n_s,
|
| 201 |
|
|
stalled_n => stalled_n_s,
|
| 202 |
|
|
|
| 203 |
|
|
rst_n => rst_n_s
|
| 204 |
|
|
);
|
| 205 |
|
|
|
| 206 |
|
|
tb_clock32kHz_i: lib_tb_clock32kHz
|
| 207 |
|
|
port map (
|
| 208 |
|
|
clk => clk_s,
|
| 209 |
|
|
rst_n => rst_n_s
|
| 210 |
|
|
);
|
| 211 |
|
|
|
| 212 |
|
|
tb_rom32bit_i: lib_tb_rom32bit
|
| 213 |
9 |
steckol |
generic map ( fileName => "../opencores/tinyvliw8/tinyvliw8/trunk/programs/timerIrq.ihex" )
|
| 214 |
3 |
steckol |
port map (
|
| 215 |
|
|
addr => instAddr_s,
|
| 216 |
|
|
dataOut => instData_s,
|
| 217 |
|
|
en_n => instEn_n_s
|
| 218 |
|
|
);
|
| 219 |
|
|
|
| 220 |
|
|
dataMem_i : dataMem
|
| 221 |
|
|
port map (
|
| 222 |
|
|
address => dataAddr_s,
|
| 223 |
|
|
data => dataOut_s,
|
| 224 |
|
|
inclock => dataInClk_s,
|
| 225 |
|
|
outclock => dataOutClk_s,
|
| 226 |
|
|
wren => dataWr_s,
|
| 227 |
|
|
q => dataIn_s
|
| 228 |
|
|
);
|
| 229 |
|
|
|
| 230 |
|
|
dataWr_s <= not(dataWr_n_s);
|
| 231 |
|
|
|
| 232 |
|
|
dataMemOutClk_delay_i: gendelay
|
| 233 |
|
|
generic map (n => 5)
|
| 234 |
|
|
port map (
|
| 235 |
|
|
a_in => dataEn_n_s,
|
| 236 |
|
|
a_out => dataEnDly_n_s
|
| 237 |
|
|
);
|
| 238 |
|
|
|
| 239 |
|
|
dataInClk_s <= '1' when (dataEn_n_s = '0' and dataEnDly_n_s = '1' and dataWr_n_s = '1') or
|
| 240 |
|
|
(dataEn_n_s = '0' and dataEnDly_n_s = '0' and dataWr_n_s = '0') else
|
| 241 |
|
|
'0';
|
| 242 |
|
|
dataOutClk_s <= not(dataInClk_s);
|
| 243 |
|
|
|
| 244 |
|
|
end beh;
|
| 245 |
|
|
|