1 |
6 |
root |
--------------------------------------------------------------------------------
|
2 |
|
|
-- Company:
|
3 |
|
|
-- Engineer: Richard Hirsch
|
4 |
|
|
--
|
5 |
|
|
-- Create Date: 09:24:52 08/31/05
|
6 |
|
|
-- Design Name:
|
7 |
|
|
-- Module Name: Cycle_Simulator.vhd - Behavioral
|
8 |
|
|
-- Project Name: HASM
|
9 |
|
|
-- Target Device:
|
10 |
|
|
-- Tool versions: ISE 7.1
|
11 |
|
|
-- Description: This is the VHDL-portion of the HASM assembler. This file
|
12 |
|
|
-- generates generic bus cycles to be used by a bus-specific model. The location
|
13 |
|
|
-- of the vector file containing the HASM-generated vectors is defined by the
|
14 |
|
|
-- vector_filename generic.
|
15 |
|
|
--
|
16 |
|
|
-- Dependencies:
|
17 |
|
|
--
|
18 |
|
|
-- Revision:
|
19 |
|
|
-- Revision 0.01 - File Created
|
20 |
|
|
-- Additional Comments:
|
21 |
|
|
--
|
22 |
|
|
--------------------------------------------------------------------------------
|
23 |
|
|
library IEEE;
|
24 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
25 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
26 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
27 |
|
|
use std.textio.all;
|
28 |
|
|
|
29 |
|
|
-- synthesis translate_off
|
30 |
|
|
library UNISIM;
|
31 |
|
|
use UNISIM.VComponents.all;
|
32 |
|
|
-- synthesis translate_on
|
33 |
|
|
|
34 |
|
|
entity cycle_simulator is
|
35 |
|
|
Generic (
|
36 |
|
|
vector_filename : string := "c:\Ortus\Hasm_vhdl\vectors.vct" -- Vector file to execute
|
37 |
|
|
);
|
38 |
|
|
Port (
|
39 |
|
|
rst : in std_logic; -- System reset
|
40 |
|
|
clk : in std_logic; -- System clock
|
41 |
|
|
|
42 |
|
|
enable_machine : in std_logic; -- Set high to enable HASM machine
|
43 |
|
|
|
44 |
|
|
machine_interrupt : in std_logic; -- Set high to cause jump to .isr
|
45 |
|
|
clr_machine_interrupt: out std_logic; -- Set by HASM to tell bus model to clear
|
46 |
|
|
-- interrupt signal (interrupt acknowledge)
|
47 |
|
|
|
48 |
|
|
cyc_rdwr : out std_logic; -- Cycle type indicator, high when read, low when write
|
49 |
|
|
cyc_rmw : out std_logic; -- Set high after execution of rmw_en, low after rmw_dis
|
50 |
|
|
cyc_siz : out std_logic_vector(1 downto 0); -- Cycle size indicator(00 8-bit, 01 16-bit, 10 32-bit, 11 24-bit)
|
51 |
|
|
cyc_addr : out std_logic_vector(31 downto 0); -- Byte-aligned cycle address
|
52 |
|
|
cyc_data_in : in std_logic_vector(31 downto 0); -- Data-in from bus model
|
53 |
|
|
cyc_data_out : out std_logic_vector(31 downto 0); -- Data-out to bus model
|
54 |
|
|
start_cyc : out std_logic; -- Start cycle indicator to bus model
|
55 |
|
|
cyc_done : in std_logic; -- Cycle done from bus model
|
56 |
|
|
|
57 |
|
|
brst_cyc : out std_logic; -- Burst cycle indicator to bus model
|
58 |
|
|
brst_quantity : out std_logic_vector(31 downto 0); -- Indicates number of R/W cycles in burst
|
59 |
|
|
brst_last : out std_logic; -- Set high on last cycle of burst access
|
60 |
|
|
brst_data_rdy : in std_logic; -- Data ready indicator from bus model
|
61 |
|
|
|
62 |
|
|
reg_user : out std_logic_vector(31 downto 0); -- General purpose register to be used by bus model
|
63 |
|
|
-- following for debug
|
64 |
|
|
instruction_out : out std_logic_vector(31 downto 0); -- Indicates current instruction being executed
|
65 |
|
|
register_out : out std_logic_vector(31 downto 0); -- Indicates target register of current instruction
|
66 |
|
|
literal_out : out std_logic_vector(31 downto 0); -- Indicates literal value of current instruction
|
67 |
|
|
next_inst : out std_logic_vector(31 downto 0) -- Indicates address of next instruction to be executed
|
68 |
|
|
|
69 |
|
|
);
|
70 |
|
|
end cycle_simulator;
|
71 |
|
|
|
72 |
|
|
architecture Behavioral of cycle_simulator is
|
73 |
|
|
|
74 |
|
|
signal registera: std_logic_vector(31 downto 0);
|
75 |
|
|
signal registerb: std_logic_vector(31 downto 0);
|
76 |
|
|
signal registerc: std_logic_vector(31 downto 0);
|
77 |
|
|
signal registerd: std_logic_vector(31 downto 0);
|
78 |
|
|
signal reg_user_int: std_logic_vector(31 downto 0);
|
79 |
|
|
signal register_delay: std_logic_Vector(31 downto 0);
|
80 |
|
|
|
81 |
|
|
type instruction is (load, read, write, comp_e, comp_ne, jump, and_inst, or_inst,
|
82 |
|
|
ret, add, push, pop, call, rdmem, wrmem, rdbrst, wrbrst, wrb,
|
83 |
|
|
wrw, rdb, rdw, rmw_en, rmw_dis, rdt, wrt, rdbrstb, rdbrstw, rdbrstt,
|
84 |
|
|
wrbrstb, wrbrstw, wrbrstt, delay, wri, wrib, wriw, writ, rdi, rdib,
|
85 |
|
|
rdiw, rdit, compi_e, compi_ne, ldrr, shl, shr );
|
86 |
|
|
|
87 |
|
|
signal instruction_state : instruction;
|
88 |
|
|
signal loaded_instruction : instruction;
|
89 |
|
|
type register_type is (rega, regb, regc, regd, reguser);
|
90 |
|
|
signal register_sel : register_type;
|
91 |
|
|
signal literal_value: std_logic_vector(31 downto 0);
|
92 |
|
|
signal data_from_target: std_logic_Vector(31 downto 0);
|
93 |
|
|
signal temp: std_logic_vector(31 downto 0);
|
94 |
|
|
|
95 |
|
|
signal interrupt_cycle: std_logic;
|
96 |
|
|
signal brst_last_int: std_logic;
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
begin
|
101 |
|
|
|
102 |
|
|
reg_user(31 downto 0) <= reg_user_int(31 downto 0);
|
103 |
|
|
brst_last <= brst_last_int;
|
104 |
|
|
|
105 |
|
|
----------------------------------------------
|
106 |
|
|
-- Instruction encoding
|
107 |
|
|
--
|
108 |
|
|
-- ld 0x00000000
|
109 |
|
|
-- rd 0x00000001
|
110 |
|
|
-- wr 0x00000002
|
111 |
|
|
-- cmp_e 0x00000003
|
112 |
|
|
-- cmp_ne 0x00000004
|
113 |
|
|
-- jmp 0x00000005
|
114 |
|
|
-- and 0x00000006
|
115 |
|
|
-- or 0x00000007
|
116 |
|
|
-- ret 0x00000008
|
117 |
|
|
-- add 0x00000009
|
118 |
|
|
-- push 0x0000000a
|
119 |
|
|
-- pop 0x0000000b
|
120 |
|
|
-- call 0x0000000c
|
121 |
|
|
-- rdmem 0x0000000d
|
122 |
|
|
-- wrmem 0x0000000e
|
123 |
|
|
-- rdbrst 0x0000000f
|
124 |
|
|
-- wrbrst 0x00000010
|
125 |
|
|
-- wrb 0x00000011
|
126 |
|
|
-- wrw 0x00000012
|
127 |
|
|
-- rdb 0x00000013
|
128 |
|
|
-- rdw 0x00000014
|
129 |
|
|
-- rmw_en 0x00000015
|
130 |
|
|
-- rmw_dis 0x00000016
|
131 |
|
|
-- rdt 0x00000017
|
132 |
|
|
-- wrt 0x00000018
|
133 |
|
|
-- rdbrstb 0x00000019
|
134 |
|
|
-- rdbrstw 0x0000001a
|
135 |
|
|
-- rdbrstt 0x0000001b
|
136 |
|
|
-- wrbrstb 0x0000001c
|
137 |
|
|
-- wrbrstw 0x0000001d
|
138 |
|
|
-- wrbrstt 0x0000001e
|
139 |
|
|
-- delay 0x0000001f
|
140 |
|
|
-- wri 0x00000020
|
141 |
|
|
-- wrib 0x00000021
|
142 |
|
|
-- wriw 0x00000022
|
143 |
|
|
-- writ 0x00000023
|
144 |
|
|
-- rdi 0x00000024
|
145 |
|
|
-- rdib 0x00000025
|
146 |
|
|
-- rdiw 0x00000026
|
147 |
|
|
-- rdit 0x00000027
|
148 |
|
|
-- cmpie 0x00000028
|
149 |
|
|
-- cmpine 0x00000029
|
150 |
|
|
-- ldrr 0x0000002A
|
151 |
|
|
-- shl 0x0000002B
|
152 |
|
|
-- shr 0x0000002C
|
153 |
|
|
----------------------------------------------
|
154 |
|
|
-- Register encoding
|
155 |
|
|
--
|
156 |
|
|
-- rega 0x00000001
|
157 |
|
|
-- regb 0x00000002
|
158 |
|
|
-- regc 0x00000003
|
159 |
|
|
-- regd 0x00000004
|
160 |
|
|
-- reguser 0x00000005
|
161 |
|
|
-----------------------------------------------
|
162 |
|
|
-- SIZ encoding
|
163 |
|
|
-- 00 Byte wide
|
164 |
|
|
-- 01 Word wide (16-bit)
|
165 |
|
|
-- 10 Long wide (32-bit)
|
166 |
|
|
-- 11 Triple wide(24-bit)
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
run_instructions: process is
|
172 |
|
|
file vector_file: text;
|
173 |
|
|
variable instruction_offset: integer := 0;
|
174 |
|
|
variable next_instruction: integer := 0;
|
175 |
|
|
variable machine_interrupt_a_vector : integer := 31; -- Jumps to this offset when interrupted
|
176 |
|
|
variable stack : integer := 0;
|
177 |
|
|
variable stack_a : integer := 0;
|
178 |
|
|
variable L : line;
|
179 |
|
|
variable ch: character;
|
180 |
|
|
variable time_delay : integer := 0;
|
181 |
|
|
|
182 |
|
|
variable instruction_type : integer := 0;
|
183 |
|
|
variable register_select : integer := 0;
|
184 |
|
|
variable lit_val : integer := 0;
|
185 |
|
|
|
186 |
|
|
variable open_status : file_open_status;
|
187 |
|
|
|
188 |
|
|
variable i : integer := 0;
|
189 |
|
|
|
190 |
|
|
type stack_array is array (0 to 20) of integer;
|
191 |
|
|
variable stack_memory : stack_array;
|
192 |
|
|
variable stack_ptr : integer := 0;
|
193 |
|
|
|
194 |
|
|
type burst_data_array is array(0 to 260) of integer;
|
195 |
|
|
variable burst_memory : burst_data_array;
|
196 |
|
|
variable burst_ptr : integer := 0;
|
197 |
|
|
|
198 |
|
|
-- read_hex_natural converts ASCII hex representation in file
|
199 |
|
|
-- to actual hex
|
200 |
|
|
procedure read_hex_natural (L:inout line; n:out integer) is
|
201 |
|
|
variable result: integer := 0;
|
202 |
|
|
begin
|
203 |
|
|
for i in 1 to 8 loop
|
204 |
|
|
read(L,ch);
|
205 |
|
|
if '0'<=ch and ch <='9' then
|
206 |
|
|
result := result * 16 + character'pos(ch) - character'pos('0');
|
207 |
|
|
elsif 'A' <= ch and ch <= 'F' then
|
208 |
|
|
result := result * 16 + character'pos(ch) - character'pos('A') + 10;
|
209 |
|
|
elsif 'a' <= ch and ch<= 'f' then
|
210 |
|
|
result := result * 16 + character'pos(ch) - character'pos('a') + 10;
|
211 |
|
|
end if;
|
212 |
|
|
end loop;
|
213 |
|
|
n := result;
|
214 |
|
|
|
215 |
|
|
end read_hex_natural;
|
216 |
|
|
|
217 |
|
|
procedure bump_file_pointer(ptr: in integer; vectors_filename: IN string ) is
|
218 |
|
|
begin
|
219 |
|
|
file_close(vector_file);
|
220 |
|
|
file_open(vector_file,vectors_filename,READ_MODE);
|
221 |
|
|
readline(vector_file,L); -- Always read past interrupt vector line
|
222 |
|
|
read_hex_natural (L, machine_interrupt_a_vector); -- Get interrupt vector
|
223 |
|
|
|
224 |
|
|
if(ptr /= 0) then
|
225 |
|
|
for i in 0 to (ptr - 1) loop -- Keep reading lines until target line
|
226 |
|
|
readline(vector_file,L);
|
227 |
|
|
end loop;
|
228 |
|
|
end if;
|
229 |
|
|
end bump_file_pointer;
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
begin
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
file_open(vector_file,vector_filename,READ_MODE);
|
237 |
|
|
interrupt_cycle <= '0';
|
238 |
|
|
start_cyc <= '0';
|
239 |
|
|
next_instruction := 0;
|
240 |
|
|
instruction_offset := 0;
|
241 |
|
|
clr_machine_interrupt <= '0';
|
242 |
|
|
stack_ptr := 0;
|
243 |
|
|
cyc_data_out(31 downto 0) <= (others => '0');
|
244 |
|
|
cyc_addr(31 downto 0) <= (others => '0');
|
245 |
|
|
cyc_rdwr <= '0';
|
246 |
|
|
cyc_siz(1 downto 0) <= "00";
|
247 |
|
|
cyc_rmw <= '0';
|
248 |
|
|
brst_cyc <= '0';
|
249 |
|
|
brst_quantity(31 downto 0) <= (others => '0');
|
250 |
|
|
brst_last_int <= '0';
|
251 |
|
|
literal_out(31 downto 0) <= (others => '0');
|
252 |
|
|
next_inst(31 downto 0) <= (others => '0');
|
253 |
|
|
registera(31 downto 0) <= (others => '0');
|
254 |
|
|
registerb(31 downto 0) <= (others => '0');
|
255 |
|
|
registerc(31 downto 0) <= (others => '0');
|
256 |
|
|
registerd(31 downto 0) <= (others => '0');
|
257 |
|
|
reg_user_int(31 downto 0) <= (others => '0');
|
258 |
|
|
register_delay(31 downto 0) <= (others => '0');
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
if(rst = '1') then
|
263 |
|
|
wait on rst;
|
264 |
|
|
end if;
|
265 |
|
|
wait for 1 fs;
|
266 |
|
|
|
267 |
|
|
for i in 0 to 1000000000 loop -- Infinite instruction loop
|
268 |
|
|
if(enable_machine = '0') then -- Wait until DUT says OK to start
|
269 |
|
|
wait on enable_machine;
|
270 |
|
|
end if;
|
271 |
|
|
|
272 |
|
|
if(cyc_done = '1') then -- Wait until last instruction completes (or DUT gets out of reset)
|
273 |
|
|
wait on cyc_done;
|
274 |
|
|
end if;
|
275 |
|
|
wait for 10 ns;
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
if(machine_interrupt = '1' and interrupt_cycle = '0') then -- Check for interrupt
|
279 |
|
|
stack_ptr := stack_ptr + 1; -- Interrupt active, bump stack to next open location
|
280 |
|
|
stack_memory(stack_ptr) := next_instruction; -- Save address of next instruction
|
281 |
|
|
clr_machine_interrupt <= '1'; -- Clear bus model's interrupt line
|
282 |
|
|
wait for 10 ns; -- Give bus model a chance
|
283 |
|
|
clr_machine_interrupt <= '0'; -- Clear the clear
|
284 |
|
|
instruction_offset := machine_interrupt_a_vector; -- Jump off to the isr
|
285 |
|
|
interrupt_cycle <= '1'; -- Indicate we've entered the ISR
|
286 |
|
|
end if;
|
287 |
|
|
wait for 1 fs;
|
288 |
|
|
bump_file_pointer(instruction_offset, vector_filename); -- Bump file pointer to next instruction line
|
289 |
|
|
wait for 1 fs;
|
290 |
|
|
|
291 |
|
|
readline(vector_file,L); -- Get desired instruction line
|
292 |
|
|
read_hex_natural(L,instruction_type); -- Convert Ascii to hex
|
293 |
|
|
instruction_out(31 downto 0) <= conv_std_logic_vector(instruction_type,32);
|
294 |
|
|
|
295 |
|
|
wait for 1 fs;
|
296 |
|
|
case instruction_type is -- convert instruction number to human-readable form
|
297 |
|
|
when 0 =>
|
298 |
|
|
loaded_instruction <= load;
|
299 |
|
|
when 1 =>
|
300 |
|
|
loaded_instruction <= read;
|
301 |
|
|
when 2 =>
|
302 |
|
|
loaded_instruction <= write;
|
303 |
|
|
when 3 =>
|
304 |
|
|
loaded_instruction <= comp_e;
|
305 |
|
|
when 4 =>
|
306 |
|
|
loaded_instruction <= comp_ne;
|
307 |
|
|
when 5 =>
|
308 |
|
|
loaded_instruction <= jump;
|
309 |
|
|
when 6 =>
|
310 |
|
|
loaded_instruction <= and_inst;
|
311 |
|
|
when 7 =>
|
312 |
|
|
loaded_instruction <= or_inst;
|
313 |
|
|
when 8 =>
|
314 |
|
|
loaded_instruction <= ret;
|
315 |
|
|
when 9 =>
|
316 |
|
|
loaded_instruction <= add;
|
317 |
|
|
when 10 =>
|
318 |
|
|
loaded_instruction <= push;
|
319 |
|
|
when 11 =>
|
320 |
|
|
loaded_instruction <= pop;
|
321 |
|
|
when 12 =>
|
322 |
|
|
loaded_instruction <= call;
|
323 |
|
|
when 13 =>
|
324 |
|
|
loaded_instruction <= rdmem;
|
325 |
|
|
when 14 =>
|
326 |
|
|
loaded_instruction <= wrmem;
|
327 |
|
|
when 15 => -- 32-bit burst read
|
328 |
|
|
loaded_instruction <= rdbrst;
|
329 |
|
|
when 16 => -- 32-bit burst write
|
330 |
|
|
loaded_instruction <= wrbrst;
|
331 |
|
|
when 17 =>
|
332 |
|
|
loaded_instruction <= wrb;
|
333 |
|
|
when 18 =>
|
334 |
|
|
loaded_instruction <= wrw;
|
335 |
|
|
when 19 =>
|
336 |
|
|
loaded_instruction <= rdb;
|
337 |
|
|
when 20 =>
|
338 |
|
|
loaded_instruction <= rdw;
|
339 |
|
|
when 21 =>
|
340 |
|
|
loaded_instruction <= rmw_en;
|
341 |
|
|
when 22 =>
|
342 |
|
|
loaded_instruction <= rmw_dis;
|
343 |
|
|
when 23 =>
|
344 |
|
|
loaded_instruction <= rdt;
|
345 |
|
|
when 24 =>
|
346 |
|
|
loaded_instruction <= wrt;
|
347 |
|
|
when 25 =>
|
348 |
|
|
loaded_instruction <= rdbrstb;
|
349 |
|
|
when 26 =>
|
350 |
|
|
loaded_instruction <= rdbrstw;
|
351 |
|
|
when 27 =>
|
352 |
|
|
loaded_instruction <= rdbrstt;
|
353 |
|
|
when 28 =>
|
354 |
|
|
loaded_instruction <= wrbrstb;
|
355 |
|
|
when 29 =>
|
356 |
|
|
loaded_instruction <= wrbrstw;
|
357 |
|
|
when 30 =>
|
358 |
|
|
loaded_instruction <= wrbrstt;
|
359 |
|
|
when 31 =>
|
360 |
|
|
loaded_instruction <= delay;
|
361 |
|
|
when 32 =>
|
362 |
|
|
loaded_instruction <= wri;
|
363 |
|
|
when 33 =>
|
364 |
|
|
loaded_instruction <= wrib;
|
365 |
|
|
when 34 =>
|
366 |
|
|
loaded_instruction <= wriw;
|
367 |
|
|
when 35 =>
|
368 |
|
|
loaded_instruction <= writ;
|
369 |
|
|
when 36 =>
|
370 |
|
|
loaded_instruction <= rdi;
|
371 |
|
|
when 37 =>
|
372 |
|
|
loaded_instruction <= rdib;
|
373 |
|
|
when 38 =>
|
374 |
|
|
loaded_instruction <= rdiw;
|
375 |
|
|
when 39 =>
|
376 |
|
|
loaded_instruction <= rdit;
|
377 |
|
|
when 40 =>
|
378 |
|
|
loaded_instruction <= compi_e;
|
379 |
|
|
when 41 =>
|
380 |
|
|
loaded_instruction <= compi_ne;
|
381 |
|
|
when 42 =>
|
382 |
|
|
loaded_instruction <= ldrr;
|
383 |
|
|
when 43 =>
|
384 |
|
|
loaded_instruction <= shl;
|
385 |
|
|
when 44 =>
|
386 |
|
|
loaded_instruction <= shr;
|
387 |
|
|
|
388 |
|
|
when others =>
|
389 |
|
|
loaded_instruction <= load;
|
390 |
|
|
end case;
|
391 |
|
|
|
392 |
|
|
read(L,ch); -- bump past space between instruction number and register numebr
|
393 |
|
|
|
394 |
|
|
read_hex_natural(L,register_select); -- Convert register ASCII to register hex
|
395 |
|
|
register_out(31 downto 0) <= conv_std_logic_vector(register_select,32);
|
396 |
|
|
|
397 |
|
|
case register_select is -- Convert register number to human-readable form
|
398 |
|
|
when 1 =>
|
399 |
|
|
register_sel <= rega;
|
400 |
|
|
when 2 =>
|
401 |
|
|
register_sel <= regb;
|
402 |
|
|
when 3 =>
|
403 |
|
|
register_sel <= regc;
|
404 |
|
|
when 4 =>
|
405 |
|
|
register_sel <= regd;
|
406 |
|
|
when 5 =>
|
407 |
|
|
register_sel <= reguser;
|
408 |
|
|
when others =>
|
409 |
|
|
register_sel <= rega;
|
410 |
|
|
end case;
|
411 |
|
|
|
412 |
|
|
read(L,ch); -- bump past space between reg number and literal
|
413 |
|
|
|
414 |
|
|
read_hex_natural(L,lit_val);
|
415 |
|
|
literal_value <= conv_std_logic_vector(lit_val,32); -- Get literal value
|
416 |
|
|
wait for 1 fs;
|
417 |
|
|
literal_out(31 downto 0) <= literal_value(31 downto 0);
|
418 |
|
|
|
419 |
|
|
read(L,ch);
|
420 |
|
|
|
421 |
|
|
read_hex_natural(L,next_instruction); -- Get next instruction offset
|
422 |
|
|
|
423 |
|
|
next_inst(31 downto 0) <= conv_std_logic_vector(next_instruction,32);
|
424 |
|
|
|
425 |
|
|
wait for 1 fs;
|
426 |
|
|
-----------------------------------------------------------------------------------
|
427 |
|
|
-- The following case statement performs the instruction indicated in the vector
|
428 |
|
|
-- file.
|
429 |
|
|
-----------------------------------------------------------------------------------
|
430 |
|
|
case loaded_instruction is
|
431 |
|
|
|
432 |
|
|
------------------------------------------------------------
|
433 |
|
|
-- load loads the target register with the literal value
|
434 |
|
|
------------------------------------------------------------
|
435 |
|
|
when load =>
|
436 |
|
|
case register_sel is
|
437 |
|
|
when rega =>
|
438 |
|
|
registera <= literal_value;
|
439 |
|
|
when regb =>
|
440 |
|
|
registerb <= literal_value;
|
441 |
|
|
when regc =>
|
442 |
|
|
registerc <= literal_value;
|
443 |
|
|
when regd =>
|
444 |
|
|
registerd <= literal_value;
|
445 |
|
|
when reguser =>
|
446 |
|
|
reg_user_int <= literal_value;
|
447 |
|
|
when others =>
|
448 |
|
|
registera <= registera;
|
449 |
|
|
end case;
|
450 |
|
|
instruction_offset := next_instruction;
|
451 |
|
|
------------------------------------------------------------
|
452 |
|
|
-- comp_e compares the value in the target register to the
|
453 |
|
|
-- literal value. If the two are equal than the next
|
454 |
|
|
-- instruction is executed. If not, the next instruction is
|
455 |
|
|
-- skipped.
|
456 |
|
|
------------------------------------------------------------
|
457 |
|
|
when comp_e =>
|
458 |
|
|
case register_sel is
|
459 |
|
|
when rega =>
|
460 |
|
|
if(registera(31 downto 0) = literal_value(31 downto 0)) then
|
461 |
|
|
instruction_offset := next_instruction;
|
462 |
|
|
else
|
463 |
|
|
instruction_offset := instruction_offset + 1;
|
464 |
|
|
end if;
|
465 |
|
|
|
466 |
|
|
when regb =>
|
467 |
|
|
if(registerb(31 downto 0) = literal_value(31 downto 0)) then
|
468 |
|
|
instruction_offset := next_instruction;
|
469 |
|
|
else
|
470 |
|
|
instruction_offset := instruction_offset + 1;
|
471 |
|
|
end if;
|
472 |
|
|
|
473 |
|
|
when regc =>
|
474 |
|
|
if(registerc(31 downto 0) = literal_value(31 downto 0)) then
|
475 |
|
|
instruction_offset := next_instruction;
|
476 |
|
|
else
|
477 |
|
|
instruction_offset := instruction_offset + 1;
|
478 |
|
|
end if;
|
479 |
|
|
|
480 |
|
|
when regd =>
|
481 |
|
|
if(registerd(31 downto 0) = literal_value(31 downto 0)) then
|
482 |
|
|
instruction_offset := next_instruction;
|
483 |
|
|
else
|
484 |
|
|
instruction_offset := instruction_offset + 1;
|
485 |
|
|
end if;
|
486 |
|
|
when reguser =>
|
487 |
|
|
if(reg_user_int(31 downto 0) = literal_value(31 downto 0)) then
|
488 |
|
|
instruction_offset := next_instruction;
|
489 |
|
|
else
|
490 |
|
|
instruction_offset := instruction_offset + 1;
|
491 |
|
|
end if;
|
492 |
|
|
when others =>
|
493 |
|
|
registera <= registera;
|
494 |
|
|
end case;
|
495 |
|
|
|
496 |
|
|
------------------------------------------------------------
|
497 |
|
|
-- comp_ne compares the value in the target register to the
|
498 |
|
|
-- literal value. If the two are equal than the next
|
499 |
|
|
-- instruction is skipped. If not, the next instruction is
|
500 |
|
|
-- executed.
|
501 |
|
|
------------------------------------------------------------
|
502 |
|
|
when comp_ne =>
|
503 |
|
|
case register_sel is
|
504 |
|
|
when rega =>
|
505 |
|
|
if(registera(31 downto 0) /= literal_value(31 downto 0)) then
|
506 |
|
|
instruction_offset := next_instruction;
|
507 |
|
|
else
|
508 |
|
|
instruction_offset := instruction_offset + 1;
|
509 |
|
|
end if;
|
510 |
|
|
|
511 |
|
|
when regb =>
|
512 |
|
|
if(registerb(31 downto 0) /= literal_value(31 downto 0)) then
|
513 |
|
|
instruction_offset := next_instruction;
|
514 |
|
|
else
|
515 |
|
|
instruction_offset := instruction_offset + 1;
|
516 |
|
|
end if;
|
517 |
|
|
|
518 |
|
|
when regc =>
|
519 |
|
|
if(registerc(31 downto 0) /= literal_value(31 downto 0)) then
|
520 |
|
|
instruction_offset := next_instruction;
|
521 |
|
|
else
|
522 |
|
|
instruction_offset := instruction_offset + 1;
|
523 |
|
|
end if;
|
524 |
|
|
|
525 |
|
|
when regd =>
|
526 |
|
|
if(registerd(31 downto 0) /= literal_value(31 downto 0)) then
|
527 |
|
|
instruction_offset := next_instruction;
|
528 |
|
|
else
|
529 |
|
|
instruction_offset := instruction_offset + 1;
|
530 |
|
|
end if;
|
531 |
|
|
when reguser =>
|
532 |
|
|
if(reg_user_int(31 downto 0) /= literal_value(31 downto 0)) then
|
533 |
|
|
instruction_offset := next_instruction;
|
534 |
|
|
else
|
535 |
|
|
instruction_offset := instruction_offset + 1;
|
536 |
|
|
end if;
|
537 |
|
|
when others =>
|
538 |
|
|
registera <= registera;
|
539 |
|
|
end case;
|
540 |
|
|
|
541 |
|
|
------------------------------------------------------------
|
542 |
|
|
-- wr, wr.b, wr.w and wr.t perform a write cycle on the
|
543 |
|
|
-- target bus model. The address to be written to is the
|
544 |
|
|
-- value stored as the literal, the data to be written is
|
545 |
|
|
-- the value stored in the target register. The instructions
|
546 |
|
|
-- size suffix determines the contents of the cyc_siz bus
|
547 |
|
|
-- on the interface.
|
548 |
|
|
------------------------------------------------------------
|
549 |
|
|
when write | wrb | wrw | wrt =>
|
550 |
|
|
case register_sel is
|
551 |
|
|
when rega =>
|
552 |
|
|
cyc_data_out(31 downto 0) <= registera(31 downto 0);
|
553 |
|
|
when regb =>
|
554 |
|
|
cyc_data_out(31 downto 0) <= registerb(31 downto 0);
|
555 |
|
|
when regc =>
|
556 |
|
|
cyc_data_out(31 downto 0) <= registerc(31 downto 0);
|
557 |
|
|
when regd =>
|
558 |
|
|
cyc_data_out(31 downto 0) <= registerd(31 downto 0);
|
559 |
|
|
when reguser =>
|
560 |
|
|
cyc_data_out(31 downto 0) <= reg_user_int(31 downto 0);
|
561 |
|
|
when others =>
|
562 |
|
|
registera <= registera;
|
563 |
|
|
end case;
|
564 |
|
|
|
565 |
|
|
case loaded_instruction is
|
566 |
|
|
when write => -- 32-bit write cycle
|
567 |
|
|
cyc_siz(1 downto 0) <= "10";
|
568 |
|
|
when wrb => -- 8-bit
|
569 |
|
|
cyc_siz(1 downto 0) <= "00";
|
570 |
|
|
when wrw => -- 16-bit
|
571 |
|
|
cyc_siz(1 downto 0) <= "01";
|
572 |
|
|
when wrt => -- 16-bit
|
573 |
|
|
cyc_siz(1 downto 0) <= "11";
|
574 |
|
|
when others =>
|
575 |
|
|
cyc_siz(1 downto 0) <= "00";
|
576 |
|
|
end case;
|
577 |
|
|
|
578 |
|
|
cyc_addr(31 downto 0) <= literal_value(31 downto 0);
|
579 |
|
|
cyc_rdwr <= '0';
|
580 |
|
|
wait for 1 ns;
|
581 |
|
|
start_cyc <= '1';
|
582 |
|
|
wait on cyc_done;
|
583 |
|
|
wait for 1 fs;
|
584 |
|
|
start_cyc <= '0';
|
585 |
|
|
wait on cyc_done;
|
586 |
|
|
|
587 |
|
|
wait for 20 ns;
|
588 |
|
|
instruction_offset := next_instruction;
|
589 |
|
|
|
590 |
|
|
------------------------------------------------------------
|
591 |
|
|
-- rd, rd.b, rd.w and rd.t perform a read cycle on the
|
592 |
|
|
-- target bus model. The address to be read from is the
|
593 |
|
|
-- value stored as the literal, the data read is stored to
|
594 |
|
|
-- the register indicated in the instruction. The instructions
|
595 |
|
|
-- size suffix determines the contents of the cyc_siz bus
|
596 |
|
|
-- on the interface.
|
597 |
|
|
------------------------------------------------------------
|
598 |
|
|
when read | rdb | rdw | rdt =>
|
599 |
|
|
|
600 |
|
|
cyc_addr(31 downto 0) <= literal_value(31 downto 0);
|
601 |
|
|
cyc_rdwr <= '1';
|
602 |
|
|
case loaded_instruction is
|
603 |
|
|
when read => -- 32-bit write cycle
|
604 |
|
|
cyc_siz(1 downto 0) <= "10";
|
605 |
|
|
when rdb => -- 8-bit
|
606 |
|
|
cyc_siz(1 downto 0) <= "00";
|
607 |
|
|
when rdw => -- 16-bit
|
608 |
|
|
cyc_siz(1 downto 0) <= "01";
|
609 |
|
|
when rdt => -- 16-bit
|
610 |
|
|
cyc_siz(1 downto 0) <= "11";
|
611 |
|
|
when others =>
|
612 |
|
|
cyc_siz(1 downto 0) <= "00";
|
613 |
|
|
end case;
|
614 |
|
|
|
615 |
|
|
wait for 1 fs;
|
616 |
|
|
if(cyc_done = '1') then -- Make sure no cyc_done from last cycle
|
617 |
|
|
wait on cyc_done;
|
618 |
|
|
end if;
|
619 |
|
|
wait for 1 fs;
|
620 |
|
|
start_cyc <= '1';
|
621 |
|
|
wait on cyc_done;
|
622 |
|
|
|
623 |
|
|
wait for 1 fs;
|
624 |
|
|
start_cyc <= '0';
|
625 |
|
|
wait for 6.5 ns;
|
626 |
|
|
|
627 |
|
|
case register_sel is
|
628 |
|
|
when rega =>
|
629 |
|
|
registera(31 downto 0) <= cyc_data_in(31 downto 0);
|
630 |
|
|
when regb =>
|
631 |
|
|
registerb(31 downto 0) <= cyc_data_in(31 downto 0);
|
632 |
|
|
when regc =>
|
633 |
|
|
|
634 |
|
|
registerc(31 downto 0) <= cyc_data_in(31 downto 0);
|
635 |
|
|
when regd =>
|
636 |
|
|
registerd(31 downto 0) <= cyc_data_in(31 downto 0);
|
637 |
|
|
when reguser =>
|
638 |
|
|
reg_user_int(31 downto 0) <= cyc_data_in(31 downto 0);
|
639 |
|
|
when others =>
|
640 |
|
|
registera <= registera;
|
641 |
|
|
end case;
|
642 |
|
|
instruction_offset := next_instruction;
|
643 |
|
|
wait for 20 ns;
|
644 |
|
|
|
645 |
|
|
|
646 |
|
|
|
647 |
|
|
------------------------------------------------------------
|
648 |
|
|
-- wri, wri.b, wri.w and wri.t perform a write cycle on the
|
649 |
|
|
-- target bus model. The address to be written to is the
|
650 |
|
|
-- value stored in the register pointed to by the literal
|
651 |
|
|
-- value, the data to be written is the value stored in the
|
652 |
|
|
-- target register. The instructions size suffix determines
|
653 |
|
|
-- the contents of the cyc_siz bus on the interface.
|
654 |
|
|
------------------------------------------------------------
|
655 |
|
|
when wri | wrib | wriw | writ =>
|
656 |
|
|
case register_sel is
|
657 |
|
|
when rega =>
|
658 |
|
|
cyc_data_out(31 downto 0) <= registera(31 downto 0);
|
659 |
|
|
when regb =>
|
660 |
|
|
cyc_data_out(31 downto 0) <= registerb(31 downto 0);
|
661 |
|
|
when regc =>
|
662 |
|
|
cyc_data_out(31 downto 0) <= registerc(31 downto 0);
|
663 |
|
|
when regd =>
|
664 |
|
|
cyc_data_out(31 downto 0) <= registerd(31 downto 0);
|
665 |
|
|
when reguser =>
|
666 |
|
|
cyc_data_out(31 downto 0) <= reg_user_int(31 downto 0);
|
667 |
|
|
when others =>
|
668 |
|
|
registera <= registera;
|
669 |
|
|
end case;
|
670 |
|
|
|
671 |
|
|
case loaded_instruction is
|
672 |
|
|
when wri => -- 32-bit write cycle
|
673 |
|
|
cyc_siz(1 downto 0) <= "10";
|
674 |
|
|
when wrib => -- 8-bit
|
675 |
|
|
cyc_siz(1 downto 0) <= "00";
|
676 |
|
|
when wriw => -- 16-bit
|
677 |
|
|
cyc_siz(1 downto 0) <= "01";
|
678 |
|
|
when writ => -- 16-bit
|
679 |
|
|
cyc_siz(1 downto 0) <= "11";
|
680 |
|
|
when others =>
|
681 |
|
|
cyc_siz(1 downto 0) <= "00";
|
682 |
|
|
end case;
|
683 |
|
|
|
684 |
|
|
case literal_value is
|
685 |
|
|
when X"00000001" =>
|
686 |
|
|
cyc_addr(31 downto 0) <= registera(31 downto 0);
|
687 |
|
|
when X"00000002" =>
|
688 |
|
|
cyc_addr(31 downto 0) <= registerb(31 downto 0);
|
689 |
|
|
when X"00000003" =>
|
690 |
|
|
cyc_addr(31 downto 0) <= registerc(31 downto 0);
|
691 |
|
|
when X"00000004" =>
|
692 |
|
|
cyc_addr(31 downto 0) <= registerd(31 downto 0);
|
693 |
|
|
when X"00000005" =>
|
694 |
|
|
cyc_addr(31 downto 0) <= reg_user_int(31 downto 0);
|
695 |
|
|
when others =>
|
696 |
|
|
cyc_addr(31 downto 0) <= registera(31 downto 0);
|
697 |
|
|
end case;
|
698 |
|
|
|
699 |
|
|
|
700 |
|
|
cyc_rdwr <= '0';
|
701 |
|
|
wait for 1 ns;
|
702 |
|
|
start_cyc <= '1';
|
703 |
|
|
wait on cyc_done;
|
704 |
|
|
wait for 1 fs;
|
705 |
|
|
start_cyc <= '0';
|
706 |
|
|
wait on cyc_done;
|
707 |
|
|
|
708 |
|
|
wait for 20 ns;
|
709 |
|
|
instruction_offset := next_instruction;
|
710 |
|
|
|
711 |
|
|
|
712 |
|
|
------------------------------------------------------------
|
713 |
|
|
-- rd, rd.b, rd.w and rd.t perform a read cycle on the
|
714 |
|
|
-- target bus model. The address to be read from is the
|
715 |
|
|
-- value stored as the literal, the data read is stored to
|
716 |
|
|
-- the register indicated in the instruction. The instructions
|
717 |
|
|
-- size suffix determines the contents of the cyc_siz bus
|
718 |
|
|
-- on the interface.
|
719 |
|
|
------------------------------------------------------------
|
720 |
|
|
when rdi | rdib | rdiw | rdit =>
|
721 |
|
|
|
722 |
|
|
case literal_value(31 downto 0) is
|
723 |
|
|
when X"00000001" =>
|
724 |
|
|
cyc_addr(31 downto 0) <= registera(31 downto 0);
|
725 |
|
|
when X"00000002" =>
|
726 |
|
|
cyc_addr(31 downto 0) <= registerb(31 downto 0);
|
727 |
|
|
when X"00000003" =>
|
728 |
|
|
cyc_addr(31 downto 0) <= registerc(31 downto 0);
|
729 |
|
|
when X"00000004" =>
|
730 |
|
|
cyc_addr(31 downto 0) <= registerd(31 downto 0);
|
731 |
|
|
when X"00000005" =>
|
732 |
|
|
cyc_addr(31 downto 0) <= reg_user_int(31 downto 0);
|
733 |
|
|
when others =>
|
734 |
|
|
cyc_addr(31 downto 0) <= (others => '0');
|
735 |
|
|
end case;
|
736 |
|
|
cyc_rdwr <= '1';
|
737 |
|
|
|
738 |
|
|
case loaded_instruction is
|
739 |
|
|
when rdi => -- 32-bit write cycle
|
740 |
|
|
cyc_siz(1 downto 0) <= "10";
|
741 |
|
|
when rdib => -- 8-bit
|
742 |
|
|
cyc_siz(1 downto 0) <= "00";
|
743 |
|
|
when rdiw => -- 16-bit
|
744 |
|
|
cyc_siz(1 downto 0) <= "01";
|
745 |
|
|
when rdit => -- 16-bit
|
746 |
|
|
cyc_siz(1 downto 0) <= "11";
|
747 |
|
|
when others =>
|
748 |
|
|
cyc_siz(1 downto 0) <= "00";
|
749 |
|
|
end case;
|
750 |
|
|
|
751 |
|
|
wait for 1 fs;
|
752 |
|
|
if(cyc_done = '1') then -- Make sure no cyc_done from last cycle
|
753 |
|
|
wait on cyc_done;
|
754 |
|
|
end if;
|
755 |
|
|
wait for 1 fs;
|
756 |
|
|
start_cyc <= '1';
|
757 |
|
|
wait on cyc_done;
|
758 |
|
|
wait for 1 fs;
|
759 |
|
|
start_cyc <= '0';
|
760 |
|
|
wait for 6.5 ns;
|
761 |
|
|
case register_sel is
|
762 |
|
|
when rega =>
|
763 |
|
|
registera(31 downto 0) <= cyc_data_in(31 downto 0);
|
764 |
|
|
when regb =>
|
765 |
|
|
registerb(31 downto 0) <= cyc_data_in(31 downto 0);
|
766 |
|
|
when regc =>
|
767 |
|
|
registerc(31 downto 0) <= cyc_data_in(31 downto 0);
|
768 |
|
|
when regd =>
|
769 |
|
|
registerd(31 downto 0) <= cyc_data_in(31 downto 0);
|
770 |
|
|
when reguser =>
|
771 |
|
|
reg_user_int(31 downto 0) <= cyc_data_in(31 downto 0);
|
772 |
|
|
when others =>
|
773 |
|
|
registera <= registera;
|
774 |
|
|
end case;
|
775 |
|
|
instruction_offset := next_instruction;
|
776 |
|
|
wait for 20 ns;
|
777 |
|
|
|
778 |
|
|
------------------------------------------------------------
|
779 |
|
|
-- jump is an unconditional jump from the current instruction
|
780 |
|
|
-- offset to that indicated on the next instruction word.
|
781 |
|
|
------------------------------------------------------------
|
782 |
|
|
when jump =>
|
783 |
|
|
instruction_offset := next_instruction;
|
784 |
|
|
wait for 1 fs;
|
785 |
|
|
|
786 |
|
|
------------------------------------------------------------
|
787 |
|
|
-- The AND instruction performs a logic AND between the
|
788 |
|
|
-- contents of the indicated register and the literal value.
|
789 |
|
|
-- The result is stored in the indicated register.
|
790 |
|
|
------------------------------------------------------------
|
791 |
|
|
when and_inst=>
|
792 |
|
|
case register_sel is
|
793 |
|
|
when rega =>
|
794 |
|
|
registera(31 downto 0) <= registera(31 downto 0) AND literal_value(31 downto 0);
|
795 |
|
|
when regb =>
|
796 |
|
|
registerb(31 downto 0) <= registerb(31 downto 0) AND literal_value(31 downto 0);
|
797 |
|
|
when regc =>
|
798 |
|
|
registerc(31 downto 0) <= registerc(31 downto 0) AND literal_value(31 downto 0);
|
799 |
|
|
when regd =>
|
800 |
|
|
registerd(31 downto 0) <= registerd(31 downto 0) AND literal_value(31 downto 0);
|
801 |
|
|
when reguser =>
|
802 |
|
|
reg_user_int(31 downto 0) <= reg_user_int(31 downto 0) AND literal_value(31 downto 0);
|
803 |
|
|
when others =>
|
804 |
|
|
registera <= registera;
|
805 |
|
|
end case;
|
806 |
|
|
instruction_offset := next_instruction;
|
807 |
|
|
|
808 |
|
|
------------------------------------------------------------
|
809 |
|
|
-- The OR instruction performs a logic OR between the
|
810 |
|
|
-- contents of the indicated register and the literal value.
|
811 |
|
|
-- The result is stored in the indicated register.
|
812 |
|
|
------------------------------------------------------------
|
813 |
|
|
when or_inst=>
|
814 |
|
|
case register_sel is
|
815 |
|
|
when rega =>
|
816 |
|
|
registera(31 downto 0) <= registera(31 downto 0) OR literal_value(31 downto 0);
|
817 |
|
|
when regb =>
|
818 |
|
|
registerb(31 downto 0) <= registerb(31 downto 0) OR literal_value(31 downto 0);
|
819 |
|
|
when regc =>
|
820 |
|
|
registerc(31 downto 0) <= registerc(31 downto 0) OR literal_value(31 downto 0);
|
821 |
|
|
when regd =>
|
822 |
|
|
registerd(31 downto 0) <= registerd(31 downto 0) OR literal_value(31 downto 0);
|
823 |
|
|
when reguser =>
|
824 |
|
|
reg_user_int(31 downto 0) <= reg_user_int(31 downto 0) OR literal_value(31 downto 0);
|
825 |
|
|
when others =>
|
826 |
|
|
registera <= registera;
|
827 |
|
|
end case;
|
828 |
|
|
instruction_offset := next_instruction;
|
829 |
|
|
|
830 |
|
|
------------------------------------------------------------
|
831 |
|
|
-- The return instruction pops off the value stored at the
|
832 |
|
|
-- top of the stack into the instructions offset.
|
833 |
|
|
------------------------------------------------------------
|
834 |
|
|
when ret=>
|
835 |
|
|
instruction_offset := stack_memory(stack_ptr); -- Get number from top of stack into
|
836 |
|
|
-- next instruction
|
837 |
|
|
stack_ptr := stack_ptr - 1; -- Drop stack pointer down to next entry
|
838 |
|
|
interrupt_cycle <= '0';
|
839 |
|
|
wait for 1 fs;
|
840 |
|
|
|
841 |
|
|
------------------------------------------------------------
|
842 |
|
|
-- The add instruction adds the literal value to the register
|
843 |
|
|
-- indicated by the instruction.
|
844 |
|
|
------------------------------------------------------------
|
845 |
|
|
when add =>
|
846 |
|
|
case register_sel is
|
847 |
|
|
when rega =>
|
848 |
|
|
registera(31 downto 0) <= registera(31 downto 0) + literal_value(31 downto 0);
|
849 |
|
|
when regb =>
|
850 |
|
|
registerb(31 downto 0) <= registerb(31 downto 0) + literal_value(31 downto 0);
|
851 |
|
|
when regc =>
|
852 |
|
|
registerc(31 downto 0) <= registerc(31 downto 0) + literal_value(31 downto 0);
|
853 |
|
|
when regd =>
|
854 |
|
|
registerd(31 downto 0) <= registerd(31 downto 0) + literal_value(31 downto 0);
|
855 |
|
|
when reguser =>
|
856 |
|
|
reg_user_int(31 downto 0) <= reg_user_int(31 downto 0) + literal_value(31 downto 0);
|
857 |
|
|
when others =>
|
858 |
|
|
registera <= registera;
|
859 |
|
|
end case;
|
860 |
|
|
instruction_offset := next_instruction;
|
861 |
|
|
|
862 |
|
|
------------------------------------------------------------
|
863 |
|
|
-- The push instruction places the contents of the targetted
|
864 |
|
|
-- register onto the top of the stack.
|
865 |
|
|
------------------------------------------------------------
|
866 |
|
|
when push =>
|
867 |
|
|
stack_ptr := stack_ptr + 1; -- Stack point incremented to next available location
|
868 |
|
|
wait for 1 fs; -- Allow simulator to do it's business
|
869 |
|
|
case register_sel is
|
870 |
|
|
when rega =>
|
871 |
|
|
stack_memory(stack_ptr) := CONV_INTEGER(registera(31 downto 0));
|
872 |
|
|
when regb =>
|
873 |
|
|
stack_memory(stack_ptr) := CONV_INTEGER(registerb(31 downto 0));
|
874 |
|
|
when regc =>
|
875 |
|
|
stack_memory(stack_ptr) := CONV_INTEGER(registerc(31 downto 0));
|
876 |
|
|
when regd =>
|
877 |
|
|
stack_memory(stack_ptr) := CONV_INTEGER(registerd(31 downto 0));
|
878 |
|
|
when reguser =>
|
879 |
|
|
stack_memory(stack_ptr) := CONV_INTEGER(reg_user_int(31 downto 0));
|
880 |
|
|
when others =>
|
881 |
|
|
stack_memory(stack_ptr) := CONV_INTEGER(registera(31 downto 0));
|
882 |
|
|
end case;
|
883 |
|
|
instruction_offset := next_instruction;
|
884 |
|
|
|
885 |
|
|
------------------------------------------------------------
|
886 |
|
|
-- The pop instruction retrieves the topmost entry on the
|
887 |
|
|
-- stack and places it into the targetted register.
|
888 |
|
|
------------------------------------------------------------
|
889 |
|
|
when pop =>
|
890 |
|
|
|
891 |
|
|
case register_sel is
|
892 |
|
|
when rega =>
|
893 |
|
|
registera(31 downto 0) <= conv_std_logic_vector(stack_memory(stack_ptr),32);
|
894 |
|
|
when regb =>
|
895 |
|
|
registerb(31 downto 0) <= conv_std_logic_vector(stack_memory(stack_ptr),32);
|
896 |
|
|
when regc =>
|
897 |
|
|
registerc(31 downto 0) <= conv_std_logic_vector(stack_memory(stack_ptr),32);
|
898 |
|
|
when regd =>
|
899 |
|
|
registerd(31 downto 0) <= conv_std_logic_vector(stack_memory(stack_ptr),32);
|
900 |
|
|
when reguser =>
|
901 |
|
|
reg_user_int(31 downto 0) <= conv_std_logic_vector(stack_memory(stack_ptr),32);
|
902 |
|
|
when others =>
|
903 |
|
|
registerd(31 downto 0) <= conv_std_logic_vector(stack_memory(stack_ptr),32);
|
904 |
|
|
end case;
|
905 |
|
|
stack_ptr := stack_ptr - 1; -- Adjust stack pointer down
|
906 |
|
|
instruction_offset := next_instruction;
|
907 |
|
|
|
908 |
|
|
------------------------------------------------------------
|
909 |
|
|
-- The call instruction places the address of the next
|
910 |
|
|
-- instruction onto the top of the stack and then changes
|
911 |
|
|
-- the instruction pointer to the value of the next
|
912 |
|
|
-- instruction.
|
913 |
|
|
------------------------------------------------------------
|
914 |
|
|
when call =>
|
915 |
|
|
-- instruction_offset holds current instruction
|
916 |
|
|
stack_ptr := stack_ptr + 1;
|
917 |
|
|
wait for 1 fs;
|
918 |
|
|
stack_memory(stack_ptr) := instruction_offset + 1; -- set stack to next instruction
|
919 |
|
|
|
920 |
|
|
instruction_offset := next_instruction; -- load PC with called routine offset
|
921 |
|
|
|
922 |
|
|
------------------------------------------------------------
|
923 |
|
|
-- HASM's method of performing burst read and write cycles
|
924 |
|
|
-- is to use a block of memory as the source and destination
|
925 |
|
|
-- of the data transferred in the burst cycle. In order for
|
926 |
|
|
-- the HASM simulator to access this memory it must use a
|
927 |
|
|
-- special instruction. The RDMEM instruction will read
|
928 |
|
|
-- the address specified by the second register in the
|
929 |
|
|
-- instruction. The first register in the instruction
|
930 |
|
|
-- receives the data from the memory.
|
931 |
|
|
------------------------------------------------------------
|
932 |
|
|
when rdmem =>
|
933 |
|
|
instruction_offset := next_instruction;
|
934 |
|
|
case register_sel is
|
935 |
|
|
when rega =>
|
936 |
|
|
case literal_value(31 downto 0) is
|
937 |
|
|
when X"00000001" => -- rdmem rega,rega;
|
938 |
|
|
registera(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
939 |
|
|
when X"00000002" => -- rdmem rega,regb;
|
940 |
|
|
registera(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerb(31 downto 0))),32);
|
941 |
|
|
when X"00000003" => -- rdmem rega,regc;
|
942 |
|
|
registera(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerc(31 downto 0))),32);
|
943 |
|
|
when X"00000004" => -- rdmem rega,regd;
|
944 |
|
|
registera(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerd(31 downto 0))),32);
|
945 |
|
|
when X"00000005" => -- rdmem rega,reguser;
|
946 |
|
|
registera(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))),32);
|
947 |
|
|
when others => -- rdmem rega,rega;
|
948 |
|
|
registera(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
949 |
|
|
end case;
|
950 |
|
|
|
951 |
|
|
when regb =>
|
952 |
|
|
case literal_value(31 downto 0) is
|
953 |
|
|
when X"00000001" => -- rdmem regb,rega;
|
954 |
|
|
registerb(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
955 |
|
|
when X"00000002" => -- rdmem regb,regb;
|
956 |
|
|
registerb(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerb(31 downto 0))),32);
|
957 |
|
|
when X"00000003" => -- rdmem regb,regc;
|
958 |
|
|
registerb(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerc(31 downto 0))),32);
|
959 |
|
|
when X"00000004" => -- rdmem regb,regd;
|
960 |
|
|
registerb(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerd(31 downto 0))),32);
|
961 |
|
|
when X"00000005" => -- rdmem regb,reguser;
|
962 |
|
|
registerb(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))),32);
|
963 |
|
|
when others => -- rdmem regb,rega;
|
964 |
|
|
registerb(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
965 |
|
|
end case;
|
966 |
|
|
|
967 |
|
|
when regc =>
|
968 |
|
|
case literal_value(31 downto 0) is
|
969 |
|
|
when X"00000001" => -- rdmem regc,rega;
|
970 |
|
|
registerc(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
971 |
|
|
when X"00000002" => -- rdmem regc,regb;
|
972 |
|
|
registerc(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerb(31 downto 0))),32);
|
973 |
|
|
when X"00000003" => -- rdmem regc,regc;
|
974 |
|
|
registerc(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerc(31 downto 0))),32);
|
975 |
|
|
when X"00000004" => -- rdmem regc,regd;
|
976 |
|
|
registerc(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerd(31 downto 0))),32);
|
977 |
|
|
when X"00000005" => -- rdmem regc,reguser;
|
978 |
|
|
registerc(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))),32);
|
979 |
|
|
|
980 |
|
|
when others => -- rdmem regc,rega;
|
981 |
|
|
registerc(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
982 |
|
|
end case;
|
983 |
|
|
|
984 |
|
|
when regd =>
|
985 |
|
|
case literal_value(31 downto 0) is
|
986 |
|
|
when X"00000001" => -- rdmem regd,rega;
|
987 |
|
|
registerd(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
988 |
|
|
when X"00000002" => -- rdmem regd,regb;
|
989 |
|
|
registerd(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerb(31 downto 0))),32);
|
990 |
|
|
when X"00000003" => -- rdmem regd,regc;
|
991 |
|
|
registerd(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerc(31 downto 0))),32);
|
992 |
|
|
when X"00000004" => -- rdmem regd,regd;
|
993 |
|
|
registerd(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerd(31 downto 0))),32);
|
994 |
|
|
when X"00000005" => -- rdmem regd,reguser;
|
995 |
|
|
registerd(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))),32);
|
996 |
|
|
|
997 |
|
|
when others => -- rdmem regd,rega;
|
998 |
|
|
registerd(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
999 |
|
|
end case;
|
1000 |
|
|
|
1001 |
|
|
when reguser =>
|
1002 |
|
|
case literal_value(31 downto 0) is
|
1003 |
|
|
when X"00000001" => -- rdmem regd,rega;
|
1004 |
|
|
reg_user_int(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
1005 |
|
|
when X"00000002" => -- rdmem regd,regb;
|
1006 |
|
|
reg_user_int(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerb(31 downto 0))),32);
|
1007 |
|
|
when X"00000003" => -- rdmem regd,regc;
|
1008 |
|
|
reg_user_int(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerc(31 downto 0))),32);
|
1009 |
|
|
when X"00000004" => -- rdmem regd,regd;
|
1010 |
|
|
reg_user_int(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registerd(31 downto 0))),32);
|
1011 |
|
|
when X"00000005" => -- rdmem reguser,reguser;
|
1012 |
|
|
reg_user_int(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))),32);
|
1013 |
|
|
|
1014 |
|
|
when others => -- rdmem regd,rega;
|
1015 |
|
|
registerd(31 downto 0) <= conv_std_logic_vector(burst_memory(CONV_INTEGER(registera(31 downto 0))),32);
|
1016 |
|
|
end case;
|
1017 |
|
|
|
1018 |
|
|
when others =>
|
1019 |
|
|
end case;
|
1020 |
|
|
|
1021 |
|
|
------------------------------------------------------------
|
1022 |
|
|
-- WRMEM is the instruction used to write data to HASM's
|
1023 |
|
|
-- internal memory block. This memory block is used as the
|
1024 |
|
|
-- source and destination for burst read and write cycles
|
1025 |
|
|
-- executed by the bus model.
|
1026 |
|
|
-- WRMEM will write the contents of the second register
|
1027 |
|
|
-- to the block memory address stored in the first register.
|
1028 |
|
|
------------------------------------------------------------
|
1029 |
|
|
when wrmem =>
|
1030 |
|
|
instruction_offset := next_instruction;
|
1031 |
|
|
case register_sel is
|
1032 |
|
|
when rega =>
|
1033 |
|
|
case literal_value(31 downto 0) is
|
1034 |
|
|
when X"00000001" => -- wrmem rega,rega;
|
1035 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(registera(31 downto 0));
|
1036 |
|
|
|
1037 |
|
|
when X"00000002" => -- wrmem rega,regb;
|
1038 |
|
|
burst_memory(CONV_INTEGER(registerb(31 downto 0))) := CONV_INTEGER(registera(31 downto 0));
|
1039 |
|
|
|
1040 |
|
|
when X"00000003" => -- wrmem rega,regc;
|
1041 |
|
|
burst_memory(CONV_INTEGER(registerc(31 downto 0))) := CONV_INTEGER(registera(31 downto 0));
|
1042 |
|
|
|
1043 |
|
|
when X"00000004" => -- wrmem rega,regd;
|
1044 |
|
|
burst_memory(CONV_INTEGER(registerd(31 downto 0))) := CONV_INTEGER(registera(31 downto 0));
|
1045 |
|
|
|
1046 |
|
|
when X"00000005" => -- wrmem rega,reguser;
|
1047 |
|
|
burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))) := CONV_INTEGER(registera(31 downto 0));
|
1048 |
|
|
|
1049 |
|
|
when others => -- wrmem rega,rega;
|
1050 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(registera(31 downto 0));
|
1051 |
|
|
end case;
|
1052 |
|
|
|
1053 |
|
|
when regb =>
|
1054 |
|
|
case literal_value(31 downto 0) is
|
1055 |
|
|
when X"00000001" => -- wrmem rega,rega;
|
1056 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(registerb(31 downto 0));
|
1057 |
|
|
when X"00000002" => -- wrmem rega,regb;
|
1058 |
|
|
burst_memory(CONV_INTEGER(registerb(31 downto 0))) := CONV_INTEGER(registerb(31 downto 0));
|
1059 |
|
|
when X"00000003" => -- wrmem rega,regc;
|
1060 |
|
|
burst_memory(CONV_INTEGER(registerc(31 downto 0))) := CONV_INTEGER(registerb(31 downto 0));
|
1061 |
|
|
when X"00000004" => -- wrmem rega,regd;
|
1062 |
|
|
burst_memory(CONV_INTEGER(registerd(31 downto 0))) := CONV_INTEGER(registerb(31 downto 0));
|
1063 |
|
|
when X"00000005" => -- wrmem rega,regd;
|
1064 |
|
|
burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))) := CONV_INTEGER(registerb(31 downto 0));
|
1065 |
|
|
|
1066 |
|
|
when others => -- wrmem rega,rega;
|
1067 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(registerb(31 downto 0));
|
1068 |
|
|
end case;
|
1069 |
|
|
|
1070 |
|
|
when regc =>
|
1071 |
|
|
case literal_value(31 downto 0) is
|
1072 |
|
|
when X"00000001" => -- wrmem rega,rega;
|
1073 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(registerc(31 downto 0));
|
1074 |
|
|
when X"00000002" => -- wrmem rega,regb;
|
1075 |
|
|
burst_memory(CONV_INTEGER(registerb(31 downto 0))) := CONV_INTEGER(registerc(31 downto 0));
|
1076 |
|
|
when X"00000003" => -- wrmem rega,regc;
|
1077 |
|
|
burst_memory(CONV_INTEGER(registerc(31 downto 0))) := CONV_INTEGER(registerc(31 downto 0));
|
1078 |
|
|
when X"00000004" => -- wrmem rega,regd;
|
1079 |
|
|
burst_memory(CONV_INTEGER(registerd(31 downto 0))) := CONV_INTEGER(registerc(31 downto 0));
|
1080 |
|
|
when X"00000005" => -- wrmem rega,regd;
|
1081 |
|
|
burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))) := CONV_INTEGER(registerc(31 downto 0));
|
1082 |
|
|
|
1083 |
|
|
when others => -- wrmem rega,rega;
|
1084 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(registerc(31 downto 0));
|
1085 |
|
|
end case;
|
1086 |
|
|
|
1087 |
|
|
when regd =>
|
1088 |
|
|
case literal_value(31 downto 0) is
|
1089 |
|
|
when X"00000001" => -- wrmem rega,rega;
|
1090 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(registerd(31 downto 0));
|
1091 |
|
|
when X"00000002" => -- wrmem rega,regb
|
1092 |
|
|
burst_memory(CONV_INTEGER(registerb(31 downto 0))) := CONV_INTEGER(registerd(31 downto 0));
|
1093 |
|
|
when X"00000003" => -- wrmem rega,regc;
|
1094 |
|
|
burst_memory(CONV_INTEGER(registerc(31 downto 0))) := CONV_INTEGER(registerd(31 downto 0));
|
1095 |
|
|
when X"00000004" => -- wrmem rega,regd;
|
1096 |
|
|
burst_memory(CONV_INTEGER(registerd(31 downto 0))) := CONV_INTEGER(registerd(31 downto 0));
|
1097 |
|
|
when X"00000005" => -- wrmem rega,regd;
|
1098 |
|
|
burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))) := CONV_INTEGER(registerd(31 downto 0));
|
1099 |
|
|
|
1100 |
|
|
when others => -- wrmem rega,rega;
|
1101 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(registerd(31 downto 0));
|
1102 |
|
|
end case;
|
1103 |
|
|
|
1104 |
|
|
when reguser =>
|
1105 |
|
|
case literal_value(31 downto 0) is
|
1106 |
|
|
when X"00000001" => -- wrmem rega,rega;
|
1107 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(reg_user_int(31 downto 0));
|
1108 |
|
|
when X"00000002" => -- wrmem rega,regb
|
1109 |
|
|
burst_memory(CONV_INTEGER(registerb(31 downto 0))) := CONV_INTEGER(reg_user_int(31 downto 0));
|
1110 |
|
|
when X"00000003" => -- wrmem rega,regc;
|
1111 |
|
|
burst_memory(CONV_INTEGER(registerc(31 downto 0))) := CONV_INTEGER(reg_user_int(31 downto 0));
|
1112 |
|
|
when X"00000004" => -- wrmem rega,regd;
|
1113 |
|
|
burst_memory(CONV_INTEGER(registerd(31 downto 0))) := CONV_INTEGER(reg_user_int(31 downto 0));
|
1114 |
|
|
when X"00000005" => -- wrmem rega,regd;
|
1115 |
|
|
burst_memory(CONV_INTEGER(reg_user_int(31 downto 0))) := CONV_INTEGER(reg_user_int(31 downto 0));
|
1116 |
|
|
|
1117 |
|
|
when others => -- wrmem rega,rega;
|
1118 |
|
|
burst_memory(CONV_INTEGER(registera(31 downto 0))) := CONV_INTEGER(reg_user_int(31 downto 0));
|
1119 |
|
|
end case;
|
1120 |
|
|
|
1121 |
|
|
|
1122 |
|
|
when others =>
|
1123 |
|
|
end case;
|
1124 |
|
|
|
1125 |
|
|
------------------------------------------------------------
|
1126 |
|
|
-- The rdbrst instruction causes the HASM simulator to
|
1127 |
|
|
-- execute a burst read cycle on the bus model. The first
|
1128 |
|
|
-- register in the instruction contains the first address in
|
1129 |
|
|
-- HASM's internal memory to receive the first value in the
|
1130 |
|
|
-- burst cycle from the bus model. The second register in the
|
1131 |
|
|
-- instruction contains the number of words to be transferred
|
1132 |
|
|
-- in the burst.
|
1133 |
|
|
------------------------------------------------------------
|
1134 |
|
|
when rdbrst | rdbrstb | rdbrstw | rdbrstt =>
|
1135 |
|
|
instruction_offset := next_instruction;
|
1136 |
|
|
burst_ptr := 0;
|
1137 |
|
|
brst_quantity(31 downto 0) <= (others => '0');
|
1138 |
|
|
brst_cyc <= '1';
|
1139 |
|
|
cyc_rdwr <= '1';
|
1140 |
|
|
case loaded_instruction is
|
1141 |
|
|
when rdbrst =>
|
1142 |
|
|
cyc_siz(1 downto 0) <= "10";
|
1143 |
|
|
when rdbrstb =>
|
1144 |
|
|
cyc_siz(1 downto 0) <= "00";
|
1145 |
|
|
when rdbrstw =>
|
1146 |
|
|
cyc_siz(1 downto 0) <= "01";
|
1147 |
|
|
when rdbrstt =>
|
1148 |
|
|
cyc_siz(1 downto 0) <= "11";
|
1149 |
|
|
when others =>
|
1150 |
|
|
cyc_siz(1 downto 0) <= "00";
|
1151 |
|
|
end case;
|
1152 |
|
|
case register_sel is -- Get Address on target to read from
|
1153 |
|
|
when rega =>
|
1154 |
|
|
cyc_addr(31 downto 0) <= registera(31 downto 0);
|
1155 |
|
|
when regb =>
|
1156 |
|
|
cyc_addr(31 downto 0) <= registerb(31 downto 0);
|
1157 |
|
|
when regc =>
|
1158 |
|
|
cyc_addr(31 downto 0) <= registerc(31 downto 0);
|
1159 |
|
|
when regd =>
|
1160 |
|
|
cyc_addr(31 downto 0) <= registerd(31 downto 0);
|
1161 |
|
|
when reguser =>
|
1162 |
|
|
cyc_addr(31 downto 0) <= reg_user_int(31 downto 0);
|
1163 |
|
|
when others =>
|
1164 |
|
|
cyc_addr(31 downto 0) <= registera(31 downto 0);
|
1165 |
|
|
end case;
|
1166 |
|
|
wait for 1 fs;
|
1167 |
|
|
|
1168 |
|
|
if(cyc_done = '1') then -- Make sure no cyc_done from last cycle
|
1169 |
|
|
wait on cyc_done;
|
1170 |
|
|
end if;
|
1171 |
|
|
wait for 1 fs;
|
1172 |
|
|
if(brst_data_rdy = '1') then
|
1173 |
|
|
wait on brst_data_rdy; -- Make sure of no left over ready signals
|
1174 |
|
|
end if;
|
1175 |
|
|
wait for 1 fs;
|
1176 |
|
|
|
1177 |
|
|
start_cyc <= '1';
|
1178 |
|
|
brst_quantity(31 downto 0) <= literal_value(31 downto 0);
|
1179 |
|
|
for i in 0 to (CONV_INTEGER( (literal_value(31 downto 0)) - 1) ) loop
|
1180 |
|
|
|
1181 |
|
|
if(i = (CONV_INTEGER( (literal_value(31 downto 0)) - 1) ) ) then
|
1182 |
|
|
brst_last_int <= '1';
|
1183 |
|
|
end if;
|
1184 |
|
|
|
1185 |
|
|
wait on brst_data_rdy; -- rising edge burst ready
|
1186 |
|
|
wait for 6.5 ns; -- Space write operation in middle of data window
|
1187 |
|
|
burst_memory(i) := CONV_INTEGER(cyc_data_in(31 downto 0));
|
1188 |
|
|
wait for 1 fs;
|
1189 |
|
|
wait on brst_data_rdy; -- falling edge burst ready
|
1190 |
|
|
|
1191 |
|
|
if(brst_last_int = '1')then
|
1192 |
|
|
brst_last_int <= '0';
|
1193 |
|
|
end if;
|
1194 |
|
|
|
1195 |
|
|
wait for 1 fs;
|
1196 |
|
|
end loop;
|
1197 |
|
|
|
1198 |
|
|
start_cyc <= '0';
|
1199 |
|
|
brst_last_int <= '0';
|
1200 |
|
|
brst_cyc <= '0';
|
1201 |
|
|
cyc_rdwr <= '0';
|
1202 |
|
|
wait for 20 ns;
|
1203 |
|
|
------------------------------------------------------------
|
1204 |
|
|
-- The wrbrst instruction causes the HASM simulator to execute
|
1205 |
|
|
-- a burst write cycle on the bus model. The first register
|
1206 |
|
|
-- in the instruction is the first address in HASM's memory
|
1207 |
|
|
-- block where the first data value to write is stored. The
|
1208 |
|
|
-- second register in the instruction is the number of cycles
|
1209 |
|
|
-- to execute in the burst.
|
1210 |
|
|
------------------------------------------------------------
|
1211 |
|
|
when wrbrst | wrbrstb | wrbrstw | wrbrstt =>
|
1212 |
|
|
instruction_offset := next_instruction;
|
1213 |
|
|
burst_ptr := 0;
|
1214 |
|
|
brst_quantity(31 downto 0) <= (others => '0');
|
1215 |
|
|
brst_cyc <= '1';
|
1216 |
|
|
cyc_rdwr <= '0';
|
1217 |
|
|
case loaded_instruction is
|
1218 |
|
|
when wrbrst =>
|
1219 |
|
|
cyc_siz(1 downto 0) <= "10";
|
1220 |
|
|
when wrbrstb =>
|
1221 |
|
|
cyc_siz(1 downto 0) <= "00";
|
1222 |
|
|
when wrbrstw =>
|
1223 |
|
|
cyc_siz(1 downto 0) <= "01";
|
1224 |
|
|
when wrbrstt =>
|
1225 |
|
|
cyc_siz(1 downto 0) <= "11";
|
1226 |
|
|
when others =>
|
1227 |
|
|
cyc_siz(1 downto 0) <= "00";
|
1228 |
|
|
end case;
|
1229 |
|
|
case register_sel is
|
1230 |
|
|
when rega =>
|
1231 |
|
|
cyc_addr(31 downto 0) <= registera(31 downto 0);
|
1232 |
|
|
when regb =>
|
1233 |
|
|
cyc_addr(31 downto 0) <= registerb(31 downto 0);
|
1234 |
|
|
when regc =>
|
1235 |
|
|
cyc_addr(31 downto 0) <= registerc(31 downto 0);
|
1236 |
|
|
when regd =>
|
1237 |
|
|
cyc_addr(31 downto 0) <= registerd(31 downto 0);
|
1238 |
|
|
when reguser =>
|
1239 |
|
|
cyc_addr(31 downto 0) <= reg_user_int(31 downto 0);
|
1240 |
|
|
when others =>
|
1241 |
|
|
cyc_addr(31 downto 0) <= registera(31 downto 0);
|
1242 |
|
|
end case;
|
1243 |
|
|
wait for 1 fs;
|
1244 |
|
|
|
1245 |
|
|
if(cyc_done = '1') then -- Make sure no cyc_done from last cycle
|
1246 |
|
|
wait on cyc_done;
|
1247 |
|
|
end if;
|
1248 |
|
|
wait for 1 fs;
|
1249 |
|
|
if(brst_data_rdy = '1') then
|
1250 |
|
|
wait on brst_data_rdy; -- make sure of no left over ready signals
|
1251 |
|
|
end if;
|
1252 |
|
|
wait for 1 fs;
|
1253 |
|
|
brst_quantity(31 downto 0) <= literal_value(31 downto 0);
|
1254 |
|
|
start_cyc <= '1';
|
1255 |
|
|
|
1256 |
|
|
for i in 0 to (CONV_INTEGER( (literal_value(31 downto 0)) - 1) ) loop
|
1257 |
|
|
|
1258 |
|
|
if(i = CONV_INTEGER(literal_value(31 downto 0)) - 1) then
|
1259 |
|
|
brst_last_int <= '1';
|
1260 |
|
|
end if;
|
1261 |
|
|
|
1262 |
|
|
cyc_data_out(31 downto 0) <= conv_std_logic_vector(burst_memory(i),32);
|
1263 |
|
|
wait on brst_data_rdy; -- rising edge burst ready
|
1264 |
|
|
wait for 1 fs;
|
1265 |
|
|
wait on brst_data_rdy; -- falling edge burst ready
|
1266 |
|
|
wait for 1 fs;
|
1267 |
|
|
end loop;
|
1268 |
|
|
|
1269 |
|
|
start_cyc <= '0';
|
1270 |
|
|
|
1271 |
|
|
brst_cyc <= '0';
|
1272 |
|
|
cyc_rdwr <= '0';
|
1273 |
|
|
brst_last_int <= '0';
|
1274 |
|
|
wait for 20 ns;
|
1275 |
|
|
|
1276 |
|
|
------------------------------------------------------------
|
1277 |
|
|
-- The RMW_EN instruction sets HASM's read-modify-write line
|
1278 |
|
|
-- high. This signal is meant to indicate to the bus model
|
1279 |
|
|
-- that the next group of bus cycles should not be interupted.
|
1280 |
|
|
------------------------------------------------------------
|
1281 |
|
|
when rmw_en =>
|
1282 |
|
|
cyc_rmw <= '1';
|
1283 |
|
|
instruction_offset := next_instruction;
|
1284 |
|
|
|
1285 |
|
|
------------------------------------------------------------
|
1286 |
|
|
-- The RMW_DIS instruction shuts off HASM's read-modify-write
|
1287 |
|
|
-- line.
|
1288 |
|
|
------------------------------------------------------------
|
1289 |
|
|
when rmw_dis =>
|
1290 |
|
|
cyc_rmw <= '0';
|
1291 |
|
|
instruction_offset := next_instruction;
|
1292 |
|
|
|
1293 |
|
|
------------------------------------------------------------
|
1294 |
|
|
-- The delay instruction stops hasm for the number of
|
1295 |
|
|
-- microseconds specified in the register field
|
1296 |
|
|
------------------------------------------------------------
|
1297 |
|
|
when delay =>
|
1298 |
|
|
register_delay(31 downto 0) <= conv_std_logic_vector(register_select,32);
|
1299 |
|
|
wait for 1 fs;
|
1300 |
|
|
time_delay := CONV_INTEGER((register_delay(31 downto 0) - X"00000001"));
|
1301 |
|
|
wait for 1 fs;
|
1302 |
|
|
for i in 0 to time_delay loop
|
1303 |
|
|
wait for 1 us;
|
1304 |
|
|
end loop;
|
1305 |
|
|
instruction_offset := next_instruction;
|
1306 |
|
|
|
1307 |
|
|
------------------------------------------------------------
|
1308 |
|
|
-- compi_e compares the value in the target register to the
|
1309 |
|
|
-- value in another register. If the two are equal than the
|
1310 |
|
|
-- next instruction is executed. If not, the next
|
1311 |
|
|
-- instruction is skipped.
|
1312 |
|
|
------------------------------------------------------------
|
1313 |
|
|
when compi_e =>
|
1314 |
|
|
case register_sel is
|
1315 |
|
|
when rega =>
|
1316 |
|
|
case literal_value(31 downto 0) is
|
1317 |
|
|
when X"00000001" => -- Register A to Register A
|
1318 |
|
|
if(registera(31 downto 0) = registera(31 downto 0)) then
|
1319 |
|
|
instruction_offset := next_instruction;
|
1320 |
|
|
else
|
1321 |
|
|
instruction_offset := instruction_offset + 1;
|
1322 |
|
|
end if;
|
1323 |
|
|
when X"00000002" => -- Register A to Register B
|
1324 |
|
|
if(registera(31 downto 0) = registerb(31 downto 0)) then
|
1325 |
|
|
instruction_offset := next_instruction;
|
1326 |
|
|
else
|
1327 |
|
|
instruction_offset := instruction_offset + 1;
|
1328 |
|
|
end if;
|
1329 |
|
|
when X"00000003" => -- Register A to Register C
|
1330 |
|
|
if(registera(31 downto 0) = registerc(31 downto 0)) then
|
1331 |
|
|
instruction_offset := next_instruction;
|
1332 |
|
|
else
|
1333 |
|
|
instruction_offset := instruction_offset + 1;
|
1334 |
|
|
end if;
|
1335 |
|
|
when X"00000004" => -- Register A to Register D
|
1336 |
|
|
if(registera(31 downto 0) = registerd(31 downto 0)) then
|
1337 |
|
|
instruction_offset := next_instruction;
|
1338 |
|
|
else
|
1339 |
|
|
instruction_offset := instruction_offset + 1;
|
1340 |
|
|
end if;
|
1341 |
|
|
when X"00000005" => -- Register A to Register User
|
1342 |
|
|
if(registera(31 downto 0) = reg_user_int(31 downto 0)) then
|
1343 |
|
|
instruction_offset := next_instruction;
|
1344 |
|
|
else
|
1345 |
|
|
instruction_offset := instruction_offset + 1;
|
1346 |
|
|
end if;
|
1347 |
|
|
when others =>
|
1348 |
|
|
instruction_offset := next_instruction;
|
1349 |
|
|
end case;
|
1350 |
|
|
when regb =>
|
1351 |
|
|
case literal_value(31 downto 0) is
|
1352 |
|
|
when X"00000001" =>
|
1353 |
|
|
if(registerb(31 downto 0) = registera(31 downto 0)) then
|
1354 |
|
|
instruction_offset := next_instruction;
|
1355 |
|
|
else
|
1356 |
|
|
instruction_offset := instruction_offset + 1;
|
1357 |
|
|
end if;
|
1358 |
|
|
when X"00000002" =>
|
1359 |
|
|
if(registerb(31 downto 0) = registerb(31 downto 0)) then
|
1360 |
|
|
instruction_offset := next_instruction;
|
1361 |
|
|
else
|
1362 |
|
|
instruction_offset := instruction_offset + 1;
|
1363 |
|
|
end if;
|
1364 |
|
|
when X"00000003" =>
|
1365 |
|
|
if(registerb(31 downto 0) = registerc(31 downto 0)) then
|
1366 |
|
|
instruction_offset := next_instruction;
|
1367 |
|
|
else
|
1368 |
|
|
instruction_offset := instruction_offset + 1;
|
1369 |
|
|
end if;
|
1370 |
|
|
when X"00000004" =>
|
1371 |
|
|
if(registerb(31 downto 0) = registerd(31 downto 0)) then
|
1372 |
|
|
instruction_offset := next_instruction;
|
1373 |
|
|
else
|
1374 |
|
|
instruction_offset := instruction_offset + 1;
|
1375 |
|
|
end if;
|
1376 |
|
|
when X"00000005" =>
|
1377 |
|
|
if(registerb(31 downto 0) = reg_user_int(31 downto 0)) then
|
1378 |
|
|
instruction_offset := next_instruction;
|
1379 |
|
|
else
|
1380 |
|
|
instruction_offset := instruction_offset + 1;
|
1381 |
|
|
end if;
|
1382 |
|
|
when others =>
|
1383 |
|
|
instruction_offset := next_instruction;
|
1384 |
|
|
end case;
|
1385 |
|
|
|
1386 |
|
|
when regc =>
|
1387 |
|
|
case literal_value(31 downto 0) is
|
1388 |
|
|
when X"00000001" =>
|
1389 |
|
|
if(registerc(31 downto 0) = registera(31 downto 0)) then
|
1390 |
|
|
instruction_offset := next_instruction;
|
1391 |
|
|
else
|
1392 |
|
|
instruction_offset := instruction_offset + 1;
|
1393 |
|
|
end if;
|
1394 |
|
|
when X"00000002" =>
|
1395 |
|
|
if(registerc(31 downto 0) = registerb(31 downto 0)) then
|
1396 |
|
|
instruction_offset := next_instruction;
|
1397 |
|
|
else
|
1398 |
|
|
instruction_offset := instruction_offset + 1;
|
1399 |
|
|
end if;
|
1400 |
|
|
when X"00000003" =>
|
1401 |
|
|
if(registerc(31 downto 0) = registerc(31 downto 0)) then
|
1402 |
|
|
instruction_offset := next_instruction;
|
1403 |
|
|
else
|
1404 |
|
|
instruction_offset := instruction_offset + 1;
|
1405 |
|
|
end if;
|
1406 |
|
|
when X"00000004" =>
|
1407 |
|
|
if(registerc(31 downto 0) = registerd(31 downto 0)) then
|
1408 |
|
|
instruction_offset := next_instruction;
|
1409 |
|
|
else
|
1410 |
|
|
instruction_offset := instruction_offset + 1;
|
1411 |
|
|
end if;
|
1412 |
|
|
when X"00000005" =>
|
1413 |
|
|
if(registerc(31 downto 0) = reg_user_int(31 downto 0)) then
|
1414 |
|
|
instruction_offset := next_instruction;
|
1415 |
|
|
else
|
1416 |
|
|
instruction_offset := instruction_offset + 1;
|
1417 |
|
|
end if;
|
1418 |
|
|
when others =>
|
1419 |
|
|
instruction_offset := next_instruction;
|
1420 |
|
|
end case;
|
1421 |
|
|
|
1422 |
|
|
when regd =>
|
1423 |
|
|
case literal_value(31 downto 0) is
|
1424 |
|
|
when X"00000001" =>
|
1425 |
|
|
if(registerd(31 downto 0) = registera(31 downto 0)) then
|
1426 |
|
|
instruction_offset := next_instruction;
|
1427 |
|
|
else
|
1428 |
|
|
instruction_offset := instruction_offset + 1;
|
1429 |
|
|
end if;
|
1430 |
|
|
when X"00000002" =>
|
1431 |
|
|
if(registerd(31 downto 0) = registerb(31 downto 0)) then
|
1432 |
|
|
instruction_offset := next_instruction;
|
1433 |
|
|
else
|
1434 |
|
|
instruction_offset := instruction_offset + 1;
|
1435 |
|
|
end if;
|
1436 |
|
|
when X"00000003" =>
|
1437 |
|
|
if(registerd(31 downto 0) = registerc(31 downto 0)) then
|
1438 |
|
|
instruction_offset := next_instruction;
|
1439 |
|
|
else
|
1440 |
|
|
instruction_offset := instruction_offset + 1;
|
1441 |
|
|
end if;
|
1442 |
|
|
when X"00000004" =>
|
1443 |
|
|
if(registerd(31 downto 0) = registerd(31 downto 0)) then
|
1444 |
|
|
instruction_offset := next_instruction;
|
1445 |
|
|
else
|
1446 |
|
|
instruction_offset := instruction_offset + 1;
|
1447 |
|
|
end if;
|
1448 |
|
|
when X"00000005" =>
|
1449 |
|
|
if(registerd(31 downto 0) = reg_user_int(31 downto 0)) then
|
1450 |
|
|
instruction_offset := next_instruction;
|
1451 |
|
|
else
|
1452 |
|
|
instruction_offset := instruction_offset + 1;
|
1453 |
|
|
end if;
|
1454 |
|
|
when others =>
|
1455 |
|
|
instruction_offset := next_instruction;
|
1456 |
|
|
end case;
|
1457 |
|
|
|
1458 |
|
|
when reguser =>
|
1459 |
|
|
case literal_value(31 downto 0) is
|
1460 |
|
|
when X"00000001" =>
|
1461 |
|
|
if(reg_user_int(31 downto 0) = registera(31 downto 0)) then
|
1462 |
|
|
instruction_offset := next_instruction;
|
1463 |
|
|
else
|
1464 |
|
|
instruction_offset := instruction_offset + 1;
|
1465 |
|
|
end if;
|
1466 |
|
|
when X"00000002" =>
|
1467 |
|
|
if(reg_user_int(31 downto 0) = registerb(31 downto 0)) then
|
1468 |
|
|
instruction_offset := next_instruction;
|
1469 |
|
|
else
|
1470 |
|
|
instruction_offset := instruction_offset + 1;
|
1471 |
|
|
end if;
|
1472 |
|
|
when X"00000003" =>
|
1473 |
|
|
if(reg_user_int(31 downto 0) = registerc(31 downto 0)) then
|
1474 |
|
|
instruction_offset := next_instruction;
|
1475 |
|
|
else
|
1476 |
|
|
instruction_offset := instruction_offset + 1;
|
1477 |
|
|
end if;
|
1478 |
|
|
when X"00000004" =>
|
1479 |
|
|
if(reg_user_int(31 downto 0) = registerd(31 downto 0)) then
|
1480 |
|
|
instruction_offset := next_instruction;
|
1481 |
|
|
else
|
1482 |
|
|
instruction_offset := instruction_offset + 1;
|
1483 |
|
|
end if;
|
1484 |
|
|
when X"00000005" =>
|
1485 |
|
|
if(reg_user_int(31 downto 0) = reg_user_int(31 downto 0)) then
|
1486 |
|
|
instruction_offset := next_instruction;
|
1487 |
|
|
else
|
1488 |
|
|
instruction_offset := instruction_offset + 1;
|
1489 |
|
|
end if;
|
1490 |
|
|
when others =>
|
1491 |
|
|
instruction_offset := next_instruction;
|
1492 |
|
|
end case;
|
1493 |
|
|
end case;
|
1494 |
|
|
|
1495 |
|
|
------------------------------------------------------------
|
1496 |
|
|
-- compi_e compares the value in the target register to the
|
1497 |
|
|
-- value in another register. If the two are equal than the
|
1498 |
|
|
-- next instruction is executed. If not, the next
|
1499 |
|
|
-- instruction is skipped.
|
1500 |
|
|
------------------------------------------------------------
|
1501 |
|
|
when compi_ne =>
|
1502 |
|
|
case register_sel is
|
1503 |
|
|
when rega =>
|
1504 |
|
|
case literal_value(31 downto 0) is
|
1505 |
|
|
when X"00000001" => -- Register A to Register A
|
1506 |
|
|
if(registera(31 downto 0) /= registera(31 downto 0)) then
|
1507 |
|
|
instruction_offset := next_instruction;
|
1508 |
|
|
else
|
1509 |
|
|
instruction_offset := instruction_offset + 1;
|
1510 |
|
|
end if;
|
1511 |
|
|
when X"00000002" => -- Register A to Register B
|
1512 |
|
|
if(registera(31 downto 0) /= registerb(31 downto 0)) then
|
1513 |
|
|
instruction_offset := next_instruction;
|
1514 |
|
|
else
|
1515 |
|
|
instruction_offset := instruction_offset + 1;
|
1516 |
|
|
end if;
|
1517 |
|
|
when X"00000003" => -- Register A to Register C
|
1518 |
|
|
if(registera(31 downto 0) /= registerc(31 downto 0)) then
|
1519 |
|
|
instruction_offset := next_instruction;
|
1520 |
|
|
else
|
1521 |
|
|
instruction_offset := instruction_offset + 1;
|
1522 |
|
|
end if;
|
1523 |
|
|
when X"00000004" => -- Register A to Register D
|
1524 |
|
|
if(registera(31 downto 0) /= registerd(31 downto 0)) then
|
1525 |
|
|
instruction_offset := next_instruction;
|
1526 |
|
|
else
|
1527 |
|
|
instruction_offset := instruction_offset + 1;
|
1528 |
|
|
end if;
|
1529 |
|
|
when X"00000005" => -- Register A to Register User
|
1530 |
|
|
if(registera(31 downto 0) /= reg_user_int(31 downto 0)) then
|
1531 |
|
|
instruction_offset := next_instruction;
|
1532 |
|
|
else
|
1533 |
|
|
instruction_offset := instruction_offset + 1;
|
1534 |
|
|
end if;
|
1535 |
|
|
when others =>
|
1536 |
|
|
instruction_offset := next_instruction;
|
1537 |
|
|
end case;
|
1538 |
|
|
|
1539 |
|
|
when regb =>
|
1540 |
|
|
case literal_value(31 downto 0) is
|
1541 |
|
|
when X"00000001" =>
|
1542 |
|
|
if(registerb(31 downto 0) /= registera(31 downto 0)) then
|
1543 |
|
|
instruction_offset := next_instruction;
|
1544 |
|
|
else
|
1545 |
|
|
instruction_offset := instruction_offset + 1;
|
1546 |
|
|
end if;
|
1547 |
|
|
when X"00000002" =>
|
1548 |
|
|
if(registerb(31 downto 0) /= registerb(31 downto 0)) then
|
1549 |
|
|
instruction_offset := next_instruction;
|
1550 |
|
|
else
|
1551 |
|
|
instruction_offset := instruction_offset + 1;
|
1552 |
|
|
end if;
|
1553 |
|
|
when X"00000003" =>
|
1554 |
|
|
if(registerb(31 downto 0) /= registerc(31 downto 0)) then
|
1555 |
|
|
instruction_offset := next_instruction;
|
1556 |
|
|
else
|
1557 |
|
|
instruction_offset := instruction_offset + 1;
|
1558 |
|
|
end if;
|
1559 |
|
|
when X"00000004" =>
|
1560 |
|
|
if(registerb(31 downto 0) /= registerd(31 downto 0)) then
|
1561 |
|
|
instruction_offset := next_instruction;
|
1562 |
|
|
else
|
1563 |
|
|
instruction_offset := instruction_offset + 1;
|
1564 |
|
|
end if;
|
1565 |
|
|
when X"00000005" =>
|
1566 |
|
|
if(registerb(31 downto 0) /= reg_user_int(31 downto 0)) then
|
1567 |
|
|
instruction_offset := next_instruction;
|
1568 |
|
|
else
|
1569 |
|
|
instruction_offset := instruction_offset + 1;
|
1570 |
|
|
end if;
|
1571 |
|
|
when others =>
|
1572 |
|
|
instruction_offset := next_instruction;
|
1573 |
|
|
end case;
|
1574 |
|
|
|
1575 |
|
|
when regc =>
|
1576 |
|
|
case literal_value(31 downto 0) is
|
1577 |
|
|
when X"00000001" =>
|
1578 |
|
|
if(registerc(31 downto 0) /= registera(31 downto 0)) then
|
1579 |
|
|
instruction_offset := next_instruction;
|
1580 |
|
|
else
|
1581 |
|
|
instruction_offset := instruction_offset + 1;
|
1582 |
|
|
end if;
|
1583 |
|
|
when X"00000002" =>
|
1584 |
|
|
if(registerc(31 downto 0) /= registerb(31 downto 0)) then
|
1585 |
|
|
instruction_offset := next_instruction;
|
1586 |
|
|
else
|
1587 |
|
|
instruction_offset := instruction_offset + 1;
|
1588 |
|
|
end if;
|
1589 |
|
|
when X"00000003" =>
|
1590 |
|
|
if(registerc(31 downto 0) /= registerc(31 downto 0)) then
|
1591 |
|
|
instruction_offset := next_instruction;
|
1592 |
|
|
else
|
1593 |
|
|
instruction_offset := instruction_offset + 1;
|
1594 |
|
|
end if;
|
1595 |
|
|
when X"00000004" =>
|
1596 |
|
|
if(registerc(31 downto 0) /= registerd(31 downto 0)) then
|
1597 |
|
|
instruction_offset := next_instruction;
|
1598 |
|
|
else
|
1599 |
|
|
instruction_offset := instruction_offset + 1;
|
1600 |
|
|
end if;
|
1601 |
|
|
when X"00000005" =>
|
1602 |
|
|
if(registerc(31 downto 0) /= reg_user_int(31 downto 0)) then
|
1603 |
|
|
instruction_offset := next_instruction;
|
1604 |
|
|
else
|
1605 |
|
|
instruction_offset := instruction_offset + 1;
|
1606 |
|
|
end if;
|
1607 |
|
|
when others =>
|
1608 |
|
|
instruction_offset := next_instruction;
|
1609 |
|
|
end case;
|
1610 |
|
|
|
1611 |
|
|
when regd =>
|
1612 |
|
|
case literal_value(31 downto 0) is
|
1613 |
|
|
when X"00000001" =>
|
1614 |
|
|
if(registerd(31 downto 0) /= registera(31 downto 0)) then
|
1615 |
|
|
instruction_offset := next_instruction;
|
1616 |
|
|
else
|
1617 |
|
|
instruction_offset := instruction_offset + 1;
|
1618 |
|
|
end if;
|
1619 |
|
|
when X"00000002" =>
|
1620 |
|
|
if(registerd(31 downto 0) /= registerb(31 downto 0)) then
|
1621 |
|
|
instruction_offset := next_instruction;
|
1622 |
|
|
else
|
1623 |
|
|
instruction_offset := instruction_offset + 1;
|
1624 |
|
|
end if;
|
1625 |
|
|
when X"00000003" =>
|
1626 |
|
|
if(registerd(31 downto 0) /= registerc(31 downto 0)) then
|
1627 |
|
|
instruction_offset := next_instruction;
|
1628 |
|
|
else
|
1629 |
|
|
instruction_offset := instruction_offset + 1;
|
1630 |
|
|
end if;
|
1631 |
|
|
when X"00000004" =>
|
1632 |
|
|
if(registerd(31 downto 0) /= registerd(31 downto 0)) then
|
1633 |
|
|
instruction_offset := next_instruction;
|
1634 |
|
|
else
|
1635 |
|
|
instruction_offset := instruction_offset + 1;
|
1636 |
|
|
end if;
|
1637 |
|
|
when X"00000005" =>
|
1638 |
|
|
if(registerd(31 downto 0) /= reg_user_int(31 downto 0)) then
|
1639 |
|
|
instruction_offset := next_instruction;
|
1640 |
|
|
else
|
1641 |
|
|
instruction_offset := instruction_offset + 1;
|
1642 |
|
|
end if;
|
1643 |
|
|
when others =>
|
1644 |
|
|
instruction_offset := next_instruction;
|
1645 |
|
|
end case;
|
1646 |
|
|
|
1647 |
|
|
when reguser =>
|
1648 |
|
|
case literal_value(31 downto 0) is
|
1649 |
|
|
when X"00000001" =>
|
1650 |
|
|
if(reg_user_int(31 downto 0) /= registera(31 downto 0)) then
|
1651 |
|
|
instruction_offset := next_instruction;
|
1652 |
|
|
else
|
1653 |
|
|
instruction_offset := instruction_offset + 1;
|
1654 |
|
|
end if;
|
1655 |
|
|
when X"00000002" =>
|
1656 |
|
|
if(reg_user_int(31 downto 0) /= registerb(31 downto 0)) then
|
1657 |
|
|
instruction_offset := next_instruction;
|
1658 |
|
|
else
|
1659 |
|
|
instruction_offset := instruction_offset + 1;
|
1660 |
|
|
end if;
|
1661 |
|
|
when X"00000003" =>
|
1662 |
|
|
if(reg_user_int(31 downto 0) /= registerc(31 downto 0)) then
|
1663 |
|
|
instruction_offset := next_instruction;
|
1664 |
|
|
else
|
1665 |
|
|
instruction_offset := instruction_offset + 1;
|
1666 |
|
|
end if;
|
1667 |
|
|
when X"00000004" =>
|
1668 |
|
|
if(reg_user_int(31 downto 0) /= registerd(31 downto 0)) then
|
1669 |
|
|
instruction_offset := next_instruction;
|
1670 |
|
|
else
|
1671 |
|
|
instruction_offset := instruction_offset + 1;
|
1672 |
|
|
end if;
|
1673 |
|
|
when X"00000005" =>
|
1674 |
|
|
if(reg_user_int(31 downto 0) /= reg_user_int(31 downto 0)) then
|
1675 |
|
|
instruction_offset := next_instruction;
|
1676 |
|
|
else
|
1677 |
|
|
instruction_offset := instruction_offset + 1;
|
1678 |
|
|
end if;
|
1679 |
|
|
when others =>
|
1680 |
|
|
instruction_offset := next_instruction;
|
1681 |
|
|
|
1682 |
|
|
end case;
|
1683 |
|
|
|
1684 |
|
|
end case;
|
1685 |
|
|
------------------------------------------------------------
|
1686 |
|
|
-- ldrr loads one register with contents from another
|
1687 |
|
|
------------------------------------------------------------
|
1688 |
|
|
when ldrr =>
|
1689 |
|
|
case register_sel is
|
1690 |
|
|
when rega =>
|
1691 |
|
|
case literal_value(31 downto 0) is
|
1692 |
|
|
when X"00000001" =>
|
1693 |
|
|
registera(31 downto 0) <= registera(31 downto 0);
|
1694 |
|
|
when X"00000002" =>
|
1695 |
|
|
registera(31 downto 0) <= registerb(31 downto 0);
|
1696 |
|
|
when X"00000003" =>
|
1697 |
|
|
registera(31 downto 0) <= registerc(31 downto 0);
|
1698 |
|
|
when X"00000004" =>
|
1699 |
|
|
registera(31 downto 0) <= registerd(31 downto 0);
|
1700 |
|
|
when X"00000005" =>
|
1701 |
|
|
registera(31 downto 0) <= reg_user_int(31 downto 0);
|
1702 |
|
|
when others =>
|
1703 |
|
|
end case;
|
1704 |
|
|
when regb =>
|
1705 |
|
|
case literal_value(31 downto 0) is
|
1706 |
|
|
when X"00000001" =>
|
1707 |
|
|
registerb(31 downto 0) <= registera(31 downto 0);
|
1708 |
|
|
when X"00000002" =>
|
1709 |
|
|
registerb(31 downto 0) <= registerb(31 downto 0);
|
1710 |
|
|
when X"00000003" =>
|
1711 |
|
|
registerb(31 downto 0) <= registerc(31 downto 0);
|
1712 |
|
|
when X"00000004" =>
|
1713 |
|
|
registerb(31 downto 0) <= registerd(31 downto 0);
|
1714 |
|
|
when X"00000005" =>
|
1715 |
|
|
registerb(31 downto 0) <= reg_user_int(31 downto 0);
|
1716 |
|
|
when others =>
|
1717 |
|
|
end case;
|
1718 |
|
|
when regc =>
|
1719 |
|
|
case literal_value(31 downto 0) is
|
1720 |
|
|
when X"00000001" =>
|
1721 |
|
|
registerc(31 downto 0) <= registera(31 downto 0);
|
1722 |
|
|
when X"00000002" =>
|
1723 |
|
|
registerc(31 downto 0) <= registerb(31 downto 0);
|
1724 |
|
|
when X"00000003" =>
|
1725 |
|
|
registerc(31 downto 0) <= registerc(31 downto 0);
|
1726 |
|
|
when X"00000004" =>
|
1727 |
|
|
registerc(31 downto 0) <= registerd(31 downto 0);
|
1728 |
|
|
when X"00000005" =>
|
1729 |
|
|
registerc(31 downto 0) <= reg_user_int(31 downto 0);
|
1730 |
|
|
when others =>
|
1731 |
|
|
end case;
|
1732 |
|
|
when regd =>
|
1733 |
|
|
case literal_value(31 downto 0) is
|
1734 |
|
|
when X"00000001" =>
|
1735 |
|
|
registerd(31 downto 0) <= registera(31 downto 0);
|
1736 |
|
|
when X"00000002" =>
|
1737 |
|
|
registerd(31 downto 0) <= registerb(31 downto 0);
|
1738 |
|
|
when X"00000003" =>
|
1739 |
|
|
registerd(31 downto 0) <= registerc(31 downto 0);
|
1740 |
|
|
when X"00000004" =>
|
1741 |
|
|
registerd(31 downto 0) <= registerd(31 downto 0);
|
1742 |
|
|
when X"00000005" =>
|
1743 |
|
|
registerd(31 downto 0) <= reg_user_int(31 downto 0);
|
1744 |
|
|
when others =>
|
1745 |
|
|
end case;
|
1746 |
|
|
when reguser =>
|
1747 |
|
|
case literal_value(31 downto 0) is
|
1748 |
|
|
when X"00000001" =>
|
1749 |
|
|
reg_user_int(31 downto 0) <= registera(31 downto 0);
|
1750 |
|
|
when X"00000002" =>
|
1751 |
|
|
reg_user_int(31 downto 0) <= registerb(31 downto 0);
|
1752 |
|
|
when X"00000003" =>
|
1753 |
|
|
reg_user_int(31 downto 0) <= registerc(31 downto 0);
|
1754 |
|
|
when X"00000004" =>
|
1755 |
|
|
reg_user_int(31 downto 0) <= registerd(31 downto 0);
|
1756 |
|
|
when X"00000005" =>
|
1757 |
|
|
reg_user_int(31 downto 0) <= reg_user_int(31 downto 0);
|
1758 |
|
|
when others =>
|
1759 |
|
|
end case;
|
1760 |
|
|
when others =>
|
1761 |
|
|
end case;
|
1762 |
|
|
instruction_offset := next_instruction;
|
1763 |
|
|
|
1764 |
|
|
------------------------------------------------------------
|
1765 |
|
|
-- shl shifts the contents of the target register left by
|
1766 |
|
|
-- the number of bit positions in the literal value.
|
1767 |
|
|
------------------------------------------------------------
|
1768 |
|
|
when shl =>
|
1769 |
|
|
case register_sel is
|
1770 |
|
|
when rega =>
|
1771 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0)) loop
|
1772 |
|
|
registera(31 downto 0) <= registera(30 downto 0) & '0';
|
1773 |
|
|
wait for 1 fs;
|
1774 |
|
|
end loop;
|
1775 |
|
|
when regb =>
|
1776 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0)) loop
|
1777 |
|
|
registerb(31 downto 0) <= registerb(30 downto 0) & '0';
|
1778 |
|
|
wait for 1 fs;
|
1779 |
|
|
end loop;
|
1780 |
|
|
when regc =>
|
1781 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0)) loop
|
1782 |
|
|
registerc(31 downto 0) <= registerc(30 downto 0) & '0';
|
1783 |
|
|
wait for 1 fs;
|
1784 |
|
|
end loop;
|
1785 |
|
|
when regd =>
|
1786 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0)) loop
|
1787 |
|
|
registerd(31 downto 0) <= registerd(30 downto 0) & '0';
|
1788 |
|
|
wait for 1 fs;
|
1789 |
|
|
end loop;
|
1790 |
|
|
when reguser =>
|
1791 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0)) loop
|
1792 |
|
|
reg_user_int(31 downto 0) <= reg_user_int(30 downto 0) & '0';
|
1793 |
|
|
wait for 1 fs;
|
1794 |
|
|
end loop;
|
1795 |
|
|
end case;
|
1796 |
|
|
instruction_offset := next_instruction;
|
1797 |
|
|
|
1798 |
|
|
------------------------------------------------------------
|
1799 |
|
|
-- shr shifts the contents of the target register right by
|
1800 |
|
|
-- the number of bit positions in the literal value.
|
1801 |
|
|
------------------------------------------------------------
|
1802 |
|
|
when shr =>
|
1803 |
|
|
case register_sel is
|
1804 |
|
|
when rega =>
|
1805 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0) - X"00000001") loop
|
1806 |
|
|
registera(31 downto 0) <= '0' & registera(31 downto 1);
|
1807 |
|
|
wait for 1 fs;
|
1808 |
|
|
end loop;
|
1809 |
|
|
when regb =>
|
1810 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0) - X"00000001") loop
|
1811 |
|
|
registerb(31 downto 0) <= '0' & registerb(31 downto 1);
|
1812 |
|
|
wait for 1 fs;
|
1813 |
|
|
end loop;
|
1814 |
|
|
when regc =>
|
1815 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0) - X"00000001") loop
|
1816 |
|
|
registerc(31 downto 0) <= '0' & registerc(31 downto 1);
|
1817 |
|
|
wait for 1 fs;
|
1818 |
|
|
end loop;
|
1819 |
|
|
when regd =>
|
1820 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0) - X"00000001") loop
|
1821 |
|
|
registerd(31 downto 0) <= '0' & registerd(31 downto 1);
|
1822 |
|
|
wait for 1 fs;
|
1823 |
|
|
end loop;
|
1824 |
|
|
when reguser =>
|
1825 |
|
|
for i in 0 to CONV_INTEGER(literal_value(31 downto 0) - X"00000001") loop
|
1826 |
|
|
reg_user_int(31 downto 0) <= '0' & reg_user_int(31 downto 1);
|
1827 |
|
|
wait for 1 fs;
|
1828 |
|
|
end loop;
|
1829 |
|
|
end case;
|
1830 |
|
|
instruction_offset := next_instruction;
|
1831 |
|
|
|
1832 |
|
|
|
1833 |
|
|
|
1834 |
|
|
when others =>
|
1835 |
|
|
|
1836 |
|
|
|
1837 |
|
|
end case;
|
1838 |
|
|
|
1839 |
|
|
end loop;
|
1840 |
|
|
wait for 50 ms;
|
1841 |
|
|
end process;
|
1842 |
|
|
|
1843 |
|
|
|
1844 |
|
|
end Behavioral;
|