-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecode.vhd
97 lines (95 loc) · 3.02 KB
/
decode.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity decode is
port (input : in std_logic_vector (7 downto 0);
reg_we : out std_logic;
out_we : out std_logic;
reg_a_we: out std_logic;
alu_op : out std_logic_vector (2 downto 0);
bus_sel : out std_logic_vector (1 downto 0));
end decode;
architecture decode_beh of decode is
begin
process(input)
begin
case input is
-- IN
when x"01" => bus_sel <= "10";
alu_op <= "000";
reg_a_we <= '0';
out_we <= '0';
reg_we <= '1';
-- OUT
when x"02" => bus_sel <= "00";
alu_op <= "000";
reg_a_we <= '0';
out_we <= '1';
reg_we <= '0';
-- MOV
when x"03" => bus_sel <= "00";
alu_op <= "000";
reg_a_we <= '0';
out_we <= '0';
reg_we <= '1';
-- LDA
when x"04" => bus_sel <= "00";
alu_op <= "000";
reg_a_we <= '1';
out_we <= '0';
reg_we <= '0';
-- LDI
when x"05" => bus_sel <= "01";
alu_op <= "000";
reg_a_we <= '1';
out_we <= '0';
reg_we <= '0';
-- ADD
when x"0A" => bus_sel <= "00";
alu_op <= "010";
reg_a_we <= '0';
out_we <= '0';
reg_we <= '1';
-- SUB
when x"0B" => bus_sel <= "00";
alu_op <= "011";
reg_a_we <= '0';
out_we <= '0';
reg_we <= '1';
-- AND
when x"0C" => bus_sel <= "00";
alu_op <= "100";
reg_a_we <= '0';
out_we <= '0';
reg_we <= '1';
-- OR
when x"0D" => bus_sel <= "00";
alu_op <= "101";
reg_a_we <= '0';
out_we <= '0';
reg_we <= '1';
-- XOR
when x"0E" => bus_sel <= "00";
alu_op <= "110";
reg_a_we <= '0';
out_we <= '0';
reg_we <= '1';
-- SHL
when x"14" => bus_sel <= "00";
alu_op <= "001";
reg_a_we <= '0';
out_we <= '0';
reg_we <= '1';
-- SHR
when x"15" => bus_sel <= "00";
alu_op <= "111";
reg_a_we <= '0';
out_we <= '0';
reg_we <= '1';
when others => bus_sel <= "XX";
alu_op <= "XXX";
reg_a_we <= 'X';
out_we <= 'X';
reg_we <= 'X';
end case;
end process;
end decode_beh;