-
Notifications
You must be signed in to change notification settings - Fork 1
/
i8080_microcode_controller.vhd
83 lines (67 loc) · 1.95 KB
/
i8080_microcode_controller.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
library ieee;
use ieee.std_logic_1164.all;
use work.i8080_util.all;
entity i8080_microcode_controller is
port (
clk, en, reset: in std_logic;
inst_byte: in std_logic_vector(7 downto 0);
cpuinfo: in ucode_ctrl_cpuinfo;
cs: out cpu_control_signals := CPU_CONTROL_SIGNALS_DEFAULT
);
end entity;
architecture rtl of i8080_microcode_controller is
signal current_ui, next_ui: microinstruction := fetch_inst_0;
signal csi: cpu_control_signals := CPU_CONTROL_SIGNALS_DEFAULT;
begin
cs <= csi;
register_next_microinstruction: process (clk, en, reset, next_ui) is
begin
if rising_edge(clk) then
if reset = '1' then
current_ui <= fetch_inst_0;
elsif en = '1' then
current_ui <= next_ui;
end if;
end if;
end process;
select_next_microinstruction: process (csi, cpuinfo, current_ui, inst_byte) is
begin
case csi.uc.op is
when Jump_next_when_read_complete =>
if cpuinfo.read_done = '1' then
next_ui <= get_next_ui(current_ui);
else
next_ui <= current_ui;
end if;
when Jump_next =>
next_ui <= get_next_ui(current_ui);
when Jump_fetch_inst_0 =>
-- TODO: add interrupt handling here
next_ui <= fetch_inst_0;
when Jump_fetch_inst_0_COND =>
-- Jump to fetch inst 0 if cond bit is NOT satisfied
if cpuinfo.cond then
next_ui <= get_next_ui(current_ui);
else
next_ui <= fetch_inst_0;
end if;
when Jump_inst_byte =>
next_ui <= get_ucode_routine(inst_byte, get_inst(inst_byte));
-- FIXME: maybe refactor code so that we dont bring the binary
-- inst byte here, just the enum. Remove the double function,
-- if worth it...
when Try_jump_to_int_handler =>
if cpuinfo.int = '1' and cpuinfo.ie = '1' then
next_ui <= inst_HW_INT_0;
else
next_ui <= get_next_ui(current_ui);
end if;
end case;
end process;
microcode_inst: entity work.i8080_microcode(rtl)
port map (
current_ui => current_ui,
inst_byte => inst_byte,
cs => csi
);
end architecture;