-
Notifications
You must be signed in to change notification settings - Fork 7
/
instruction_reg.vhd
52 lines (37 loc) · 1.48 KB
/
instruction_reg.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
library ieee;
use ieee.std_logic_1164.all;
entity instruction_reg is
port(
i_clkin : in std_logic;
i_reset : in std_logic;
i_we : in std_logic; --Instruction register in (Active LOW)
i_oe : in std_logic; --Instruction register output (Active LOW)
i_data_bus_in : in std_logic_vector(7 downto 0);
o_data_bus_out : out std_logic_vector(7 downto 0);
o_instuction : out std_logic_vector(3 downto 0);
o_instreg_dbg_led : out std_logic_vector(7 downto 0)
);
end entity instruction_reg;
architecture rtl of instruction_reg is
--Instruction register
signal r_instruction_reg : std_logic_vector(7 downto 0) := (others => '0');
signal w_address : std_logic_vector(7 downto 0) := (others => '0');
begin
w_address(3 downto 0) <= r_instruction_reg(3 downto 0); --The address associated with the instruction is found in the 4 LSB
--Instruction register input
p_instreg_write : process(i_clkin,i_reset) is
begin
if i_reset = '0' then
r_instruction_reg <= (others => '0');
elsif rising_edge(i_clkin) then
if i_we = '0' and i_oe = '1' then
r_instruction_reg <= i_data_bus_in;
end if;
end if;
end process p_instreg_write;
--Instruction register output to the data bus
o_data_bus_out <= w_address when(i_oe = '0' and i_we = '1') else
(others => '0');
o_instuction <= r_instruction_reg(7 downto 4); --The 4 MSB is the instruction
o_instreg_dbg_led <= r_instruction_reg; --The debug LED is the instruction register
end rtl;