1 |
2 |
Valerio63 |
library IEEE;
|
2 |
|
|
use IEEE.std_logic_1164.all; -- defines std_logic types
|
3 |
|
|
use IEEE.STD_LOGIC_unsigned.all;
|
4 |
|
|
use IEEE.STD_LOGIC_arith.all;
|
5 |
|
|
|
6 |
|
|
-- opcode decimal instructions and prefetch prediction logic
|
7 |
|
|
entity pre_dec is
|
8 |
|
|
port( op: in STD_LOGIC_VECTOR(7 downto 0);
|
9 |
|
|
fetch: in STD_LOGIC;
|
10 |
|
|
ei: out STD_LOGIC;
|
11 |
|
|
dec: out STD_LOGIC
|
12 |
|
|
);
|
13 |
|
|
end pre_dec;
|
14 |
|
|
|
15 |
|
|
architecture comb of pre_dec is
|
16 |
|
|
constant NOP_OP: STD_LOGIC_VECTOR(7 downto 0) := "11101010"; -- 0xEA NOP
|
17 |
|
|
constant CLC_OP: STD_LOGIC_VECTOR(7 downto 0) := "00011000"; -- 0x18 CLC 0->C
|
18 |
|
|
constant SEC_OP: STD_LOGIC_VECTOR(7 downto 0) := "00111000"; -- 0x38 SEC 1->C
|
19 |
|
|
constant CLI_OP: STD_LOGIC_VECTOR(7 downto 0) := "01011000"; -- 0x58 CLI 0->I
|
20 |
|
|
constant SEI_OP: STD_LOGIC_VECTOR(7 downto 0) := "01111000"; -- 0x78 SEI 1->I
|
21 |
|
|
constant CLV_OP: STD_LOGIC_VECTOR(7 downto 0) := "10111000"; -- 0xB8 CLV 0->V
|
22 |
|
|
constant CLD_OP: STD_LOGIC_VECTOR(7 downto 0) := "11011000"; -- 0xD8 CLD 0->D
|
23 |
|
|
constant SED_OP: STD_LOGIC_VECTOR(7 downto 0) := "11111000"; -- 0xF8 SED 1->D
|
24 |
|
|
constant TAX_OP: STD_LOGIC_VECTOR(7 downto 0) := "10101010"; -- 0xAA TAX A->X
|
25 |
|
|
constant TAY_OP: STD_LOGIC_VECTOR(7 downto 0) := "10101000"; -- 0xA8 TAY A->Y
|
26 |
|
|
constant TXA_OP: STD_LOGIC_VECTOR(7 downto 0) := "10001010"; -- 0x8A TXA X->A
|
27 |
|
|
constant TYA_OP: STD_LOGIC_VECTOR(7 downto 0) := "10011000"; -- 0x98 TYA Y->A
|
28 |
|
|
constant TXY_OP: STD_LOGIC_VECTOR(7 downto 0) := "10011011"; -- 0x9B TXY X->Y
|
29 |
|
|
constant TYX_OP: STD_LOGIC_VECTOR(7 downto 0) := "10111011"; -- 0xBB TYX Y->X
|
30 |
|
|
constant TXS_OP: STD_LOGIC_VECTOR(7 downto 0) := "10011010"; -- 0x9A TXS X->S
|
31 |
|
|
constant TSX_OP: STD_LOGIC_VECTOR(7 downto 0) := "10111010"; -- 0xBA TSX S->X
|
32 |
|
|
constant TCD_OP: STD_LOGIC_VECTOR(7 downto 0) := "01011011"; -- 0x5B TCD C->D
|
33 |
|
|
constant TDC_OP: STD_LOGIC_VECTOR(7 downto 0) := "01111011"; -- 0x7B TDC D->C
|
34 |
|
|
constant TCS_OP: STD_LOGIC_VECTOR(7 downto 0) := "00011011"; -- 0x1B TCS C->S
|
35 |
|
|
constant TSC_OP: STD_LOGIC_VECTOR(7 downto 0) := "00111011"; -- 0x3B TSC S->C
|
36 |
|
|
constant INX_OP: STD_LOGIC_VECTOR(7 downto 0) := "11101000"; -- 0xE8 INX X +1
|
37 |
|
|
constant DEX_OP: STD_LOGIC_VECTOR(7 downto 0) := "11001010"; -- 0xCA DEX X -1
|
38 |
|
|
constant INY_OP: STD_LOGIC_VECTOR(7 downto 0) := "11001000"; -- 0xC8 INY Y +1
|
39 |
|
|
constant DEY_OP: STD_LOGIC_VECTOR(7 downto 0) := "10001000"; -- 0x88 DEY Y -1
|
40 |
|
|
constant ASL_OP: STD_LOGIC_VECTOR(7 downto 0) := "00001010"; -- 0x0A ASL A
|
41 |
|
|
constant LSR_OP: STD_LOGIC_VECTOR(7 downto 0) := "01001010"; -- 0x4A LSR A
|
42 |
|
|
constant ROL_OP: STD_LOGIC_VECTOR(7 downto 0) := "00101010"; -- 0x2A ROL A
|
43 |
|
|
constant ROR_OP: STD_LOGIC_VECTOR(7 downto 0) := "01101010"; -- 0x6A ROR A
|
44 |
|
|
constant XCE_OP: STD_LOGIC_VECTOR(7 downto 0) := "11111011"; -- 0xFB XCE E<->C
|
45 |
|
|
constant XBA_OP: STD_LOGIC_VECTOR(7 downto 0) := "11101011"; -- 0xEB XBA (swap A/B)
|
46 |
|
|
constant WDM_OP: STD_LOGIC_VECTOR(7 downto 0) := "01000010"; -- 0x42 WDM
|
47 |
|
|
constant ADC1_OP: STD_LOGIC_VECTOR(7 downto 0) := "01100001"; -- 0x61 ADC ($xx,X)
|
48 |
|
|
constant ADC2_OP: STD_LOGIC_VECTOR(7 downto 0) := "01110001"; -- 0x71 ADC ($xx),Y
|
49 |
|
|
constant ADC3_OP: STD_LOGIC_VECTOR(7 downto 0) := "01100101"; -- 0x65 ADC $xx
|
50 |
|
|
constant ADC4_OP: STD_LOGIC_VECTOR(7 downto 0) := "01110101"; -- 0x75 ADC $xx,X
|
51 |
|
|
constant ADC5_OP: STD_LOGIC_VECTOR(7 downto 0) := "01101001"; -- 0x69 ADC #xx
|
52 |
|
|
constant ADC6_OP: STD_LOGIC_VECTOR(7 downto 0) := "01111001"; -- 0x79 ADC $xxxx,Y
|
53 |
|
|
constant ADC7_OP: STD_LOGIC_VECTOR(7 downto 0) := "01111101"; -- 0x7D ADC $xxxx,X
|
54 |
|
|
constant SBC1_OP: STD_LOGIC_VECTOR(7 downto 0) := "11100001"; -- 0xE1 SBC ($xx,X)
|
55 |
|
|
constant SBC2_OP: STD_LOGIC_VECTOR(7 downto 0) := "11110001"; -- 0xF1 SBC ($xx),Y
|
56 |
|
|
constant SBC3_OP: STD_LOGIC_VECTOR(7 downto 0) := "11100101"; -- 0xE5 SBC $xx
|
57 |
|
|
constant SBC4_OP: STD_LOGIC_VECTOR(7 downto 0) := "11110101"; -- 0xF5 SBC $xx,X
|
58 |
|
|
constant SBC5_OP: STD_LOGIC_VECTOR(7 downto 0) := "11101001"; -- 0xE9 SBC #xx
|
59 |
|
|
constant SBC6_OP: STD_LOGIC_VECTOR(7 downto 0) := "11111001"; -- 0xF9 SBC $xxxx,Y
|
60 |
|
|
constant SBC7_OP: STD_LOGIC_VECTOR(7 downto 0) := "11111101"; -- 0xFD SBC $xxxx,X
|
61 |
|
|
|
62 |
|
|
signal eoi: STD_LOGIC;
|
63 |
|
|
begin
|
64 |
|
|
process(op)
|
65 |
|
|
begin
|
66 |
|
|
case op is
|
67 |
|
|
when NOP_OP => eoi <= '1';
|
68 |
|
|
dec <= '0';
|
69 |
|
|
when CLC_OP => eoi <= '1';
|
70 |
|
|
dec <= '0';
|
71 |
|
|
when SEC_OP => eoi <= '1';
|
72 |
|
|
dec <= '0';
|
73 |
|
|
when CLI_OP => eoi <= '1';
|
74 |
|
|
dec <= '0';
|
75 |
|
|
when SEI_OP => eoi <= '1';
|
76 |
|
|
dec <= '0';
|
77 |
|
|
when CLV_OP => eoi <= '1';
|
78 |
|
|
dec <= '0';
|
79 |
|
|
when CLD_OP => eoi <= '1';
|
80 |
|
|
dec <= '0';
|
81 |
|
|
when SED_OP => eoi <= '1';
|
82 |
|
|
dec <= '0';
|
83 |
|
|
when TAX_OP => eoi <= '1';
|
84 |
|
|
dec <= '0';
|
85 |
|
|
when TAY_OP => eoi <= '1';
|
86 |
|
|
dec <= '0';
|
87 |
|
|
when TCD_OP => eoi <= '1';
|
88 |
|
|
dec <= '0';
|
89 |
|
|
when TDC_OP => eoi <= '1';
|
90 |
|
|
dec <= '0';
|
91 |
|
|
when TXA_OP => eoi <= '1';
|
92 |
|
|
dec <= '0';
|
93 |
|
|
when TYA_OP => eoi <= '1';
|
94 |
|
|
dec <= '0';
|
95 |
|
|
when TXY_OP => eoi <= '1';
|
96 |
|
|
dec <= '0';
|
97 |
|
|
when TYX_OP => eoi <= '1';
|
98 |
|
|
dec <= '0';
|
99 |
|
|
when TXS_OP => eoi <= '1';
|
100 |
|
|
dec <= '0';
|
101 |
|
|
when TSX_OP => eoi <= '1';
|
102 |
|
|
dec <= '0';
|
103 |
|
|
when TCS_OP => eoi <= '1';
|
104 |
|
|
dec <= '0';
|
105 |
|
|
when TSC_OP => eoi <= '1';
|
106 |
|
|
dec <= '0';
|
107 |
|
|
when INX_OP => eoi <= '1';
|
108 |
|
|
dec <= '0';
|
109 |
|
|
when DEX_OP => eoi <= '1';
|
110 |
|
|
dec <= '0';
|
111 |
|
|
when INY_OP => eoi <= '1';
|
112 |
|
|
dec <= '0';
|
113 |
|
|
when DEY_OP => eoi <= '1';
|
114 |
|
|
dec <= '0';
|
115 |
|
|
when ASL_OP => eoi <= '1';
|
116 |
|
|
dec <= '0';
|
117 |
|
|
when LSR_OP => eoi <= '1';
|
118 |
|
|
dec <= '0';
|
119 |
|
|
when ROL_OP => eoi <= '1';
|
120 |
|
|
dec <= '0';
|
121 |
|
|
when ROR_OP => eoi <= '1';
|
122 |
|
|
dec <= '0';
|
123 |
|
|
when XCE_OP => eoi <= '1';
|
124 |
|
|
dec <= '0';
|
125 |
|
|
when XBA_OP => eoi <= '1';
|
126 |
|
|
dec <= '0';
|
127 |
|
|
when WDM_OP => eoi <= '1';
|
128 |
|
|
dec <= '0';
|
129 |
|
|
-- ADC/SBC
|
130 |
|
|
when ADC1_OP => eoi <= '0';
|
131 |
|
|
dec <= '1';
|
132 |
|
|
when ADC2_OP => eoi <= '0';
|
133 |
|
|
dec <= '1';
|
134 |
|
|
-- when ADC3_OP => eoi <= '0';
|
135 |
|
|
-- dec <= '1';
|
136 |
|
|
when ADC4_OP => eoi <= '0';
|
137 |
|
|
dec <= '1';
|
138 |
|
|
when ADC5_OP => eoi <= '0';
|
139 |
|
|
dec <= '1';
|
140 |
|
|
when ADC6_OP => eoi <= '0';
|
141 |
|
|
dec <= '1';
|
142 |
|
|
when ADC7_OP => eoi <= '0';
|
143 |
|
|
dec <= '1';
|
144 |
|
|
when SBC1_OP => eoi <= '0';
|
145 |
|
|
dec <= '1';
|
146 |
|
|
when SBC2_OP => eoi <= '0';
|
147 |
|
|
dec <= '1';
|
148 |
|
|
when SBC3_OP => eoi <= '0';
|
149 |
|
|
dec <= '1';
|
150 |
|
|
when SBC4_OP => eoi <= '0';
|
151 |
|
|
dec <= '1';
|
152 |
|
|
when SBC5_OP => eoi <= '0';
|
153 |
|
|
dec <= '1';
|
154 |
|
|
when SBC6_OP => eoi <= '0';
|
155 |
|
|
dec <= '1';
|
156 |
|
|
when SBC7_OP => eoi <= '0';
|
157 |
|
|
dec <= '1';
|
158 |
|
|
when others => eoi <= '0';
|
159 |
|
|
dec <= '0';
|
160 |
|
|
end case;
|
161 |
|
|
end process;
|
162 |
|
|
ei <= eoi when fetch = '1' else '0';
|
163 |
|
|
end comb;
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|