1 |
2 |
ja_rd |
--##############################################################################
|
2 |
10 |
ja_rd |
-- light8080 : Intel 8080 binary compatible core
|
3 |
2 |
ja_rd |
--##############################################################################
|
4 |
10 |
ja_rd |
-- v1.1 (20 sep 2008) Microcode bug in INR fixed.
|
5 |
|
|
-- v1.0 (05 nov 2007) First release. Jose A. Ruiz.
|
6 |
|
|
--
|
7 |
19 |
ja_rd |
-- This file and all the light8080 project files are freeware (See COPYING.TXT)
|
8 |
3 |
ja_rd |
--##############################################################################
|
9 |
19 |
ja_rd |
-- (See timing diagrams at bottom of file. More comprehensive explainations can
|
10 |
|
|
-- be found in the design notes)
|
11 |
10 |
ja_rd |
--##############################################################################
|
12 |
2 |
ja_rd |
|
13 |
|
|
library IEEE;
|
14 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
15 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
16 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
17 |
|
|
|
18 |
|
|
--##############################################################################
|
19 |
|
|
-- vma : enable a memory or io r/w access.
|
20 |
|
|
-- io : access in progress is io (and not memory)
|
21 |
|
|
-- rd : read memory or io
|
22 |
|
|
-- wr : write memory or io
|
23 |
|
|
-- data_out : data output
|
24 |
|
|
-- addr_out : memory and io address
|
25 |
|
|
-- data_in : data input
|
26 |
|
|
-- halt : halt status (1 when in halt state)
|
27 |
|
|
-- inte : interrupt status (1 when enabled)
|
28 |
|
|
-- intr : interrupt request
|
29 |
|
|
-- inta : interrupt acknowledge
|
30 |
|
|
-- reset : synchronous reset
|
31 |
|
|
-- clk : clock
|
32 |
19 |
ja_rd |
--
|
33 |
|
|
-- (see timing diagrams at bottom of file)
|
34 |
2 |
ja_rd |
--##############################################################################
|
35 |
|
|
entity light8080 is
|
36 |
|
|
Port (
|
37 |
|
|
addr_out : out std_logic_vector(15 downto 0);
|
38 |
|
|
|
39 |
|
|
inta : out std_logic;
|
40 |
|
|
inte : out std_logic;
|
41 |
|
|
halt : out std_logic;
|
42 |
|
|
intr : in std_logic;
|
43 |
|
|
|
44 |
|
|
vma : out std_logic;
|
45 |
|
|
io : out std_logic;
|
46 |
|
|
rd : out std_logic;
|
47 |
|
|
wr : out std_logic;
|
48 |
19 |
ja_rd |
fetch : out std_logic;
|
49 |
2 |
ja_rd |
data_in : in std_logic_vector(7 downto 0);
|
50 |
|
|
data_out : out std_logic_vector(7 downto 0);
|
51 |
|
|
|
52 |
|
|
clk : in std_logic;
|
53 |
|
|
reset : in std_logic );
|
54 |
|
|
end light8080;
|
55 |
|
|
|
56 |
|
|
--##############################################################################
|
57 |
10 |
ja_rd |
-- All memory and io accesses are synchronous (rising clock edge). Signal vma
|
58 |
|
|
-- works as the master memory and io synchronous enable. More specifically:
|
59 |
2 |
ja_rd |
--
|
60 |
|
|
-- * All memory/io control signals (io,rd,wr) are valid only when vma is
|
61 |
|
|
-- high. They never activate when vms is inactive.
|
62 |
|
|
-- * Signals data_out and address are only valid when vma='1'. The high
|
63 |
10 |
ja_rd |
-- address byte is 0x00 for all io accesses.
|
64 |
|
|
-- * Signal data_in should be valid by the end of the cycle after vma='1',
|
65 |
|
|
-- data is clocked in by the rising clock edge.
|
66 |
2 |
ja_rd |
--
|
67 |
10 |
ja_rd |
-- All signals are assumed to be synchronous to the master clock. Prevention of
|
68 |
|
|
-- metastability, if necessary, is up to you.
|
69 |
|
|
--
|
70 |
|
|
-- Signal reset needs to be active for just 1 clock cycle (it is sampled on a
|
71 |
|
|
-- positive clock edge and is subject to setup and hold times).
|
72 |
4 |
ja_rd |
-- Once reset is deasserted, the first fetch at address 0x0000 will happen 4
|
73 |
2 |
ja_rd |
-- cycles later.
|
74 |
|
|
--
|
75 |
|
|
-- Signal intr is sampled on all positive clock edges. If asserted when inte is
|
76 |
4 |
ja_rd |
-- high, interrupts will be disabled, inta will be asserted high and a fetch
|
77 |
39 |
ja_rd |
-- cycle will occur immediately after the current instruction ends execution,
|
78 |
|
|
-- except if intr was asserted at the last cycle of an instruction. In that case
|
79 |
|
|
-- it will be honored after the next instruction ends.
|
80 |
|
|
-- The fetched instruction will be executed normally, except that PC will not
|
81 |
|
|
-- be valid in any subsequent fetch cycles of the same instruction,
|
82 |
10 |
ja_rd |
-- and will not be incremented (In practice, the same as the original 8080).
|
83 |
39 |
ja_rd |
-- inta will remain high for the duration of the fetched instruction, including
|
84 |
|
|
-- fetch and execution time (in the original 8080 it was high only for the
|
85 |
|
|
-- opcode fetch cycle).
|
86 |
10 |
ja_rd |
-- PC will not be autoincremented while inta is high, but it can be explicitly
|
87 |
39 |
ja_rd |
-- modified (e.g. RST, CALL, etc.). Again, the same as the original.
|
88 |
2 |
ja_rd |
-- Interrupts will be disabled upon assertion of inta, and remain disabled
|
89 |
4 |
ja_rd |
-- until explicitly enabled by the program (as in the original).
|
90 |
39 |
ja_rd |
-- If intr is asserted when inte is low, the interrupt will not be attended but
|
91 |
|
|
-- it will be registered in an int_pending flag, so it will be honored when
|
92 |
|
|
-- interrupts are enabled.
|
93 |
|
|
--
|
94 |
2 |
ja_rd |
--
|
95 |
4 |
ja_rd |
-- The above means that any instruction can be supplied in an inta cycle,
|
96 |
10 |
ja_rd |
-- either single byte or multibyte. See the design notes.
|
97 |
2 |
ja_rd |
--##############################################################################
|
98 |
|
|
|
99 |
|
|
architecture microcoded of light8080 is
|
100 |
|
|
|
101 |
|
|
-- addr_low: low byte of address
|
102 |
|
|
signal addr_low : std_logic_vector(7 downto 0);
|
103 |
|
|
-- IR: instruction register. some bits left unused.
|
104 |
|
|
signal IR : std_logic_vector(7 downto 0);
|
105 |
|
|
-- s_field: IR field, sss source reg code
|
106 |
|
|
signal s_field : std_logic_vector(2 downto 0);
|
107 |
|
|
-- d_field: IR field, ddd destination reg code
|
108 |
|
|
signal d_field : std_logic_vector(2 downto 0);
|
109 |
|
|
-- p_field: IR field, pp 16-bit reg pair code
|
110 |
|
|
signal p_field : std_logic_vector(1 downto 0);
|
111 |
|
|
-- rbh: 1 when p_field=11, used in reg bank addressing for 'special' regs
|
112 |
|
|
signal rbh : std_logic; -- 1 when P=11 (special case)
|
113 |
|
|
-- alu_op: uinst field, ALU operation code
|
114 |
|
|
signal alu_op : std_logic_vector(3 downto 0);
|
115 |
|
|
-- DI: data input to ALU block from data_in, unregistered
|
116 |
|
|
signal DI : std_logic_vector(7 downto 0);
|
117 |
|
|
-- uc_addr: microcode (ucode) address
|
118 |
|
|
signal uc_addr : std_logic_vector(7 downto 0);
|
119 |
|
|
-- next_uc_addr: computed next microcode address (uaddr++/jump/ret/fetch)
|
120 |
|
|
signal next_uc_addr : std_logic_vector(8 downto 0);
|
121 |
|
|
-- uc_jmp_addr: uinst field, absolute ucode jump address
|
122 |
|
|
signal uc_jmp_addr : std_logic_vector(7 downto 0);
|
123 |
|
|
-- uc_ret_address: ucode return address saved in previous jump
|
124 |
|
|
signal uc_ret_addr : std_logic_vector(7 downto 0);
|
125 |
|
|
-- addr_plus_1: uaddr + 1
|
126 |
|
|
signal addr_plus_1 : std_logic_vector(7 downto 0);
|
127 |
|
|
-- do_reset: reset, delayed 1 cycle -- used to reset the microcode sequencer
|
128 |
|
|
signal do_reset : std_logic;
|
129 |
|
|
|
130 |
|
|
-- uc_flags1: uinst field, encoded flag of group 1 (see ucode file)
|
131 |
|
|
signal uc_flags1 : std_logic_vector(2 downto 0);
|
132 |
|
|
-- uc_flags2: uinst field, encoded flag of group 2 (see ucode file)
|
133 |
|
|
signal uc_flags2 : std_logic_vector(2 downto 0);
|
134 |
|
|
-- uc_addr_sel: selection of next uc_addr, composition of 4 flags
|
135 |
|
|
signal uc_addr_sel : std_logic_vector(3 downto 0);
|
136 |
|
|
-- NOTE: see microcode file for information on flags
|
137 |
|
|
signal uc_jsr : std_logic; -- uinst field, decoded 'jsr' flag
|
138 |
|
|
signal uc_tjsr : std_logic; -- uinst field, decoded 'tjsr' flag
|
139 |
|
|
signal uc_decode : std_logic; -- uinst field, decoded 'decode' flag
|
140 |
|
|
signal uc_end : std_logic; -- uinst field, decoded 'end' flag
|
141 |
|
|
signal condition_reg :std_logic; -- registered tjst condition
|
142 |
|
|
-- condition: tjsr condition (computed ccc condition from '80 instructions)
|
143 |
|
|
signal condition : std_logic;
|
144 |
|
|
-- condition_sel: IR field, ccc condition code
|
145 |
|
|
signal condition_sel :std_logic_vector(2 downto 0);
|
146 |
|
|
signal uc_do_jmp : std_logic; -- uinst jump (jsr/tjsr) flag, pipelined
|
147 |
|
|
signal uc_do_ret : std_logic; -- ret flag, pipelined
|
148 |
|
|
signal uc_halt_flag : std_logic; -- uinst field, decoded 'halt' flag
|
149 |
|
|
signal uc_halt : std_logic; -- halt command
|
150 |
|
|
signal halt_reg : std_logic; -- halt status reg, output as 'halt' signal
|
151 |
|
|
signal uc_ei : std_logic; -- uinst field, decoded 'ei' flag
|
152 |
49 |
ja_rd |
signal uc_di : std_logic; -- uinst field, decoded 'di' flag
|
153 |
2 |
ja_rd |
signal inte_reg : std_logic; -- inte status reg, output as 'inte' signal
|
154 |
|
|
signal int_pending : std_logic; -- intr requested, inta not active yet
|
155 |
|
|
signal inta_reg : std_logic; -- inta status reg, output as 'inta'
|
156 |
|
|
signal clr_t1 : std_logic; -- uinst field, explicitly erase T1
|
157 |
|
|
signal do_clr_t1 : std_logic; -- clr_t1 pipelined
|
158 |
|
|
signal clr_t2 : std_logic; -- uinst field, explicitly erase T2
|
159 |
|
|
signal do_clr_t2 : std_logic; -- clr_t2 pipelined
|
160 |
|
|
signal ucode : std_logic_vector(31 downto 0); -- microcode word
|
161 |
|
|
signal ucode_field2 : std_logic_vector(24 downto 0); -- pipelined microcode
|
162 |
|
|
|
163 |
49 |
ja_rd |
-- used to delay interrup enable for one entire instruction after EI
|
164 |
|
|
signal delayed_ei : std_logic;
|
165 |
|
|
|
166 |
2 |
ja_rd |
-- microcode ROM : see design notes and microcode source file
|
167 |
|
|
type t_rom is array (0 to 511) of std_logic_vector(31 downto 0);
|
168 |
|
|
|
169 |
|
|
signal rom : t_rom := (
|
170 |
|
|
"00000000000000000000000000000000", -- 000
|
171 |
|
|
"00000000000001001000000001000100", -- 001
|
172 |
|
|
"00000000000001000000000001000100", -- 002
|
173 |
|
|
"10111101101001001000000001001101", -- 003
|
174 |
|
|
"10110110101001000000000001001101", -- 004
|
175 |
|
|
"00100000000000000000000000000000", -- 005
|
176 |
|
|
"00000000000000000000000000000000", -- 006
|
177 |
|
|
"11100100000000000000000000000000", -- 007
|
178 |
|
|
"00000000101010000000000000000000", -- 008
|
179 |
|
|
"00000100000100000000000001010111", -- 009
|
180 |
|
|
"00001000000000000000110000011001", -- 00a
|
181 |
|
|
"00000100000100000000000001010111", -- 00b
|
182 |
|
|
"00000000101010000000000010010111", -- 00c
|
183 |
|
|
"00001000000000000000110000011100", -- 00d
|
184 |
|
|
"00001000000000000000110000011111", -- 00e
|
185 |
|
|
"00000100000100000000000001010111", -- 00f
|
186 |
|
|
"00001000000000000000110000011111", -- 010
|
187 |
|
|
"00001000000000000000110000011100", -- 011
|
188 |
|
|
"00001000000000000000110000011111", -- 012
|
189 |
|
|
"00000000000110001000000001010111", -- 013
|
190 |
|
|
"00001000000000000000110000011111", -- 014
|
191 |
|
|
"00000100000110000000000001010111", -- 015
|
192 |
|
|
"00001000000000000000110000101110", -- 016
|
193 |
|
|
"00001000000000000000110000100010", -- 017
|
194 |
|
|
"00000100000000111000000001010111", -- 018
|
195 |
|
|
"00001000000000000000110000101110", -- 019
|
196 |
|
|
"00000000101000111000000010010111", -- 01a
|
197 |
|
|
"00001000000000000000110000100101", -- 01b
|
198 |
|
|
"00001000000000000000110000101110", -- 01c
|
199 |
|
|
"10111101101001100000000001001101", -- 01d
|
200 |
|
|
"10110110101001101000000001001101", -- 01e
|
201 |
|
|
"00000000100000101000000001010111", -- 01f
|
202 |
|
|
"00001000000000000000110000100010", -- 020
|
203 |
|
|
"00000100000000100000000001010111", -- 021
|
204 |
|
|
"00001000000000000000110000101110", -- 022
|
205 |
|
|
"00000000101000101000000010010111", -- 023
|
206 |
|
|
"10111101101001100000000001001101", -- 024
|
207 |
|
|
"10111010101001101000000001001101", -- 025
|
208 |
|
|
"00000000101000100000000010010111", -- 026
|
209 |
|
|
"00001000000000000000110000100101", -- 027
|
210 |
|
|
"00001000000000000000110000101000", -- 028
|
211 |
|
|
"00000100000000111000000001010111", -- 029
|
212 |
|
|
"00000000101000111000000010010111", -- 02a
|
213 |
|
|
"00001000000000000000110000101011", -- 02b
|
214 |
|
|
"00000000101000010000000000000000", -- 02c
|
215 |
|
|
"00000000000001010000000001010111", -- 02d
|
216 |
|
|
"00000000101000011000000000000000", -- 02e
|
217 |
|
|
"00000000000001011000000001010111", -- 02f
|
218 |
|
|
"00000000101000100000000000000000", -- 030
|
219 |
|
|
"00000000000000010000000001010111", -- 031
|
220 |
|
|
"00000000101000101000000000000000", -- 032
|
221 |
|
|
"00000000000000011000000001010111", -- 033
|
222 |
|
|
"00000000101001010000000000000000", -- 034
|
223 |
|
|
"00000000000000100000000001010111", -- 035
|
224 |
|
|
"00000000101001011000000000000000", -- 036
|
225 |
|
|
"00000100000000101000000001010111", -- 037
|
226 |
|
|
"00001000000000000000110000011111", -- 038
|
227 |
|
|
"00000100011000111000001101001100", -- 039
|
228 |
|
|
"00001000000000000000110000011111", -- 03a
|
229 |
|
|
"00000100011000111000001101001101", -- 03b
|
230 |
|
|
"00001000000000000000110000011111", -- 03c
|
231 |
|
|
"00000100011000111000001101001110", -- 03d
|
232 |
|
|
"00001000000000000000110000011111", -- 03e
|
233 |
|
|
"00000100011000111000001101001111", -- 03f
|
234 |
|
|
"00001000000000000000110000011111", -- 040
|
235 |
|
|
"00000100011000111000001101000100", -- 041
|
236 |
|
|
"00001000000000000000110000011111", -- 042
|
237 |
|
|
"00000100011000111000001101000101", -- 043
|
238 |
|
|
"00001000000000000000110000011111", -- 044
|
239 |
|
|
"00000100011000111000001101000110", -- 045
|
240 |
|
|
"00001000000000000000110000011111", -- 046
|
241 |
|
|
"00000100011000111000001110001110", -- 047
|
242 |
|
|
"00000000101010000000000000000000", -- 048
|
243 |
|
|
"00000100011000111000001101001100", -- 049
|
244 |
|
|
"00000000101010000000000000000000", -- 04a
|
245 |
|
|
"00000100011000111000001101001101", -- 04b
|
246 |
|
|
"00000000101010000000000000000000", -- 04c
|
247 |
|
|
"00000100011000111000001101001110", -- 04d
|
248 |
|
|
"00000000101010000000000000000000", -- 04e
|
249 |
|
|
"00000100011000111000001101001111", -- 04f
|
250 |
|
|
"00000000101010000000000000000000", -- 050
|
251 |
|
|
"00000100011000111000001101000100", -- 051
|
252 |
|
|
"00000000101010000000000000000000", -- 052
|
253 |
|
|
"00000100011000111000001101000101", -- 053
|
254 |
|
|
"00000000101010000000000000000000", -- 054
|
255 |
|
|
"00000100011000111000001101000110", -- 055
|
256 |
|
|
"00000000101010000000000000000000", -- 056
|
257 |
|
|
"00000100011000111000001110001110", -- 057
|
258 |
|
|
"00001000000000000000110000011001", -- 058
|
259 |
|
|
"00000100011000111000001101001100", -- 059
|
260 |
|
|
"00001000000000000000110000011001", -- 05a
|
261 |
|
|
"00000100011000111000001101001101", -- 05b
|
262 |
|
|
"00001000000000000000110000011001", -- 05c
|
263 |
|
|
"00000100011000111000001101001110", -- 05d
|
264 |
|
|
"00001000000000000000110000011001", -- 05e
|
265 |
|
|
"00000100011000111000001101001111", -- 05f
|
266 |
|
|
"00001000000000000000110000011001", -- 060
|
267 |
|
|
"00000100011000111000001101000100", -- 061
|
268 |
|
|
"00001000000000000000110000011001", -- 062
|
269 |
|
|
"00000100011000111000001101000101", -- 063
|
270 |
|
|
"00001000000000000000110000011001", -- 064
|
271 |
|
|
"00000100011000111000001101000110", -- 065
|
272 |
|
|
"00001000000000000000110000011001", -- 066
|
273 |
|
|
"00000100011000111000001110001110", -- 067
|
274 |
|
|
"10111100101100000000001001001101", -- 068
|
275 |
|
|
"00000100000000000000000000000000", -- 069
|
276 |
|
|
"00001000000000000000110000011001", -- 06a
|
277 |
6 |
ja_rd |
"10111100000000000000001010001101", -- 06b
|
278 |
2 |
ja_rd |
"00001000000000000000110000011100", -- 06c
|
279 |
|
|
"10111100011100000000001001001111", -- 06d
|
280 |
|
|
"00000100000000000000000000000000", -- 06e
|
281 |
|
|
"00001000000000000000110000011001", -- 06f
|
282 |
|
|
"11000000000000000000000000000000", -- 070
|
283 |
|
|
"10111100011001010000001010001111", -- 071
|
284 |
|
|
"00001000000000000000110000011100", -- 072
|
285 |
|
|
"10111100101110001000000001001101", -- 073
|
286 |
|
|
"10100100101110000000000001001101", -- 074
|
287 |
|
|
"10111100011110001000000001001111", -- 075
|
288 |
|
|
"10100100011110000000000001001111", -- 076
|
289 |
|
|
"00000000011110001000000000000000", -- 077
|
290 |
|
|
"00000000101000101000000101001100", -- 078
|
291 |
|
|
"00000000011110000000000000000000", -- 079
|
292 |
|
|
"00000100101000100000000101001101", -- 07a
|
293 |
|
|
"00000000101000111000000010101000", -- 07b
|
294 |
|
|
"00000100101000111000001101101000", -- 07c
|
295 |
|
|
"00000100101000111000000101000000", -- 07d
|
296 |
|
|
"00000100101000111000000101000001", -- 07e
|
297 |
|
|
"00000100101000111000000101000010", -- 07f
|
298 |
|
|
"00000100101000111000000101000011", -- 080
|
299 |
|
|
"00000100101000111000000001000111", -- 081
|
300 |
|
|
"00000100000000000000000100101100", -- 082
|
301 |
|
|
"00000100000000000000000100101101", -- 083
|
302 |
|
|
"00001000000000000000110000101110", -- 084
|
303 |
|
|
"00000000101001100000000000000000", -- 085
|
304 |
|
|
"00000000000001001000000001010111", -- 086
|
305 |
|
|
"00000000101001101000000000000000", -- 087
|
306 |
|
|
"00000100000001000000000001010111", -- 088
|
307 |
|
|
"00000100000000000000000000000000", -- 089
|
308 |
|
|
"00001000000000000000110000101110", -- 08a
|
309 |
|
|
"00010000000000000000100000000101", -- 08b
|
310 |
|
|
"00001000000000000000110000101110", -- 08c
|
311 |
|
|
"11000000101001000000000010010111", -- 08d
|
312 |
|
|
"00001000000000000000110000110100", -- 08e
|
313 |
|
|
"11000000101001001000000010010111", -- 08f
|
314 |
|
|
"00001000000000000000110000110100", -- 090
|
315 |
|
|
"00000000101001100000000000000000", -- 091
|
316 |
|
|
"00000000000001001000000001010111", -- 092
|
317 |
|
|
"00000000101001101000000000000000", -- 093
|
318 |
|
|
"00000100000001000000000001010111", -- 094
|
319 |
|
|
"00001000000000000000110000101110", -- 095
|
320 |
|
|
"00010000000000000000100000001101", -- 096
|
321 |
|
|
"00001000000000000000110000111001", -- 097
|
322 |
|
|
"00000000000001001000000001010111", -- 098
|
323 |
|
|
"00001000000000000000110000111001", -- 099
|
324 |
|
|
"00000100000001000000000001010111", -- 09a
|
325 |
|
|
"00010000000000000000100000010111", -- 09b
|
326 |
|
|
"11000000101001000000000010010111", -- 09c
|
327 |
|
|
"00001000000000000000110000110100", -- 09d
|
328 |
|
|
"11000000101001001000000010010111", -- 09e
|
329 |
|
|
"00001000000000000000110000110100", -- 09f
|
330 |
|
|
"11000000000001001000000001011111", -- 0a0
|
331 |
|
|
"00000100000001000000000001000100", -- 0a1
|
332 |
|
|
"00000000101000101000000000000000", -- 0a2
|
333 |
|
|
"00000000000001001000000001010111", -- 0a3
|
334 |
|
|
"00000000101000100000000000000000", -- 0a4
|
335 |
|
|
"00000100000001000000000001010111", -- 0a5
|
336 |
|
|
"11000000101110000000000010010111", -- 0a6
|
337 |
|
|
"00001000000000000000110000110100", -- 0a7
|
338 |
|
|
"11000000101110001000000010010111", -- 0a8
|
339 |
|
|
"00001000000000000000110000110100", -- 0a9
|
340 |
|
|
"00000100000000000000000000000000", -- 0aa
|
341 |
|
|
"11000000101000111000000010010111", -- 0ab
|
342 |
|
|
"00001000000000000000110000110100", -- 0ac
|
343 |
|
|
"11000000000000000000000010110000", -- 0ad
|
344 |
|
|
"00001000000000000000110000110100", -- 0ae
|
345 |
|
|
"00000100000000000000000000000000", -- 0af
|
346 |
|
|
"00001000000000000000110000111001", -- 0b0
|
347 |
|
|
"00000000000110001000000001010111", -- 0b1
|
348 |
|
|
"00001000000000000000110000111001", -- 0b2
|
349 |
|
|
"00000100000110000000000001010111", -- 0b3
|
350 |
|
|
"00001000000000000000110000111001", -- 0b4
|
351 |
|
|
"00000000000000110000001101010111", -- 0b5
|
352 |
|
|
"00001000000000000000110000111001", -- 0b6
|
353 |
|
|
"00000100000000111000000001010111", -- 0b7
|
354 |
|
|
"00001000000000000000110000111001", -- 0b8
|
355 |
|
|
"00000000000001100000000001010111", -- 0b9
|
356 |
|
|
"00001000000000000000110000111001", -- 0ba
|
357 |
|
|
"00000000000001101000000001010111", -- 0bb
|
358 |
|
|
"11000000101000100000000010010111", -- 0bc
|
359 |
|
|
"00001000000000000000110000110100", -- 0bd
|
360 |
|
|
"11000000101000101000000010010111", -- 0be
|
361 |
|
|
"00001000000000000000110000110100", -- 0bf
|
362 |
|
|
"00000000101001100000000000000000", -- 0c0
|
363 |
|
|
"00000000000000101000000001010111", -- 0c1
|
364 |
|
|
"00000000101001101000000000000000", -- 0c2
|
365 |
|
|
"00000100000000100000000001010111", -- 0c3
|
366 |
|
|
"00000000101000101000000000000000", -- 0c4
|
367 |
|
|
"00000000000001111000000001010111", -- 0c5
|
368 |
|
|
"00000000101000100000000000000000", -- 0c6
|
369 |
|
|
"00000100000001110000000001010111", -- 0c7
|
370 |
|
|
"01100100000000000000000000000000", -- 0c8
|
371 |
|
|
"01000100000000000000000000000000", -- 0c9
|
372 |
|
|
"00000000000001101000000001010111", -- 0ca
|
373 |
|
|
"00001000000000000000110000011111", -- 0cb
|
374 |
|
|
"00000000000001100000000001010111", -- 0cc
|
375 |
|
|
"00000000000000000000000000000000", -- 0cd
|
376 |
|
|
"00000001101001100000000000000000", -- 0ce
|
377 |
|
|
"10010110101001101000000000000000", -- 0cf
|
378 |
|
|
"00000100100000111000000001010111", -- 0d0
|
379 |
|
|
"00000000000001101000000001010111", -- 0d1
|
380 |
|
|
"00001000000000000000110000011111", -- 0d2
|
381 |
|
|
"00000000000001100000000001010111", -- 0d3
|
382 |
|
|
"00000000101000111000000010010111", -- 0d4
|
383 |
|
|
"00000001101001100000000000000000", -- 0d5
|
384 |
|
|
"10011010101001101000000000000000", -- 0d6
|
385 |
|
|
"00000100000000000000000000000000", -- 0d7
|
386 |
|
|
"11100100000000000000000000000000", -- 0d8
|
387 |
|
|
"00000001101000101000000000000000", -- 0d9
|
388 |
|
|
"00010110101000100000000000000000", -- 0da
|
389 |
|
|
"00001100100001010000000001010111", -- 0db
|
390 |
|
|
"00000001101000101000000000000000", -- 0dc
|
391 |
|
|
"00011010101000100000000000000000", -- 0dd
|
392 |
|
|
"00000100000000000000000000000000", -- 0de
|
393 |
|
|
"10111101101001001000000001001101", -- 0df
|
394 |
|
|
"10110110101001000000000001001101", -- 0e0
|
395 |
|
|
"00001100100000000000000010010111", -- 0e1
|
396 |
|
|
"00000001101001100000000000000000", -- 0e2
|
397 |
|
|
"00010110101001101000000000000000", -- 0e3
|
398 |
|
|
"00001100100000000000000000000000", -- 0e4
|
399 |
|
|
"00000001101001100000000000000000", -- 0e5
|
400 |
|
|
"00011010101001101000000000000000", -- 0e6
|
401 |
|
|
"00000100000000000000000000000000", -- 0e7
|
402 |
|
|
"00000001101110001000000000000000", -- 0e8
|
403 |
|
|
"00010110101110000000000000000000", -- 0e9
|
404 |
|
|
"00001100100000000000000000000000", -- 0ea
|
405 |
|
|
"00000001101110001000000000000000", -- 0eb
|
406 |
|
|
"00011010101110000000000000000000", -- 0ec
|
407 |
|
|
"00000100000000000000000000000000", -- 0ed
|
408 |
|
|
"10111101101001001000000001001101", -- 0ee
|
409 |
|
|
"10110110101001000000000001001101", -- 0ef
|
410 |
|
|
"00000000100001100000000001010111", -- 0f0
|
411 |
|
|
"10111101101001001000000001001101", -- 0f1
|
412 |
|
|
"10110110101001000000000001001101", -- 0f2
|
413 |
|
|
"00001100100001101000000001010111", -- 0f3
|
414 |
|
|
"10111100011001111000000001001111", -- 0f4
|
415 |
|
|
"10100000011001110000000001001111", -- 0f5
|
416 |
|
|
"00000001101001111000000000000000", -- 0f6
|
417 |
|
|
"00011010101001110000000000000000", -- 0f7
|
418 |
|
|
"00001100000000000000000000000000", -- 0f8
|
419 |
|
|
"10111101101001111000000001001101", -- 0f9
|
420 |
|
|
"10110110101001110000000001001101", -- 0fa
|
421 |
|
|
"00001100100000000000000000000000", -- 0fb
|
422 |
|
|
"00000100000000000000000000000000", -- 0fc
|
423 |
|
|
"00000100000000000000000000000000", -- 0fd
|
424 |
|
|
"00000100000000000000000000000000", -- 0fe
|
425 |
|
|
"00000100000000000000000000000000", -- 0ff
|
426 |
|
|
"00001000000000000000100000001001", -- 100
|
427 |
|
|
"00001000000000000000000000010010", -- 101
|
428 |
|
|
"00001000000000000000000000101010", -- 102
|
429 |
|
|
"00001000000000000000010000110011", -- 103
|
430 |
|
|
"00001000000000000000010000101000", -- 104
|
431 |
|
|
"00001000000000000000010000101101", -- 105
|
432 |
|
|
"00001000000000000000000000001110", -- 106
|
433 |
|
|
"00001000000000000000010000111101", -- 107
|
434 |
|
|
"00001000000000000000000000000000", -- 108
|
435 |
|
|
"00001000000000000000010000110111", -- 109
|
436 |
|
|
"00001000000000000000000000101000", -- 10a
|
437 |
|
|
"00001000000000000000010000110101", -- 10b
|
438 |
|
|
"00001000000000000000010000101000", -- 10c
|
439 |
|
|
"00001000000000000000010000101101", -- 10d
|
440 |
|
|
"00001000000000000000000000001110", -- 10e
|
441 |
|
|
"00001000000000000000010000111110", -- 10f
|
442 |
|
|
"00001000000000000000000000000000", -- 110
|
443 |
|
|
"00001000000000000000000000010010", -- 111
|
444 |
|
|
"00001000000000000000000000101010", -- 112
|
445 |
|
|
"00001000000000000000010000110011", -- 113
|
446 |
|
|
"00001000000000000000010000101000", -- 114
|
447 |
|
|
"00001000000000000000010000101101", -- 115
|
448 |
|
|
"00001000000000000000000000001110", -- 116
|
449 |
|
|
"00001000000000000000010000111111", -- 117
|
450 |
|
|
"00001000000000000000000000000000", -- 118
|
451 |
|
|
"00001000000000000000010000110111", -- 119
|
452 |
|
|
"00001000000000000000000000101000", -- 11a
|
453 |
|
|
"00001000000000000000010000110101", -- 11b
|
454 |
|
|
"00001000000000000000010000101000", -- 11c
|
455 |
|
|
"00001000000000000000010000101101", -- 11d
|
456 |
|
|
"00001000000000000000000000001110", -- 11e
|
457 |
|
|
"00001000000000000000100000000000", -- 11f
|
458 |
|
|
"00001000000000000000000000000000", -- 120
|
459 |
|
|
"00001000000000000000000000010010", -- 121
|
460 |
|
|
"00001000000000000000000000100010", -- 122
|
461 |
|
|
"00001000000000000000010000110011", -- 123
|
462 |
|
|
"00001000000000000000010000101000", -- 124
|
463 |
|
|
"00001000000000000000010000101101", -- 125
|
464 |
|
|
"00001000000000000000000000001110", -- 126
|
465 |
|
|
"00001000000000000000010000111011", -- 127
|
466 |
|
|
"00001000000000000000000000000000", -- 128
|
467 |
|
|
"00001000000000000000010000110111", -- 129
|
468 |
|
|
"00001000000000000000000000011100", -- 12a
|
469 |
|
|
"00001000000000000000010000110101", -- 12b
|
470 |
|
|
"00001000000000000000010000101000", -- 12c
|
471 |
|
|
"00001000000000000000010000101101", -- 12d
|
472 |
|
|
"00001000000000000000000000001110", -- 12e
|
473 |
|
|
"00001000000000000000100000000001", -- 12f
|
474 |
|
|
"00001000000000000000000000000000", -- 130
|
475 |
|
|
"00001000000000000000000000010010", -- 131
|
476 |
|
|
"00001000000000000000000000011001", -- 132
|
477 |
|
|
"00001000000000000000010000110011", -- 133
|
478 |
|
|
"00001000000000000000010000101010", -- 134
|
479 |
|
|
"00001000000000000000010000101111", -- 135
|
480 |
|
|
"00001000000000000000000000010000", -- 136
|
481 |
|
|
"00001000000000000000100000000011", -- 137
|
482 |
|
|
"00001000000000000000000000000000", -- 138
|
483 |
|
|
"00001000000000000000010000110111", -- 139
|
484 |
|
|
"00001000000000000000000000010110", -- 13a
|
485 |
|
|
"00001000000000000000010000110101", -- 13b
|
486 |
|
|
"00001000000000000000010000101000", -- 13c
|
487 |
|
|
"00001000000000000000010000101101", -- 13d
|
488 |
|
|
"00001000000000000000000000001110", -- 13e
|
489 |
|
|
"00001000000000000000100000000010", -- 13f
|
490 |
|
|
"00001000000000000000000000001000", -- 140
|
491 |
|
|
"00001000000000000000000000001000", -- 141
|
492 |
|
|
"00001000000000000000000000001000", -- 142
|
493 |
|
|
"00001000000000000000000000001000", -- 143
|
494 |
|
|
"00001000000000000000000000001000", -- 144
|
495 |
|
|
"00001000000000000000000000001000", -- 145
|
496 |
|
|
"00001000000000000000000000001010", -- 146
|
497 |
|
|
"00001000000000000000000000001000", -- 147
|
498 |
|
|
"00001000000000000000000000001000", -- 148
|
499 |
|
|
"00001000000000000000000000001000", -- 149
|
500 |
|
|
"00001000000000000000000000001000", -- 14a
|
501 |
|
|
"00001000000000000000000000001000", -- 14b
|
502 |
|
|
"00001000000000000000000000001000", -- 14c
|
503 |
|
|
"00001000000000000000000000001000", -- 14d
|
504 |
|
|
"00001000000000000000000000001010", -- 14e
|
505 |
|
|
"00001000000000000000000000001000", -- 14f
|
506 |
|
|
"00001000000000000000000000001000", -- 150
|
507 |
|
|
"00001000000000000000000000001000", -- 151
|
508 |
|
|
"00001000000000000000000000001000", -- 152
|
509 |
|
|
"00001000000000000000000000001000", -- 153
|
510 |
|
|
"00001000000000000000000000001000", -- 154
|
511 |
|
|
"00001000000000000000000000001000", -- 155
|
512 |
|
|
"00001000000000000000000000001010", -- 156
|
513 |
|
|
"00001000000000000000000000001000", -- 157
|
514 |
|
|
"00001000000000000000000000001000", -- 158
|
515 |
|
|
"00001000000000000000000000001000", -- 159
|
516 |
|
|
"00001000000000000000000000001000", -- 15a
|
517 |
|
|
"00001000000000000000000000001000", -- 15b
|
518 |
|
|
"00001000000000000000000000001000", -- 15c
|
519 |
|
|
"00001000000000000000000000001000", -- 15d
|
520 |
|
|
"00001000000000000000000000001010", -- 15e
|
521 |
|
|
"00001000000000000000000000001000", -- 15f
|
522 |
|
|
"00001000000000000000000000001000", -- 160
|
523 |
|
|
"00001000000000000000000000001000", -- 161
|
524 |
|
|
"00001000000000000000000000001000", -- 162
|
525 |
|
|
"00001000000000000000000000001000", -- 163
|
526 |
|
|
"00001000000000000000000000001000", -- 164
|
527 |
|
|
"00001000000000000000000000001000", -- 165
|
528 |
|
|
"00001000000000000000000000001010", -- 166
|
529 |
|
|
"00001000000000000000000000001000", -- 167
|
530 |
|
|
"00001000000000000000000000001000", -- 168
|
531 |
|
|
"00001000000000000000000000001000", -- 169
|
532 |
|
|
"00001000000000000000000000001000", -- 16a
|
533 |
|
|
"00001000000000000000000000001000", -- 16b
|
534 |
|
|
"00001000000000000000000000001000", -- 16c
|
535 |
|
|
"00001000000000000000000000001000", -- 16d
|
536 |
|
|
"00001000000000000000000000001010", -- 16e
|
537 |
|
|
"00001000000000000000000000001000", -- 16f
|
538 |
|
|
"00001000000000000000000000001100", -- 170
|
539 |
|
|
"00001000000000000000000000001100", -- 171
|
540 |
|
|
"00001000000000000000000000001100", -- 172
|
541 |
|
|
"00001000000000000000000000001100", -- 173
|
542 |
|
|
"00001000000000000000000000001100", -- 174
|
543 |
|
|
"00001000000000000000000000001100", -- 175
|
544 |
|
|
"00001000000000000000110000011000", -- 176
|
545 |
|
|
"00001000000000000000000000001100", -- 177
|
546 |
|
|
"00001000000000000000000000001000", -- 178
|
547 |
|
|
"00001000000000000000000000001000", -- 179
|
548 |
|
|
"00001000000000000000000000001000", -- 17a
|
549 |
|
|
"00001000000000000000000000001000", -- 17b
|
550 |
|
|
"00001000000000000000000000001000", -- 17c
|
551 |
|
|
"00001000000000000000000000001000", -- 17d
|
552 |
|
|
"00001000000000000000000000001010", -- 17e
|
553 |
|
|
"00001000000000000000000000001000", -- 17f
|
554 |
|
|
"00001000000000000000010000001000", -- 180
|
555 |
|
|
"00001000000000000000010000001000", -- 181
|
556 |
|
|
"00001000000000000000010000001000", -- 182
|
557 |
|
|
"00001000000000000000010000001000", -- 183
|
558 |
|
|
"00001000000000000000010000001000", -- 184
|
559 |
|
|
"00001000000000000000010000001000", -- 185
|
560 |
|
|
"00001000000000000000010000011000", -- 186
|
561 |
|
|
"00001000000000000000010000001000", -- 187
|
562 |
|
|
"00001000000000000000010000001010", -- 188
|
563 |
|
|
"00001000000000000000010000001010", -- 189
|
564 |
|
|
"00001000000000000000010000001010", -- 18a
|
565 |
|
|
"00001000000000000000010000001010", -- 18b
|
566 |
|
|
"00001000000000000000010000001010", -- 18c
|
567 |
|
|
"00001000000000000000010000001010", -- 18d
|
568 |
|
|
"00001000000000000000010000011010", -- 18e
|
569 |
|
|
"00001000000000000000010000001010", -- 18f
|
570 |
|
|
"00001000000000000000010000001100", -- 190
|
571 |
|
|
"00001000000000000000010000001100", -- 191
|
572 |
|
|
"00001000000000000000010000001100", -- 192
|
573 |
|
|
"00001000000000000000010000001100", -- 193
|
574 |
|
|
"00001000000000000000010000001100", -- 194
|
575 |
|
|
"00001000000000000000010000001100", -- 195
|
576 |
|
|
"00001000000000000000010000011100", -- 196
|
577 |
|
|
"00001000000000000000010000001100", -- 197
|
578 |
|
|
"00001000000000000000010000001110", -- 198
|
579 |
|
|
"00001000000000000000010000001110", -- 199
|
580 |
|
|
"00001000000000000000010000001110", -- 19a
|
581 |
|
|
"00001000000000000000010000001110", -- 19b
|
582 |
|
|
"00001000000000000000010000001110", -- 19c
|
583 |
|
|
"00001000000000000000010000001110", -- 19d
|
584 |
|
|
"00001000000000000000010000011110", -- 19e
|
585 |
|
|
"00001000000000000000010000001110", -- 19f
|
586 |
|
|
"00001000000000000000010000010000", -- 1a0
|
587 |
|
|
"00001000000000000000010000010000", -- 1a1
|
588 |
|
|
"00001000000000000000010000010000", -- 1a2
|
589 |
|
|
"00001000000000000000010000010000", -- 1a3
|
590 |
|
|
"00001000000000000000010000010000", -- 1a4
|
591 |
|
|
"00001000000000000000010000010000", -- 1a5
|
592 |
|
|
"00001000000000000000010000100000", -- 1a6
|
593 |
|
|
"00001000000000000000010000010000", -- 1a7
|
594 |
|
|
"00001000000000000000010000010010", -- 1a8
|
595 |
|
|
"00001000000000000000010000010010", -- 1a9
|
596 |
|
|
"00001000000000000000010000010010", -- 1aa
|
597 |
|
|
"00001000000000000000010000010010", -- 1ab
|
598 |
|
|
"00001000000000000000010000010010", -- 1ac
|
599 |
|
|
"00001000000000000000010000010010", -- 1ad
|
600 |
|
|
"00001000000000000000010000100010", -- 1ae
|
601 |
|
|
"00001000000000000000010000010010", -- 1af
|
602 |
|
|
"00001000000000000000010000010100", -- 1b0
|
603 |
|
|
"00001000000000000000010000010100", -- 1b1
|
604 |
|
|
"00001000000000000000010000010100", -- 1b2
|
605 |
|
|
"00001000000000000000010000010100", -- 1b3
|
606 |
|
|
"00001000000000000000010000010100", -- 1b4
|
607 |
|
|
"00001000000000000000010000010100", -- 1b5
|
608 |
|
|
"00001000000000000000010000100100", -- 1b6
|
609 |
|
|
"00001000000000000000010000010100", -- 1b7
|
610 |
|
|
"00001000000000000000010000010110", -- 1b8
|
611 |
|
|
"00001000000000000000010000010110", -- 1b9
|
612 |
|
|
"00001000000000000000010000010110", -- 1ba
|
613 |
|
|
"00001000000000000000010000010110", -- 1bb
|
614 |
|
|
"00001000000000000000010000010110", -- 1bc
|
615 |
|
|
"00001000000000000000010000010110", -- 1bd
|
616 |
|
|
"00001000000000000000010000100110", -- 1be
|
617 |
|
|
"00001000000000000000010000010110", -- 1bf
|
618 |
|
|
"00001000000000000000100000011011", -- 1c0
|
619 |
|
|
"00001000000000000000100000110000", -- 1c1
|
620 |
|
|
"00001000000000000000100000001010", -- 1c2
|
621 |
|
|
"00001000000000000000100000000100", -- 1c3
|
622 |
|
|
"00001000000000000000100000010101", -- 1c4
|
623 |
|
|
"00001000000000000000100000100110", -- 1c5
|
624 |
|
|
"00001000000000000000000000111000", -- 1c6
|
625 |
|
|
"00001000000000000000100000011100", -- 1c7
|
626 |
|
|
"00001000000000000000100000011011", -- 1c8
|
627 |
|
|
"00001000000000000000100000010111", -- 1c9
|
628 |
|
|
"00001000000000000000100000001010", -- 1ca
|
629 |
|
|
"00001000000000000000000000000000", -- 1cb
|
630 |
|
|
"00001000000000000000100000010101", -- 1cc
|
631 |
|
|
"00001000000000000000100000001100", -- 1cd
|
632 |
|
|
"00001000000000000000000000111010", -- 1ce
|
633 |
|
|
"00001000000000000000100000011100", -- 1cf
|
634 |
|
|
"00001000000000000000100000011011", -- 1d0
|
635 |
|
|
"00001000000000000000100000110000", -- 1d1
|
636 |
|
|
"00001000000000000000100000001010", -- 1d2
|
637 |
|
|
"00001000000000000000110000010001", -- 1d3
|
638 |
|
|
"00001000000000000000100000010101", -- 1d4
|
639 |
|
|
"00001000000000000000100000100110", -- 1d5
|
640 |
|
|
"00001000000000000000000000111100", -- 1d6
|
641 |
|
|
"00001000000000000000100000011100", -- 1d7
|
642 |
|
|
"00001000000000000000100000011011", -- 1d8
|
643 |
|
|
"00001000000000000000000000000000", -- 1d9
|
644 |
|
|
"00001000000000000000100000001010", -- 1da
|
645 |
|
|
"00001000000000000000110000001010", -- 1db
|
646 |
|
|
"00001000000000000000100000010101", -- 1dc
|
647 |
|
|
"00001000000000000000000000000000", -- 1dd
|
648 |
|
|
"00001000000000000000000000111110", -- 1de
|
649 |
|
|
"00001000000000000000100000011100", -- 1df
|
650 |
|
|
"00001000000000000000100000011011", -- 1e0
|
651 |
|
|
"00001000000000000000100000110000", -- 1e1
|
652 |
|
|
"00001000000000000000100000001010", -- 1e2
|
653 |
|
|
"00001000000000000000100000111000", -- 1e3
|
654 |
|
|
"00001000000000000000100000010101", -- 1e4
|
655 |
|
|
"00001000000000000000100000100110", -- 1e5
|
656 |
|
|
"00001000000000000000010000000000", -- 1e6
|
657 |
|
|
"00001000000000000000100000011100", -- 1e7
|
658 |
|
|
"00001000000000000000100000011011", -- 1e8
|
659 |
|
|
"00001000000000000000100000100010", -- 1e9
|
660 |
|
|
"00001000000000000000100000001010", -- 1ea
|
661 |
|
|
"00001000000000000000000000101100", -- 1eb
|
662 |
|
|
"00001000000000000000100000010101", -- 1ec
|
663 |
|
|
"00001000000000000000000000000000", -- 1ed
|
664 |
|
|
"00001000000000000000010000000010", -- 1ee
|
665 |
|
|
"00001000000000000000100000011100", -- 1ef
|
666 |
|
|
"00001000000000000000100000011011", -- 1f0
|
667 |
|
|
"00001000000000000000100000110100", -- 1f1
|
668 |
|
|
"00001000000000000000100000001010", -- 1f2
|
669 |
|
|
"00001000000000000000110000001001", -- 1f3
|
670 |
|
|
"00001000000000000000100000010101", -- 1f4
|
671 |
|
|
"00001000000000000000100000101011", -- 1f5
|
672 |
|
|
"00001000000000000000010000000100", -- 1f6
|
673 |
|
|
"00001000000000000000100000011100", -- 1f7
|
674 |
|
|
"00001000000000000000100000011011", -- 1f8
|
675 |
|
|
"00001000000000000000110000000100", -- 1f9
|
676 |
|
|
"00001000000000000000100000001010", -- 1fa
|
677 |
|
|
"00001000000000000000110000001000", -- 1fb
|
678 |
|
|
"00001000000000000000100000010101", -- 1fc
|
679 |
|
|
"00001000000000000000000000000000", -- 1fd
|
680 |
|
|
"00001000000000000000010000000110", -- 1fe
|
681 |
|
|
"00001000000000000000100000011100" -- 1ff
|
682 |
|
|
|
683 |
|
|
);
|
684 |
|
|
|
685 |
|
|
-- end of microcode ROM
|
686 |
|
|
|
687 |
|
|
signal load_al : std_logic; -- uinst field, load AL reg from rbank
|
688 |
|
|
signal load_addr : std_logic; -- uinst field, enable external addr reg load
|
689 |
|
|
signal load_t1 : std_logic; -- uinst field, load reg T1
|
690 |
|
|
signal load_t2 : std_logic; -- uinst field, load reg T2
|
691 |
|
|
signal mux_in : std_logic; -- uinst field, T1/T2 input data selection
|
692 |
|
|
signal load_do : std_logic; -- uinst field, pipelined, load DO reg
|
693 |
|
|
-- rb_addr_sel: uinst field, rbank address selection: (sss,ddd,pp,ra_field)
|
694 |
|
|
signal rb_addr_sel : std_logic_vector(1 downto 0);
|
695 |
|
|
-- ra_field: uinst field, explicit reg bank address
|
696 |
|
|
signal ra_field : std_logic_vector(3 downto 0);
|
697 |
|
|
signal rbank_data : std_logic_vector(7 downto 0); -- rbank output
|
698 |
|
|
signal alu_output : std_logic_vector(7 downto 0); -- ALU output
|
699 |
|
|
-- data_output: datapath output: ALU output vs. F reg
|
700 |
|
|
signal data_output : std_logic_vector(7 downto 0);
|
701 |
|
|
signal T1 : std_logic_vector(7 downto 0); -- T1 reg (ALU operand)
|
702 |
|
|
signal T2 : std_logic_vector(7 downto 0); -- T2 reg (ALU operand)
|
703 |
|
|
-- alu_input: data loaded into T1, T2: rbank data vs. DI
|
704 |
|
|
signal alu_input : std_logic_vector(7 downto 0);
|
705 |
|
|
signal we_rb : std_logic; -- uinst field, commands a write to the rbank
|
706 |
|
|
signal inhibit_pc_increment : std_logic; -- avoid PC changes (during INTA)
|
707 |
|
|
signal rbank_rd_addr: std_logic_vector(3 downto 0); -- rbank rd addr
|
708 |
|
|
signal rbank_wr_addr: std_logic_vector(3 downto 0); -- rbank wr addr
|
709 |
|
|
signal DO : std_logic_vector(7 downto 0); -- data output reg
|
710 |
|
|
|
711 |
|
|
-- Register bank as an array of 16 bytes (asynch. LUT ram)
|
712 |
|
|
type t_reg_bank is array(0 to 15) of std_logic_vector(7 downto 0);
|
713 |
|
|
-- Register bank : BC, DE, HL, AF, [PC, XY, ZW, SP]
|
714 |
|
|
signal rbank : t_reg_bank;
|
715 |
|
|
|
716 |
|
|
signal flag_reg : std_logic_vector(7 downto 0); -- F register
|
717 |
|
|
-- flag_pattern: uinst field, F update pattern: which flags are updated
|
718 |
|
|
signal flag_pattern : std_logic_vector(1 downto 0);
|
719 |
|
|
signal flag_s : std_logic; -- new computed S flag
|
720 |
|
|
signal flag_z : std_logic; -- new computed Z flag
|
721 |
|
|
signal flag_p : std_logic; -- new computed P flag
|
722 |
|
|
signal flag_cy : std_logic; -- new computed C flag
|
723 |
|
|
signal flag_cy_1 : std_logic; -- C flag computed from arith/logic operation
|
724 |
|
|
signal flag_cy_2 : std_logic; -- C flag computed from CPC circuit
|
725 |
|
|
signal do_cy_op : std_logic; -- ALU explicit CY operation (CPC, etc.)
|
726 |
|
|
signal do_cy_op_d : std_logic; -- do_cy_op, pipelined
|
727 |
|
|
signal do_cpc : std_logic; -- ALU operation is CPC
|
728 |
|
|
signal do_cpc_d : std_logic; -- do_cpc, pipelined
|
729 |
|
|
signal do_daa : std_logic; -- ALU operation is DAA
|
730 |
|
|
signal flag_ac : std_logic; -- new computed half carry flag
|
731 |
|
|
-- flag_aux_cy: new computed half carry flag (used in 16-bit ops)
|
732 |
|
|
signal flag_aux_cy : std_logic;
|
733 |
|
|
signal load_psw : std_logic; -- load F register
|
734 |
|
|
|
735 |
|
|
-- aux carry computation and control signals
|
736 |
|
|
signal use_aux : std_logic; -- decoded from flags in 1st phase
|
737 |
|
|
signal use_aux_cy : std_logic; -- 2nd phase signal
|
738 |
|
|
signal reg_aux_cy : std_logic;
|
739 |
|
|
signal aux_cy_in : std_logic;
|
740 |
|
|
signal set_aux_cy : std_logic;
|
741 |
|
|
signal set_aux : std_logic;
|
742 |
|
|
|
743 |
|
|
-- ALU control signals -- together they select ALU operation
|
744 |
|
|
signal alu_fn : std_logic_vector(1 downto 0);
|
745 |
|
|
signal use_logic : std_logic; -- logic/arith mux control
|
746 |
|
|
signal mux_fn : std_logic_vector(1 downto 0);
|
747 |
|
|
signal use_psw : std_logic; -- ALU/F mux control
|
748 |
|
|
|
749 |
|
|
-- ALU arithmetic operands and result
|
750 |
|
|
signal arith_op1 : std_logic_vector(8 downto 0);
|
751 |
|
|
signal arith_op2 : std_logic_vector(8 downto 0);
|
752 |
|
|
signal arith_op2_sgn: std_logic_vector(8 downto 0);
|
753 |
|
|
signal arith_res : std_logic_vector(8 downto 0);
|
754 |
|
|
signal arith_res8 : std_logic_vector(7 downto 0);
|
755 |
|
|
|
756 |
|
|
-- ALU DAA intermediate signals (DAA has fully dedicated logic)
|
757 |
|
|
signal daa_res : std_logic_vector(8 downto 0);
|
758 |
|
|
signal daa_res8 : std_logic_vector(7 downto 0);
|
759 |
|
|
signal daa_res9 : std_logic_vector(8 downto 0);
|
760 |
|
|
signal daa_test1 : std_logic;
|
761 |
|
|
signal daa_test1a : std_logic;
|
762 |
|
|
signal daa_test2 : std_logic;
|
763 |
|
|
signal daa_test2a : std_logic;
|
764 |
|
|
signal arith_daa_res :std_logic_vector(7 downto 0);
|
765 |
|
|
signal cy_daa : std_logic;
|
766 |
|
|
|
767 |
|
|
-- ALU CY flag intermediate signals
|
768 |
|
|
signal cy_in_sgn : std_logic;
|
769 |
|
|
signal cy_in : std_logic;
|
770 |
|
|
signal cy_in_gated : std_logic;
|
771 |
|
|
signal cy_adder : std_logic;
|
772 |
|
|
signal cy_arith : std_logic;
|
773 |
|
|
signal cy_shifter : std_logic;
|
774 |
|
|
|
775 |
|
|
-- ALU intermediate results
|
776 |
|
|
signal logic_res : std_logic_vector(7 downto 0);
|
777 |
|
|
signal shift_res : std_logic_vector(7 downto 0);
|
778 |
|
|
signal alu_mux1 : std_logic_vector(7 downto 0);
|
779 |
|
|
|
780 |
49 |
ja_rd |
|
781 |
2 |
ja_rd |
begin
|
782 |
|
|
|
783 |
|
|
DI <= data_in;
|
784 |
|
|
|
785 |
|
|
process(clk) -- IR register, load when uc_decode flag activates
|
786 |
|
|
begin
|
787 |
|
|
if clk'event and clk='1' then
|
788 |
|
|
if uc_decode = '1' then
|
789 |
|
|
IR <= DI;
|
790 |
|
|
end if;
|
791 |
|
|
end if;
|
792 |
|
|
end process;
|
793 |
|
|
|
794 |
|
|
s_field <= IR(2 downto 0); -- IR field extraction : sss reg code
|
795 |
|
|
d_field <= IR(5 downto 3); -- ddd reg code
|
796 |
|
|
p_field <= IR(5 downto 4); -- pp 16-bit reg pair code
|
797 |
|
|
|
798 |
|
|
|
799 |
|
|
--##############################################################################
|
800 |
|
|
-- Microcode sequencer
|
801 |
|
|
|
802 |
|
|
process(clk) -- do_reset is reset delayed 1 cycle
|
803 |
|
|
begin
|
804 |
|
|
if clk'event and clk='1' then
|
805 |
|
|
do_reset <= reset;
|
806 |
|
|
end if;
|
807 |
|
|
end process;
|
808 |
|
|
|
809 |
|
|
uc_flags1 <= ucode(31 downto 29);
|
810 |
|
|
uc_flags2 <= ucode(28 downto 26);
|
811 |
|
|
|
812 |
|
|
-- microcode address control flags are gated by do_reset (reset has priority)
|
813 |
|
|
uc_do_ret <= '1' when uc_flags2 = "011" and do_reset = '0' else '0';
|
814 |
|
|
uc_jsr <= '1' when uc_flags2 = "010" and do_reset = '0' else '0';
|
815 |
|
|
uc_tjsr <= '1' when uc_flags2 = "100" and do_reset = '0' else '0';
|
816 |
|
|
uc_decode <= '1' when uc_flags1 = "001" and do_reset = '0' else '0';
|
817 |
|
|
uc_end <= '1' when (uc_flags2 = "001" or (uc_tjsr='1' and condition_reg='0'))
|
818 |
|
|
and do_reset = '0' else '0';
|
819 |
|
|
|
820 |
|
|
-- other microinstruction flags are decoded
|
821 |
|
|
uc_halt_flag <= '1' when uc_flags1 = "111" else '0';
|
822 |
|
|
uc_halt <= '1' when uc_halt_flag='1' and inta_reg='0' else '0';
|
823 |
|
|
uc_ei <= '1' when uc_flags1 = "011" else '0';
|
824 |
|
|
uc_di <= '1' when uc_flags1 = "010" or inta_reg='1' else '0';
|
825 |
|
|
-- clr_t1/2 clears T1/T2 when explicitly commanded; T2 and T1 clear implicitly
|
826 |
|
|
-- at the end of each instruction (by uc_decode)
|
827 |
|
|
clr_t2 <= '1' when uc_flags2 = "001" else '0';
|
828 |
|
|
clr_t1 <= '1' when uc_flags1 = "110" else '0';
|
829 |
|
|
use_aux <= '1' when uc_flags1 = "101" else '0';
|
830 |
|
|
set_aux <= '1' when uc_flags2 = "111" else '0';
|
831 |
|
|
|
832 |
|
|
load_al <= ucode(24);
|
833 |
|
|
load_addr <= ucode(25);
|
834 |
|
|
|
835 |
|
|
do_cy_op_d <= '1' when ucode(5 downto 2)="1011" else '0'; -- decode CY ALU op
|
836 |
|
|
do_cpc_d <= ucode(0); -- decode CPC ALU op
|
837 |
|
|
|
838 |
|
|
-- uinst jump command, either unconditional or on a given condition
|
839 |
|
|
uc_do_jmp <= uc_jsr or (uc_tjsr and condition_reg);
|
840 |
|
|
|
841 |
|
|
vma <= load_addr; -- addr is valid, either for memmory or io
|
842 |
|
|
|
843 |
19 |
ja_rd |
-- assume the only uinst that does memory access in the range 0..f is 'fetch'
|
844 |
|
|
fetch <= '1' when uc_addr(7 downto 4)=X"0" and load_addr='1' else '0';
|
845 |
|
|
|
846 |
2 |
ja_rd |
-- external bus interface control signals
|
847 |
|
|
io <= '1' when uc_flags1="100" else '0'; -- IO access (vs. memory)
|
848 |
|
|
rd <= '1' when uc_flags2="101" else '0'; -- RD access
|
849 |
|
|
wr <= '1' when uc_flags2="110" else '0'; -- WR access
|
850 |
|
|
|
851 |
|
|
uc_jmp_addr <= ucode(11 downto 10) & ucode(5 downto 0);
|
852 |
|
|
|
853 |
|
|
uc_addr_sel <= uc_do_ret & uc_do_jmp & uc_decode & uc_end;
|
854 |
|
|
|
855 |
|
|
addr_plus_1 <= uc_addr + 1;
|
856 |
|
|
|
857 |
|
|
-- TODO simplify this!!
|
858 |
|
|
|
859 |
|
|
-- NOTE: when end='1' we jump either to the FETCH ucode ot to the HALT ucode
|
860 |
|
|
-- depending on the value of the halt signal.
|
861 |
|
|
-- We use the unregistered uc_halt instead of halt_reg because otherwise #end
|
862 |
|
|
-- should be on the cycle following #halt, wasting a cycle.
|
863 |
|
|
-- This means that the flag #halt has to be used with #end or will be ignored.
|
864 |
|
|
|
865 |
|
|
with uc_addr_sel select
|
866 |
|
|
next_uc_addr <= '0'&uc_ret_addr when "1000", -- ret
|
867 |
|
|
'0'&uc_jmp_addr when "0100", -- jsr/tjsr
|
868 |
|
|
'0'&addr_plus_1 when "0000", -- uaddr++
|
869 |
|
|
"000000"&uc_halt&"11"
|
870 |
|
|
when "0001", -- end: go to fetch/halt uaddr
|
871 |
|
|
'1'&DI when others; -- decode fetched address
|
872 |
|
|
|
873 |
|
|
-- Note how we used DI (containing instruction opcode) as a microcode address
|
874 |
|
|
|
875 |
|
|
-- read microcode rom
|
876 |
|
|
process (clk)
|
877 |
|
|
begin
|
878 |
|
|
if clk'event and clk='1' then
|
879 |
|
|
ucode <= rom(conv_integer(next_uc_addr));
|
880 |
|
|
end if;
|
881 |
|
|
end process;
|
882 |
|
|
|
883 |
|
|
-- microcode address register
|
884 |
|
|
process (clk)
|
885 |
|
|
begin
|
886 |
|
|
if clk'event and clk='1' then
|
887 |
|
|
if reset = '1' then
|
888 |
|
|
uc_addr <= X"00";
|
889 |
|
|
else
|
890 |
|
|
uc_addr <= next_uc_addr(7 downto 0);
|
891 |
|
|
end if;
|
892 |
|
|
end if;
|
893 |
|
|
end process;
|
894 |
|
|
|
895 |
|
|
-- ucode address 1-level 'return stack'
|
896 |
|
|
process (clk)
|
897 |
|
|
begin
|
898 |
|
|
if clk'event and clk='1' then
|
899 |
|
|
if reset = '1' then
|
900 |
|
|
uc_ret_addr <= X"00";
|
901 |
|
|
elsif uc_do_jmp='1' then
|
902 |
|
|
uc_ret_addr <= addr_plus_1;
|
903 |
|
|
end if;
|
904 |
|
|
end if;
|
905 |
|
|
end process;
|
906 |
|
|
|
907 |
|
|
|
908 |
|
|
alu_op <= ucode(3 downto 0);
|
909 |
|
|
|
910 |
|
|
-- pipeline uinst field2 for 1-cycle delayed execution.
|
911 |
|
|
-- note the same rbank addr field is used in cycles 1 and 2; this enforces
|
912 |
|
|
-- some constraints on uinst programming but simplifies the system.
|
913 |
|
|
process(clk)
|
914 |
|
|
begin
|
915 |
|
|
if clk'event and clk='1' then
|
916 |
|
|
ucode_field2 <= do_cy_op_d & do_cpc_d & clr_t2 & clr_t1 &
|
917 |
|
|
set_aux & use_aux & rbank_rd_addr &
|
918 |
|
|
ucode(14 downto 4) & alu_op;
|
919 |
|
|
end if;
|
920 |
|
|
end process;
|
921 |
|
|
|
922 |
|
|
--#### HALT logic
|
923 |
|
|
process(clk)
|
924 |
|
|
begin
|
925 |
|
|
if clk'event and clk='1' then
|
926 |
|
|
if reset = '1' or int_pending = '1' then --inta_reg
|
927 |
|
|
halt_reg <= '0';
|
928 |
|
|
else
|
929 |
|
|
if uc_halt = '1' then
|
930 |
|
|
halt_reg <= '1';
|
931 |
|
|
end if;
|
932 |
|
|
end if;
|
933 |
|
|
end if;
|
934 |
|
|
end process;
|
935 |
|
|
|
936 |
|
|
halt <= halt_reg;
|
937 |
|
|
|
938 |
|
|
--#### INTE logic -- inte_reg = '1' means interrupts ENABLED
|
939 |
|
|
process(clk)
|
940 |
|
|
begin
|
941 |
|
|
if clk'event and clk='1' then
|
942 |
|
|
if reset = '1' then
|
943 |
|
|
inte_reg <= '0';
|
944 |
49 |
ja_rd |
delayed_ei <= '0';
|
945 |
2 |
ja_rd |
else
|
946 |
49 |
ja_rd |
if (uc_di='1' or uc_ei='1') and uc_end='1' then
|
947 |
|
|
--inte_reg <= uc_ei;
|
948 |
|
|
delayed_ei <= uc_ei; -- FIXME DI must not be delayed
|
949 |
2 |
ja_rd |
end if;
|
950 |
49 |
ja_rd |
if uc_end = '1' then -- at the last cycle of every instruction...
|
951 |
|
|
if uc_di='1' then -- ...disable interrupts if the instruction is DI...
|
952 |
|
|
inte_reg <= '0';
|
953 |
|
|
else
|
954 |
|
|
-- ...of enable interrupts after the instruction following EI
|
955 |
|
|
inte_reg <= delayed_ei;
|
956 |
|
|
end if;
|
957 |
|
|
end if;
|
958 |
2 |
ja_rd |
end if;
|
959 |
|
|
end if;
|
960 |
|
|
end process;
|
961 |
|
|
|
962 |
|
|
inte <= inte_reg;
|
963 |
|
|
|
964 |
39 |
ja_rd |
-- interrupts are ignored when inte='0' but they are registered and will be
|
965 |
|
|
-- honored when interrupts are enabled
|
966 |
2 |
ja_rd |
process(clk)
|
967 |
|
|
begin
|
968 |
|
|
if clk'event and clk='1' then
|
969 |
|
|
if reset = '1' then
|
970 |
|
|
int_pending <= '0';
|
971 |
|
|
else
|
972 |
39 |
ja_rd |
-- intr will raise int_pending only if inta has not been asserted.
|
973 |
|
|
-- Otherwise, if intr overlapped inta, we'd enter a microcode endless
|
974 |
|
|
-- loop, executing the interrupt vector again and again.
|
975 |
|
|
if intr='1' and inte_reg='1' and int_pending='0' and inta_reg='0' then
|
976 |
2 |
ja_rd |
int_pending <= '1';
|
977 |
|
|
else
|
978 |
39 |
ja_rd |
-- int_pending is cleared when we're about to service the interrupt,
|
979 |
|
|
-- that is when interrupts are enabled and the current instruction ends.
|
980 |
2 |
ja_rd |
if inte_reg = '1' and uc_end='1' then
|
981 |
|
|
int_pending <= '0';
|
982 |
|
|
end if;
|
983 |
|
|
end if;
|
984 |
|
|
end if;
|
985 |
|
|
end if;
|
986 |
|
|
end process;
|
987 |
|
|
|
988 |
|
|
|
989 |
|
|
--#### INTA logic
|
990 |
|
|
-- INTA goes high from END to END, that is for the entire time the instruction
|
991 |
|
|
-- takes to fetch and execute; in the original 8080 it was asserted only for
|
992 |
|
|
-- the M1 cycle.
|
993 |
|
|
-- All instructions can be used in an inta cycle, including XTHL which was
|
994 |
|
|
-- forbidden in the original 8080.
|
995 |
|
|
-- It's up to you figuring out which cycle is which in multibyte instructions.
|
996 |
|
|
process(clk)
|
997 |
|
|
begin
|
998 |
|
|
if clk'event and clk='1' then
|
999 |
|
|
if reset = '1' then
|
1000 |
|
|
inta_reg <= '0';
|
1001 |
|
|
else
|
1002 |
|
|
if int_pending = '1' and uc_end='1' then
|
1003 |
|
|
-- enter INTA state
|
1004 |
|
|
inta_reg <= '1';
|
1005 |
|
|
else
|
1006 |
|
|
-- exit INTA state
|
1007 |
|
|
-- NOTE: don't reset inta when exiting halt state (uc_halt_flag='1').
|
1008 |
|
|
-- If we omit this condition, when intr happens on halt state, inta
|
1009 |
|
|
-- will only last for 1 cycle, because in halt state uc_end is
|
1010 |
|
|
-- always asserted.
|
1011 |
|
|
if uc_end = '1' and uc_halt_flag='0' then
|
1012 |
|
|
inta_reg <= '0';
|
1013 |
|
|
end if;
|
1014 |
|
|
end if;
|
1015 |
|
|
end if;
|
1016 |
|
|
end if;
|
1017 |
|
|
end process;
|
1018 |
|
|
|
1019 |
|
|
inta <= inta_reg;
|
1020 |
|
|
|
1021 |
|
|
|
1022 |
|
|
--##############################################################################
|
1023 |
|
|
-- Datapath
|
1024 |
|
|
|
1025 |
|
|
-- extract pipelined microcode fields
|
1026 |
|
|
ra_field <= ucode(18 downto 15);
|
1027 |
|
|
load_t1 <= ucode(23);
|
1028 |
|
|
load_t2 <= ucode(22);
|
1029 |
|
|
mux_in <= ucode(21);
|
1030 |
|
|
rb_addr_sel <= ucode(20 downto 19);
|
1031 |
|
|
load_do <= ucode_field2(7);
|
1032 |
|
|
set_aux_cy <= ucode_field2(20);
|
1033 |
|
|
do_clr_t1 <= ucode_field2(21);
|
1034 |
|
|
do_clr_t2 <= ucode_field2(22);
|
1035 |
|
|
|
1036 |
|
|
|
1037 |
|
|
-- T1 register
|
1038 |
|
|
process (clk)
|
1039 |
|
|
begin
|
1040 |
|
|
if clk'event and clk='1' then
|
1041 |
|
|
if reset = '1' or uc_decode = '1' or do_clr_t1='1' then
|
1042 |
|
|
T1 <= X"00";
|
1043 |
|
|
else
|
1044 |
|
|
if load_t1 = '1' then
|
1045 |
|
|
T1 <= alu_input;
|
1046 |
|
|
end if;
|
1047 |
|
|
end if;
|
1048 |
|
|
end if;
|
1049 |
|
|
end process;
|
1050 |
|
|
|
1051 |
|
|
-- T2 register
|
1052 |
|
|
process (clk)
|
1053 |
|
|
begin
|
1054 |
|
|
if clk'event and clk='1' then
|
1055 |
|
|
if reset = '1' or uc_decode = '1' or do_clr_t2='1' then
|
1056 |
|
|
T2 <= X"00";
|
1057 |
|
|
else
|
1058 |
|
|
if load_t2 = '1' then
|
1059 |
|
|
T2 <= alu_input;
|
1060 |
|
|
end if;
|
1061 |
|
|
end if;
|
1062 |
|
|
end if;
|
1063 |
|
|
end process;
|
1064 |
|
|
|
1065 |
|
|
-- T1/T2 input data mux
|
1066 |
|
|
alu_input <= rbank_data when mux_in = '1' else DI;
|
1067 |
|
|
|
1068 |
|
|
-- register bank address mux logic
|
1069 |
|
|
|
1070 |
|
|
rbh <= '1' when p_field = "11" else '0';
|
1071 |
|
|
|
1072 |
|
|
with rb_addr_sel select
|
1073 |
|
|
rbank_rd_addr <= ra_field when "00",
|
1074 |
|
|
"0"&s_field when "01",
|
1075 |
|
|
"0"&d_field when "10",
|
1076 |
|
|
rbh&p_field&ra_field(0) when others;
|
1077 |
|
|
|
1078 |
|
|
-- RBank writes are inhibited in INTA state, but only for PC increments.
|
1079 |
|
|
inhibit_pc_increment <= '1' when inta_reg='1' and use_aux_cy='1'
|
1080 |
|
|
and rbank_wr_addr(3 downto 1) = "100"
|
1081 |
|
|
else '0';
|
1082 |
|
|
we_rb <= ucode_field2(6) and not inhibit_pc_increment;
|
1083 |
|
|
|
1084 |
|
|
-- Register bank logic
|
1085 |
|
|
-- NOTE: read is asynchronous, while write is synchronous; but note also
|
1086 |
|
|
-- that write phase for a given uinst happens the cycle after the read phase.
|
1087 |
|
|
-- This way we give the ALU time to do its job.
|
1088 |
|
|
rbank_wr_addr <= ucode_field2(18 downto 15);
|
1089 |
|
|
process(clk)
|
1090 |
|
|
begin
|
1091 |
|
|
if clk'event and clk='1' then
|
1092 |
|
|
if we_rb = '1' then
|
1093 |
|
|
rbank(conv_integer(rbank_wr_addr)) <= alu_output;
|
1094 |
|
|
end if;
|
1095 |
|
|
end if;
|
1096 |
|
|
end process;
|
1097 |
|
|
rbank_data <= rbank(conv_integer(rbank_rd_addr));
|
1098 |
|
|
|
1099 |
|
|
-- should we read F register or ALU output?
|
1100 |
|
|
use_psw <= '1' when ucode_field2(5 downto 4)="11" else '0';
|
1101 |
|
|
data_output <= flag_reg when use_psw = '1' else alu_output;
|
1102 |
|
|
|
1103 |
|
|
|
1104 |
|
|
process (clk)
|
1105 |
|
|
begin
|
1106 |
|
|
if clk'event and clk='1' then
|
1107 |
|
|
if load_do = '1' then
|
1108 |
|
|
DO <= data_output;
|
1109 |
|
|
end if;
|
1110 |
|
|
end if;
|
1111 |
|
|
end process;
|
1112 |
|
|
|
1113 |
|
|
--##############################################################################
|
1114 |
|
|
-- ALU
|
1115 |
|
|
|
1116 |
|
|
alu_fn <= ucode_field2(1 downto 0);
|
1117 |
|
|
use_logic <= ucode_field2(2);
|
1118 |
|
|
mux_fn <= ucode_field2(4 downto 3);
|
1119 |
|
|
--#### make sure this is "00" in the microcode when no F updates should happen!
|
1120 |
|
|
flag_pattern <= ucode_field2(9 downto 8);
|
1121 |
|
|
use_aux_cy <= ucode_field2(19);
|
1122 |
|
|
do_cpc <= ucode_field2(23);
|
1123 |
|
|
do_cy_op <= ucode_field2(24);
|
1124 |
|
|
do_daa <= '1' when ucode_field2(5 downto 2) = "1010" else '0';
|
1125 |
|
|
|
1126 |
|
|
aux_cy_in <= reg_aux_cy when set_aux_cy = '0' else '1';
|
1127 |
|
|
|
1128 |
|
|
-- carry input selection: normal or aux (for 16 bit increments)?
|
1129 |
|
|
cy_in <= flag_reg(0) when use_aux_cy = '0' else aux_cy_in;
|
1130 |
|
|
|
1131 |
|
|
-- carry is not used (0) in add/sub operations
|
1132 |
|
|
cy_in_gated <= cy_in and alu_fn(0);
|
1133 |
|
|
|
1134 |
|
|
--##### Adder/substractor
|
1135 |
|
|
|
1136 |
|
|
-- zero extend adder operands to 9 bits to ease CY output synthesis
|
1137 |
|
|
-- use zero extension because we're only interested in cy from 7 to 8
|
1138 |
|
|
arith_op1 <= '0' & T2;
|
1139 |
|
|
arith_op2 <= '0' & T1;
|
1140 |
|
|
|
1141 |
|
|
-- The adder/substractor is done in 2 stages to help XSL synth it properly
|
1142 |
|
|
-- Other codings result in 1 adder + a substractor + 1 mux
|
1143 |
|
|
|
1144 |
|
|
-- do 2nd op 2's complement if substracting...
|
1145 |
|
|
arith_op2_sgn <= arith_op2 when alu_fn(1) = '0' else not arith_op2;
|
1146 |
|
|
-- ...and complement cy input too
|
1147 |
|
|
cy_in_sgn <= cy_in_gated when alu_fn(1) = '0' else not cy_in_gated;
|
1148 |
|
|
|
1149 |
|
|
-- once 2nd operand has been negated (or not) add operands normally
|
1150 |
|
|
arith_res <= arith_op1 + arith_op2_sgn + cy_in_sgn;
|
1151 |
|
|
|
1152 |
|
|
-- take only 8 bits; 9th bit of adder is cy output
|
1153 |
|
|
arith_res8 <= arith_res(7 downto 0);
|
1154 |
|
|
cy_adder <= arith_res(8);
|
1155 |
|
|
|
1156 |
|
|
--##### DAA dedicated logic
|
1157 |
|
|
-- Note a DAA takes 2 cycles to complete!
|
1158 |
|
|
|
1159 |
|
|
--daa_test1a='1' when daa_res9(7 downto 4) > 0x06
|
1160 |
|
|
daa_test1a <= arith_op2(3) and (arith_op2(2) or arith_op2(1) or arith_op2(0));
|
1161 |
|
|
daa_test1 <= '1' when flag_reg(4)='1' or daa_test1a='1' else '0';
|
1162 |
|
|
|
1163 |
|
|
process(clk)
|
1164 |
|
|
begin
|
1165 |
|
|
if clk'event and clk='1' then
|
1166 |
|
|
if reset='1' then
|
1167 |
|
|
daa_res9 <= "000000000";
|
1168 |
|
|
else
|
1169 |
|
|
if daa_test1='1' then
|
1170 |
|
|
daa_res9 <= arith_op2 + "000000110";
|
1171 |
|
|
else
|
1172 |
|
|
daa_res9 <= arith_op2;
|
1173 |
|
|
end if;
|
1174 |
|
|
end if;
|
1175 |
|
|
end if;
|
1176 |
|
|
end process;
|
1177 |
|
|
|
1178 |
|
|
--daa_test2a='1' when daa_res9(7 downto 4) > 0x06 FIXME unused?
|
1179 |
|
|
daa_test2a <= daa_res9(7) and (daa_res9(6) or daa_res9(5) or daa_res9(4));
|
1180 |
|
|
daa_test2 <= '1' when flag_reg(0)='1' or daa_test1a='1' else '0';
|
1181 |
|
|
|
1182 |
|
|
daa_res <= '0'&daa_res9(7 downto 0) + "01100000" when daa_test2='1'
|
1183 |
|
|
else daa_res9;
|
1184 |
|
|
|
1185 |
|
|
cy_daa <= daa_res(8);
|
1186 |
|
|
|
1187 |
|
|
-- DAA vs. adder mux
|
1188 |
|
|
arith_daa_res <= daa_res(7 downto 0) when do_daa='1' else arith_res8;
|
1189 |
|
|
|
1190 |
|
|
-- DAA vs. adder CY mux
|
1191 |
|
|
cy_arith <= cy_daa when do_daa='1' else cy_adder;
|
1192 |
|
|
|
1193 |
|
|
--##### Logic operations block
|
1194 |
|
|
logic_res <= T1 and T2 when alu_fn = "00" else
|
1195 |
|
|
T1 xor T2 when alu_fn = "01" else
|
1196 |
|
|
T1 or T2 when alu_fn = "10" else
|
1197 |
|
|
not T1;
|
1198 |
|
|
|
1199 |
|
|
--##### Shifter
|
1200 |
|
|
shifter:
|
1201 |
|
|
for i in 1 to 6 generate
|
1202 |
|
|
begin
|
1203 |
|
|
shift_res(i) <= T1(i-1) when alu_fn(0) = '0' else T1(i+1);
|
1204 |
|
|
end generate;
|
1205 |
|
|
shift_res(0) <= T1(7) when alu_fn = "00" else -- rot left
|
1206 |
|
|
cy_in when alu_fn = "10" else -- rot left through carry
|
1207 |
|
|
T1(1); -- rot right
|
1208 |
|
|
shift_res(7) <= T1(0) when alu_fn = "01" else -- rot right
|
1209 |
|
|
cy_in when alu_fn = "11" else -- rot right through carry
|
1210 |
|
|
T1(6); -- rot left
|
1211 |
|
|
|
1212 |
|
|
cy_shifter <= T1(7) when alu_fn(0) = '0' else -- left
|
1213 |
|
|
T1(0); -- right
|
1214 |
|
|
|
1215 |
|
|
alu_mux1 <= logic_res when use_logic = '1' else shift_res;
|
1216 |
|
|
|
1217 |
|
|
|
1218 |
|
|
with mux_fn select
|
1219 |
|
|
alu_output <= alu_mux1 when "00",
|
1220 |
|
|
arith_daa_res when "01",
|
1221 |
|
|
not alu_mux1 when "10",
|
1222 |
|
|
"00"&d_field&"000" when others; -- RST
|
1223 |
|
|
|
1224 |
|
|
--###### flag computation
|
1225 |
|
|
|
1226 |
|
|
flag_s <= alu_output(7);
|
1227 |
|
|
flag_p <= not(alu_output(7) xor alu_output(6) xor alu_output(5) xor alu_output(4) xor
|
1228 |
|
|
alu_output(3) xor alu_output(2) xor alu_output(1) xor alu_output(0));
|
1229 |
|
|
flag_z <= '1' when alu_output=X"00" else '0';
|
1230 |
|
|
flag_ac <= (arith_op1(4) xor arith_op2_sgn(4) xor alu_output(4));
|
1231 |
|
|
|
1232 |
|
|
flag_cy_1 <= cy_arith when use_logic = '1' else cy_shifter;
|
1233 |
|
|
flag_cy_2 <= not flag_reg(0) when do_cpc='0' else '1'; -- cmc, stc
|
1234 |
|
|
flag_cy <= flag_cy_1 when do_cy_op='0' else flag_cy_2;
|
1235 |
|
|
|
1236 |
|
|
flag_aux_cy <= cy_adder;
|
1237 |
|
|
|
1238 |
|
|
-- auxiliary carry reg
|
1239 |
|
|
process(clk)
|
1240 |
|
|
begin
|
1241 |
|
|
if clk'event and clk='1' then
|
1242 |
|
|
if reset='1' or uc_decode = '1' then
|
1243 |
|
|
reg_aux_cy <= '1'; -- inits to 0 every instruction
|
1244 |
|
|
else
|
1245 |
|
|
reg_aux_cy <= flag_aux_cy;
|
1246 |
|
|
end if;
|
1247 |
|
|
end if;
|
1248 |
|
|
end process;
|
1249 |
|
|
|
1250 |
|
|
-- load PSW from ALU (i.e. POP AF) or from flag signals
|
1251 |
|
|
load_psw <= '1' when we_rb='1' and rbank_wr_addr="0110" else '0';
|
1252 |
|
|
|
1253 |
|
|
-- The F register has been split in two separate groupt that always update
|
1254 |
|
|
-- together (C and all others).
|
1255 |
|
|
|
1256 |
|
|
-- F register, flags S,Z,AC,P
|
1257 |
|
|
process(clk)
|
1258 |
|
|
begin
|
1259 |
|
|
if clk'event and clk='1' then
|
1260 |
|
|
if reset='1' then
|
1261 |
|
|
flag_reg(7) <= '0';
|
1262 |
|
|
flag_reg(6) <= '0';
|
1263 |
|
|
flag_reg(4) <= '0';
|
1264 |
|
|
flag_reg(2) <= '0';
|
1265 |
|
|
elsif flag_pattern(1) = '1' then
|
1266 |
|
|
if load_psw = '1' then
|
1267 |
|
|
flag_reg(7) <= alu_output(7);
|
1268 |
|
|
flag_reg(6) <= alu_output(6);
|
1269 |
|
|
flag_reg(4) <= alu_output(4);
|
1270 |
|
|
flag_reg(2) <= alu_output(2);
|
1271 |
|
|
else
|
1272 |
|
|
flag_reg(7) <= flag_s;
|
1273 |
|
|
flag_reg(6) <= flag_z;
|
1274 |
|
|
flag_reg(4) <= flag_ac;
|
1275 |
|
|
flag_reg(2) <= flag_p;
|
1276 |
|
|
end if;
|
1277 |
|
|
end if;
|
1278 |
|
|
end if;
|
1279 |
|
|
end procesS;
|
1280 |
|
|
|
1281 |
|
|
-- F register, flag C
|
1282 |
|
|
process(clk)
|
1283 |
|
|
begin
|
1284 |
|
|
if clk'event and clk='1' then
|
1285 |
|
|
if reset = '1' then
|
1286 |
|
|
flag_reg(0) <= '0';
|
1287 |
|
|
elsif flag_pattern(0) = '1' then
|
1288 |
|
|
if load_psw = '1' then
|
1289 |
|
|
flag_reg(0) <= alu_output(0);
|
1290 |
|
|
else
|
1291 |
|
|
flag_reg(0) <= flag_cy;
|
1292 |
|
|
end if;
|
1293 |
|
|
end if;
|
1294 |
|
|
end if;
|
1295 |
|
|
end procesS;
|
1296 |
|
|
|
1297 |
|
|
flag_reg(5) <= '0'; -- constant flag
|
1298 |
|
|
flag_reg(3) <= '0'; -- constant flag
|
1299 |
|
|
flag_reg(1) <= '1'; -- constant flag
|
1300 |
|
|
|
1301 |
|
|
--##### Condition computation
|
1302 |
|
|
|
1303 |
|
|
condition_sel <= d_field(2 downto 0);
|
1304 |
|
|
with condition_sel select
|
1305 |
|
|
condition <=
|
1306 |
|
|
not flag_reg(6) when "000", -- NZ
|
1307 |
|
|
flag_reg(6) when "001", -- Z
|
1308 |
|
|
not flag_reg(0) when "010", -- NC
|
1309 |
|
|
flag_reg(0) when "011", -- C
|
1310 |
|
|
not flag_reg(2) when "100", -- PO
|
1311 |
|
|
flag_reg(2) when "101", -- PE
|
1312 |
|
|
not flag_reg(7) when "110", -- P
|
1313 |
|
|
flag_reg(7) when others;-- M
|
1314 |
|
|
|
1315 |
|
|
|
1316 |
|
|
-- condition is registered to shorten the delay path; the extra 1-cycle
|
1317 |
|
|
-- delay is not relevant because conditions are tested in the next instruction
|
1318 |
|
|
-- at the earliest, and there's at least the fetch uinsts intervening.
|
1319 |
|
|
process(clk)
|
1320 |
|
|
begin
|
1321 |
|
|
if clk'event and clk='1' then
|
1322 |
|
|
if reset = '1' then
|
1323 |
|
|
condition_reg <= '0';
|
1324 |
|
|
else
|
1325 |
|
|
condition_reg <= condition;
|
1326 |
|
|
end if;
|
1327 |
|
|
end if;
|
1328 |
|
|
end process;
|
1329 |
|
|
|
1330 |
|
|
-- low byte address register
|
1331 |
|
|
process(clk)
|
1332 |
|
|
begin
|
1333 |
|
|
if clk'event and clk='1' then
|
1334 |
|
|
if reset = '1' then
|
1335 |
|
|
addr_low <= X"00";
|
1336 |
|
|
elsif load_al = '1' then
|
1337 |
|
|
addr_low <= rbank_data;
|
1338 |
|
|
end if;
|
1339 |
|
|
end if;
|
1340 |
|
|
end process;
|
1341 |
|
|
|
1342 |
|
|
-- note external address registers (high byte) are loaded directly from rbank
|
1343 |
|
|
addr_out <= rbank_data & addr_low;
|
1344 |
|
|
|
1345 |
|
|
data_out <= DO;
|
1346 |
|
|
|
1347 |
|
|
end microcoded;
|
1348 |
19 |
ja_rd |
|
1349 |
|
|
--------------------------------------------------------------------------------
|
1350 |
|
|
-- Timing diagram 1: RD and WR cycles
|
1351 |
|
|
--------------------------------------------------------------------------------
|
1352 |
|
|
-- 1 2 3 4 5 6 7 8
|
1353 |
|
|
-- __ __ __ __ __ __ __ __
|
1354 |
|
|
-- clk __/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__
|
1355 |
|
|
--
|
1356 |
39 |
ja_rd |
-- ==|=====|=====|=====|=====|=====|=====|=====|=====|
|
1357 |
|
|
--
|
1358 |
19 |
ja_rd |
-- addr_o xxxxxxxxxxxxxx< ADR >xxxxxxxxxxx< ADR >xxxxxxxxxxx
|
1359 |
|
|
--
|
1360 |
|
|
-- data_i xxxxxxxxxxxxxxxxxxxx< Din >xxxxxxxxxxxxxxxxxxxxxxx
|
1361 |
|
|
--
|
1362 |
|
|
-- data_o xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx< Dout>xxxxxxxxxxx
|
1363 |
|
|
-- _____ _____
|
1364 |
|
|
-- vma_o ______________/ \___________/ \___________
|
1365 |
|
|
-- _____
|
1366 |
|
|
-- rd_o ______________/ \_____________________________
|
1367 |
|
|
-- _____
|
1368 |
|
|
-- wr_o ________________________________/ \___________
|
1369 |
|
|
--
|
1370 |
|
|
-- (functional diagram, actual time delays not shown)
|
1371 |
|
|
--------------------------------------------------------------------------------
|
1372 |
|
|
-- This diagram shows a read cycle and a write cycle back to back.
|
1373 |
|
|
-- In clock edges (4) and (7), the address is loaded into the external
|
1374 |
|
|
-- synchronous RAM address register.
|
1375 |
|
|
-- In clock edge (5), read data is loaded into the CPU.
|
1376 |
|
|
-- In clock edge (7), write data is loaded into the external synchronous RAM.
|
1377 |
|
|
-- In actual operation, the CPU does about 1 rd/wr cycle for each 5 clock
|
1378 |
|
|
-- cycles, which is a waste of RAM bandwidth.
|
1379 |
|
|
--
|