1 |
2 |
__alexs__ |
-- --------------------------------------------------------------------------
|
2 |
|
|
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
3 |
|
|
-- --------------------------------------------------------------------------
|
4 |
|
|
-- TITLE: Plasma TESTBENCH
|
5 |
|
|
-- AUTHOR: Alex Schoenberger (Alex.Schoenberger@ies.tu-darmstadt.de)
|
6 |
|
|
-- COMMENT: This project is based on Plasma CPU core by Steve Rhoads
|
7 |
|
|
--
|
8 |
|
|
-- www.ies.tu-darmstadt.de
|
9 |
|
|
-- TU Darmstadt
|
10 |
|
|
-- Institute for Integrated Systems
|
11 |
|
|
-- Merckstr. 25
|
12 |
|
|
--
|
13 |
|
|
-- 64283 Darmstadt - GERMANY
|
14 |
|
|
-- --------------------------------------------------------------------------
|
15 |
|
|
-- PROJECT: Plasma CPU core with FPU
|
16 |
|
|
-- FILENAME: tb_plasma.vhd
|
17 |
|
|
-- --------------------------------------------------------------------------
|
18 |
|
|
-- COPYRIGHT:
|
19 |
|
|
-- This project is distributed by GPLv2.0
|
20 |
|
|
-- Software placed into the public domain by the author.
|
21 |
|
|
-- Software 'as is' without warranty. Author liable for nothing.
|
22 |
|
|
-- --------------------------------------------------------------------------
|
23 |
|
|
-- DESCRIPTION:
|
24 |
|
|
-- plasma platform test
|
25 |
|
|
--
|
26 |
|
|
-- NOT SYNTHESIZABLE
|
27 |
|
|
--
|
28 |
|
|
----------------------------------------------------------------------------
|
29 |
|
|
-- Revision History
|
30 |
|
|
-- --------------------------------------------------------------------------
|
31 |
|
|
-- Revision Date Author CHANGES
|
32 |
|
|
-- 1.0 8/2014 AS initial
|
33 |
|
|
-- --------------------------------------------------------------------------
|
34 |
|
|
library IEEE;
|
35 |
|
|
use IEEE.std_logic_1164.ALL;
|
36 |
|
|
|
37 |
|
|
library PLASMA;
|
38 |
|
|
use PLASMA.plasma_pack.ALL;
|
39 |
|
|
|
40 |
|
|
library MEMORY;
|
41 |
|
|
use MEMORY.plasma_memory_pack.plasma_memory;
|
42 |
|
|
|
43 |
|
|
entity tb_plasma is
|
44 |
|
|
generic(
|
45 |
|
|
-- test architecture
|
46 |
|
|
SIM_FLAG : string := "ON"; -- simulation model
|
47 |
|
|
FPU_FLAG : string := "OF"; -- FPU integrated
|
48 |
|
|
|
49 |
|
|
-- debugging
|
50 |
|
|
DEBUG_FLAG : string := "OF" -- verbose debugging output
|
51 |
|
|
);
|
52 |
|
|
end entity tb_plasma;
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
architecture behav_tb_plasma of tb_plasma is
|
56 |
|
|
|
57 |
|
|
-- -------- SIMULATION CONSTANTS -----
|
58 |
|
|
constant CLK_TIME : time := 500 ps;
|
59 |
|
|
constant RST_TIME : time := 3 ns;
|
60 |
|
|
|
61 |
|
|
constant INIT_RISE : time := 1 ns;
|
62 |
|
|
constant SIGNAl_ACTIVE : time := 2 ns;
|
63 |
|
|
|
64 |
|
|
-- -------- PLASMA INTERFACE --------
|
65 |
|
|
signal clk : std_logic := '0';
|
66 |
|
|
signal rst : std_logic;
|
67 |
|
|
signal instr_addr : std_logic_vector(31 downto 0);
|
68 |
|
|
signal data_addr : std_logic_vector(31 downto 0);
|
69 |
|
|
signal rd_mask : std_logic_vector(3 downto 0);
|
70 |
|
|
signal wr_mask : std_logic_vector(3 downto 0);
|
71 |
|
|
signal instr_stall : std_logic;
|
72 |
|
|
signal data_stall : std_logic;
|
73 |
|
|
signal instr_in : std_logic_vector(31 downto 0);
|
74 |
|
|
signal data_to_cpu : std_logic_vector(31 downto 0);
|
75 |
|
|
signal data_from_cpu : std_logic_vector(31 downto 0);
|
76 |
|
|
|
77 |
|
|
-- ------ MEMORY INIT ----------------------
|
78 |
|
|
signal init : std_logic := '0';
|
79 |
|
|
|
80 |
|
|
-- ------ SIMULATION CONTROL ---------------
|
81 |
|
|
signal sim_enable : std_logic := '0';
|
82 |
|
|
signal sim_finish : std_logic;
|
83 |
|
|
|
84 |
|
|
signal exec_done : std_logic;
|
85 |
|
|
signal ff_exec_done : std_logic;
|
86 |
|
|
|
87 |
|
|
begin ---------------- BEGIN ------------------ BEGIN -------------------------
|
88 |
|
|
--
|
89 |
|
|
-- GENERAL CONTROL SIGNAL
|
90 |
|
|
--
|
91 |
|
|
clk <= not clk after CLK_TIME;
|
92 |
|
|
rst <= '1', '0' after RST_TIME;
|
93 |
|
|
|
94 |
|
|
--
|
95 |
|
|
-- NO cache -> no external stalls
|
96 |
|
|
--
|
97 |
|
|
instr_stall <= '0';
|
98 |
|
|
data_stall <= '0';
|
99 |
|
|
|
100 |
|
|
-- ____ ___ _ _
|
101 |
|
|
-- | |__] | |
|
102 |
|
|
-- |___ | |__|
|
103 |
|
|
u1_cpu: entity PLASMA.plasma
|
104 |
|
|
GENERIC MAP(
|
105 |
|
|
core_idx => 0,
|
106 |
|
|
SIM_FLAG => SIM_FLAG,
|
107 |
|
|
FPU_FLAG => FPU_FLAG, DEBUG_FLAG => DEBUG_FLAG
|
108 |
|
|
)
|
109 |
|
|
PORT MAP(
|
110 |
|
|
clk => clk, rst => rst,
|
111 |
|
|
instr_in => instr_in, data_to_cpu => data_to_cpu,
|
112 |
|
|
instr_stall => instr_stall, data_stall => data_stall,
|
113 |
|
|
instr_addr => instr_addr, data_addr => data_addr,
|
114 |
|
|
rd_mask => rd_mask, wr_mask => wr_mask,
|
115 |
|
|
data_from_cpu => data_from_cpu
|
116 |
|
|
);
|
117 |
|
|
|
118 |
|
|
-- _ _ ____ _ _ ____ ____ _ _
|
119 |
|
|
-- |\/| |___ |\/| | | |__/ \_/
|
120 |
|
|
-- | | |___ | | |__| | \ |
|
121 |
|
|
u2_memory: entity MEMORY.plasma_memory
|
122 |
|
|
PORT MAP(
|
123 |
|
|
clk => clk, reset => rst,
|
124 |
|
|
wr_mask => wr_mask, rd_mask => rd_mask,
|
125 |
|
|
prog_addr => instr_addr, data_addr => data_addr,
|
126 |
|
|
prog_out => instr_in, data_in => data_from_cpu,
|
127 |
|
|
data_out => data_to_cpu
|
128 |
|
|
);
|
129 |
|
|
|
130 |
|
|
--
|
131 |
|
|
-- debugging
|
132 |
|
|
--
|
133 |
|
|
debug_prog_addr <= instr_addr;
|
134 |
|
|
|
135 |
|
|
-- --------------------------------------------------------------------------
|
136 |
|
|
-- ____ _ _ _ _ _ _ ____ ___ _ ____ _ _ ____ ____ _ _ ___ ____ ____ _
|
137 |
|
|
-- [__ | |\/| | | | |__| | | | | |\ | | | | |\ | | |__/ | | |
|
138 |
|
|
-- ___] | | | |__| |___ | | | | |__| | \| |___ |__| | \| | | \ |__| |___
|
139 |
|
|
--
|
140 |
|
|
-- activate simulation control
|
141 |
|
|
--
|
142 |
|
|
sim_enable <= '1' after INIT_RISE;
|
143 |
|
|
|
144 |
|
|
--
|
145 |
|
|
-- get simulation control signals
|
146 |
|
|
--
|
147 |
|
|
exec_done <= sim_enable when i_sim_control.sim_finish /= '0' else '0';
|
148 |
|
|
|
149 |
|
|
--
|
150 |
|
|
-- algorithm execution done signal is synchron to enable flush
|
151 |
|
|
--
|
152 |
|
|
process(clk)
|
153 |
|
|
begin
|
154 |
|
|
if rising_edge( clk ) then
|
155 |
|
|
if rst = '1' then ff_exec_done <= '0';
|
156 |
|
|
else ff_exec_done <= exec_done;
|
157 |
|
|
end if;
|
158 |
|
|
end if;
|
159 |
|
|
end process;
|
160 |
|
|
|
161 |
|
|
-- --------------------------------------------------------------------------
|
162 |
|
|
-- _ _ ____ _ _ _ ___ ____ ____ ____ ____ ____ ____
|
163 |
|
|
-- |\/| |__| | |\ | |__] |__/ | | | |___ [__ [__
|
164 |
|
|
-- | | | | | | \| | | \ |__| |___ |___ ___] ___]
|
165 |
|
|
test_process:process
|
166 |
|
|
begin
|
167 |
|
|
init <= '0';
|
168 |
|
|
sim_finish <= '0';
|
169 |
|
|
|
170 |
|
|
-- ------- INITIALISE MEMORY -----------------------
|
171 |
|
|
wait for INIT_RISE; init <= '1';
|
172 |
|
|
wait for SIGNAL_ACTIVE; init <= '0';
|
173 |
|
|
-- ------- EXECUTION RUN ---------------------------
|
174 |
|
|
wait until ff_exec_done = '1';
|
175 |
|
|
-- ------- FINISH SIMULATION ----------------------
|
176 |
|
|
sim_finish <= '1';
|
177 |
|
|
wait;
|
178 |
|
|
end process;
|
179 |
|
|
|
180 |
|
|
end architecture behav_tb_plasma;
|