-
Notifications
You must be signed in to change notification settings - Fork 1
/
i8080_address_unit.vhd
86 lines (67 loc) · 1.85 KB
/
i8080_address_unit.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
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.i8080_util.all;
entity i8080_address_unit is
port (
clk: in std_logic;
cs: in address_control_signals;
b, c, d, e, h, l: in std_logic_vector(7 downto 0);
pc, sp: in std_logic_vector(15 downto 0);
addr: out std_logic_vector(15 downto 0)
);
end entity;
architecture pipeline_2_cycle of i8080_address_unit is
signal bc, de, hl: std_logic_vector(15 downto 0) := X"0000";
signal pc_to_hl_muxed:
std_logic_vector(15 downto 0) := X"0000";
signal sp_muxed:
std_logic_vector(15 downto 0) := X"0000";
signal addr_pre_offset: std_logic_vector(15 downto 0) := X"0000";
signal addr_post_offset: std_logic_vector(15 downto 0) := X"0000";
begin
-- Inputs
bc <= b & c;
de <= d & e;
hl <= h & l;
-- Outputs
addr <= addr_post_offset;
register_offset: process(clk, addr_pre_offset, cs.offset) is
begin
if rising_edge(clk) then
addr_post_offset <= std_logic_vector(
unsigned(addr_pre_offset) +
to_unsigned(cs.offset, addr_pre_offset'length)
);
end if;
end process;
reg_mux_level_1: process(clk, cs.mode, pc_to_hl_muxed, sp_muxed) is
begin
if rising_edge(clk) then
if cs.mode = ADDRMODE_PC
or cs.mode = ADDRMODE_BC
or cs.mode = ADDRMODE_DE
or cs.mode = ADDRMODE_HL
then
addr_pre_offset <= pc_to_hl_muxed;
elsif cs.mode = ADDRMODE_SP
then
addr_pre_offset <= sp_muxed;
end if;
end if;
end process;
reg_mux_level_0: process (pc, bc, de, hl, sp, cs.mode)
is
begin
-- Limit muxes to 4 inputs
case cs.mode is
-- First mux
when ADDRMODE_PC => pc_to_hl_muxed <= pc;
when ADDRMODE_BC => pc_to_hl_muxed <= bc;
when ADDRMODE_DE => pc_to_hl_muxed <= de;
when ADDRMODE_HL => pc_to_hl_muxed <= hl;
-- Second mux
when ADDRMODE_SP => sp_muxed <= sp;
end case;
end process;
end architecture;