1
|
--test bench written by Alban Bourge @ TIMA
|
2
|
library ieee;
|
3
|
use ieee.std_logic_1164.all;
|
4
|
use ieee.numeric_std.all;
|
5
|
library work;
|
6
|
use work.pkg_tb.all;
|
7
|
|
8
|
entity prog is
|
9
|
port(
|
10
|
clock : in std_logic;
|
11
|
reset : in std_logic;
|
12
|
step : in std_logic;
|
13
|
instr_next : out instruction
|
14
|
);
|
15
|
end prog;
|
16
|
|
17
|
architecture rtl of prog is
|
18
|
|
19
|
signal instr_n : instruction := instr_rst;
|
20
|
|
21
|
--Table describing fsm behavior
|
22
|
constant fsm_behavior : table_behavior := (
|
23
|
--##PROGRAM_GOES_DOWN_HERE##--
|
24
|
0 => (state => Rst, context_uut => "00", arg => to_unsigned(0,ARG_WIDTH)),
|
25
|
1 => (state => Rst, context_uut => "00", arg => to_unsigned(0,ARG_WIDTH)),
|
26
|
2 => (state => Sig_start, context_uut => "01", arg => to_unsigned(0,ARG_WIDTH)),
|
27
|
3 => (state => Ack_data, context_uut => "01", arg => to_unsigned(2,ARG_WIDTH)),
|
28
|
4 => (state => Running, context_uut => "01", arg => to_unsigned(5,ARG_WIDTH)),
|
29
|
5 => (state => Cp_search, context_uut => "01", arg => to_unsigned(0,ARG_WIDTH)),
|
30
|
6 => (state => Idle, context_uut => "00", arg => to_unsigned(5,ARG_WIDTH)),
|
31
|
7 => (state => Rst_uut, context_uut => "00", arg => to_unsigned(0,ARG_WIDTH)),
|
32
|
8 => (state => Idle, context_uut => "00", arg => to_unsigned(5,ARG_WIDTH)),
|
33
|
9 => (state => Sig_start, context_uut => "10", arg => to_unsigned(0,ARG_WIDTH)),
|
34
|
10 => (state => Ack_data, context_uut => "10", arg => to_unsigned(2,ARG_WIDTH)),
|
35
|
11 => (state => Running, context_uut => "10", arg => to_unsigned(6,ARG_WIDTH)),
|
36
|
12 => (state => Cp_search, context_uut => "10", arg => to_unsigned(0,ARG_WIDTH)),
|
37
|
13 => (state => Idle, context_uut => "00", arg => to_unsigned(5,ARG_WIDTH)),
|
38
|
14 => (state => Rst_uut, context_uut => "00", arg => to_unsigned(0,ARG_WIDTH)),
|
39
|
15 => (state => Idle, context_uut => "00", arg => to_unsigned(5,ARG_WIDTH)),
|
40
|
16 => (state => Rest_ini0, context_uut => "01", arg => to_unsigned(0,ARG_WIDTH)),
|
41
|
17 => (state => Waitfor, context_uut => "01", arg => to_unsigned(1,ARG_WIDTH)),
|
42
|
18 => (state => Idle, context_uut => "00", arg => to_unsigned(5,ARG_WIDTH)),
|
43
|
19 => (state => Rst_uut, context_uut => "00", arg => to_unsigned(0,ARG_WIDTH)),
|
44
|
20 => (state => Idle, context_uut => "00", arg => to_unsigned(5,ARG_WIDTH)),
|
45
|
21 => (state => Rest_ini0, context_uut => "10", arg => to_unsigned(0,ARG_WIDTH)),
|
46
|
22 => (state => Waitfor, context_uut => "10", arg => to_unsigned(1,ARG_WIDTH)),
|
47
|
23 => (state => Stop, context_uut => "00", arg => to_unsigned(0,ARG_WIDTH)),
|
48
|
--##PROGRAM_GOES_OVER_HERE##--
|
49
|
others => instr_rst);
|
50
|
|
51
|
signal pc : unsigned(PC_SIZE - 1 downto 0) := (others => '0');
|
52
|
|
53
|
begin
|
54
|
|
55
|
drive_state : process (reset,clock) is
|
56
|
begin
|
57
|
if reset = '1' then
|
58
|
instr_n <= instr_rst;
|
59
|
pc <= (others => '0');
|
60
|
elsif rising_edge(clock) then
|
61
|
if (step = '1') then
|
62
|
pc <= pc + 1;
|
63
|
end if;
|
64
|
instr_n <= fsm_behavior(to_integer(pc));
|
65
|
end if;
|
66
|
end process drive_state;
|
67
|
|
68
|
--instr_next <= instr_n;
|
69
|
instr_next <= fsm_behavior(to_integer(pc));
|
70
|
|
71
|
end rtl;
|