1 |
2 |
trurl |
------------------------------------------------------------------
|
2 |
|
|
--!
|
3 |
|
|
--! PDP-8 Processor
|
4 |
|
|
--!
|
5 |
|
|
--! \brief
|
6 |
|
|
--! CPU Memory Address (MA) Register
|
7 |
|
|
--!
|
8 |
|
|
--! \details
|
9 |
|
|
--! The Memory Address (MA) Register provides the address
|
10 |
|
|
--! that is asserted onto the address bus on the subsequent
|
11 |
|
|
--! memory reads or writes.
|
12 |
|
|
--!
|
13 |
|
|
--! \file
|
14 |
|
|
--! ma.vhd
|
15 |
|
|
--!
|
16 |
|
|
--! \author
|
17 |
|
|
--! Rob Doyle - doyle (at) cox (dot) net
|
18 |
|
|
--!
|
19 |
|
|
--------------------------------------------------------------------
|
20 |
|
|
--
|
21 |
|
|
-- Copyright (C) 2009, 2010, 2011, 2012 Rob Doyle
|
22 |
|
|
--
|
23 |
|
|
-- This source file may be used and distributed without
|
24 |
|
|
-- restriction provided that this copyright statement is not
|
25 |
|
|
-- removed from the file and that any derivative work contains
|
26 |
|
|
-- the original copyright notice and the associated disclaimer.
|
27 |
|
|
--
|
28 |
|
|
-- This source file is free software; you can redistribute it
|
29 |
|
|
-- and/or modify it under the terms of the GNU Lesser General
|
30 |
|
|
-- Public License as published by the Free Software Foundation;
|
31 |
|
|
-- version 2.1 of the License.
|
32 |
|
|
--
|
33 |
|
|
-- This source is distributed in the hope that it will be
|
34 |
|
|
-- useful, but WITHOUT ANY WARRANTY; without even the implied
|
35 |
|
|
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
36 |
|
|
-- PURPOSE. See the GNU Lesser General Public License for more
|
37 |
|
|
-- details.
|
38 |
|
|
--
|
39 |
|
|
-- You should have received a copy of the GNU Lesser General
|
40 |
|
|
-- Public License along with this source; if not, download it
|
41 |
|
|
-- from http://www.gnu.org/licenses/lgpl.txt
|
42 |
|
|
--
|
43 |
|
|
--------------------------------------------------------------------
|
44 |
|
|
--
|
45 |
|
|
-- Comments are formatted for doxygen
|
46 |
|
|
--
|
47 |
|
|
|
48 |
|
|
library ieee; --! IEEE Library
|
49 |
|
|
use ieee.std_logic_1164.all; --! IEEE 1164
|
50 |
|
|
use ieee.numeric_std.all; --! IEEE Numeric Standard
|
51 |
|
|
use work.cpu_types.all; --! Types
|
52 |
|
|
|
53 |
|
|
--
|
54 |
|
|
--! CPU Memory Address (MA) Register Entity
|
55 |
|
|
--
|
56 |
|
|
|
57 |
|
|
entity eMA is port (
|
58 |
|
|
sys : in sys_t; --! Clock/Reset
|
59 |
|
|
maOP : in maOP_t; --! MA Operation
|
60 |
|
|
IR : in data_t; --! Instruction Register
|
61 |
|
|
MB : in data_t; --! Memory Buffer
|
62 |
|
|
MD : in data_t; --! Memory Data
|
63 |
|
|
PC : in addr_t; --! Program Counter
|
64 |
|
|
SP1 : in addr_t; --! Stack Pointer 1
|
65 |
|
|
SP2 : in addr_t; --! Stack Pointer 2
|
66 |
|
|
SR : in data_t; --! Switch Register
|
67 |
|
|
MA : out addr_t --! MA Output
|
68 |
|
|
);
|
69 |
|
|
end eMA;
|
70 |
|
|
|
71 |
|
|
--
|
72 |
|
|
--! CPU Memory Address (MA) Register RTL
|
73 |
|
|
--
|
74 |
|
|
|
75 |
|
|
architecture rtl of eMA is
|
76 |
|
|
|
77 |
|
|
signal maREG : addr_t; --! Memory Address Register
|
78 |
|
|
signal addMUX1 : addr_t; --! Adder Mux #1
|
79 |
|
|
signal addMUX2 : addr_t; --! Adder Mux #2
|
80 |
|
|
signal CP : addr_t; --! Current Page Addr
|
81 |
|
|
signal ZP : addr_t; --! Zero Page Addr
|
82 |
|
|
|
83 |
|
|
begin
|
84 |
|
|
|
85 |
|
|
--
|
86 |
|
|
-- Current Page and Zero Page addresses
|
87 |
|
|
--
|
88 |
|
|
|
89 |
|
|
CP <= maREG(0 to 4) & IR(5 to 11); -- Current Page Addr
|
90 |
|
|
ZP <= "00000" & IR(5 to 11); -- Zero Page Addr
|
91 |
|
|
|
92 |
|
|
--
|
93 |
|
|
-- Adder input #1 mux.
|
94 |
|
|
-- This synthesizes into a ROM
|
95 |
|
|
--
|
96 |
|
|
|
97 |
|
|
with maOP select
|
98 |
|
|
addMUX1 <= o"0000" when maopNOP, -- MA <- MA
|
99 |
|
|
o"0000" when maop0000, -- MA <- o"0000"
|
100 |
|
|
o"0000" when maopIR, -- MA <- IR
|
101 |
|
|
o"0000" when maopPC, -- MA <- PC
|
102 |
|
|
o"0000" when maopMB, -- MA <- MB
|
103 |
|
|
o"0000" when maopMD, -- MA <- MD
|
104 |
|
|
o"0000" when maopSP1, -- MA <- SP1
|
105 |
|
|
o"0000" when maopSP2, -- MA <- SP2
|
106 |
|
|
o"0000" when maopSR, -- MA <- SR
|
107 |
|
|
o"0000" when maopZP, -- MA <- zeroPage & IR(5 to 11)
|
108 |
|
|
o"0000" when maopCP, -- MA <- currPage & IR(5 to 11)
|
109 |
|
|
o"0001" when maopINC, -- MA <- MA + 1
|
110 |
|
|
o"0001" when maopPCP1, -- MA <- PC + 1
|
111 |
|
|
o"0001" when maopMDP1, -- MA <- MD + 1
|
112 |
|
|
o"0001" when maopSP1P1, -- MA <- SP1 + 1
|
113 |
|
|
o"0001" when maopSP2P1; -- MA <- SP2 + 1
|
114 |
|
|
|
115 |
|
|
--
|
116 |
|
|
-- Adder input #2 mux.
|
117 |
|
|
--
|
118 |
|
|
|
119 |
|
|
with maOP select
|
120 |
|
|
addMUX2 <= maREG when maopNOP, -- MA <- MA
|
121 |
|
|
o"0000" when maop0000, -- MA <- o"0000"
|
122 |
|
|
IR when maopIR, -- MA <- IR
|
123 |
|
|
PC when maopPC, -- MA <- PC
|
124 |
|
|
MB when maopMB, -- MA <- MB
|
125 |
|
|
MD when maopMD, -- MA <- MD
|
126 |
|
|
SP1 when maopSP1, -- MA <- SP1
|
127 |
|
|
SP2 when maopSP2, -- MA <- SP2
|
128 |
|
|
SR when maopSR, -- MA <- SR
|
129 |
|
|
ZP when maopZP, -- MA <- zeroPage & IR(5 to 11)
|
130 |
|
|
CP when maopCP, -- MA <- currPage & IR(5 to 11)
|
131 |
|
|
maREG when maopINC, -- MA <- MA + 1
|
132 |
|
|
PC when maopPCP1, -- MA <- PC + 1
|
133 |
|
|
MD when maopMDP1, -- MA <- MD + 1
|
134 |
|
|
SP1 when maopSP1P1, -- MA <- SP1 + 1
|
135 |
|
|
SP2 when maopSP2P1; -- MA <- SP2 + 1
|
136 |
|
|
|
137 |
|
|
--
|
138 |
|
|
--! MA Register
|
139 |
|
|
--
|
140 |
|
|
|
141 |
|
|
REG_MA : process(sys)
|
142 |
|
|
begin
|
143 |
|
|
if sys.rst = '1' then
|
144 |
|
|
maREG <= (others => '0');
|
145 |
|
|
elsif rising_edge(sys.clk) then
|
146 |
|
|
maREG <= std_logic_vector(unsigned(addMUX2) + unsigned(addMUX1));
|
147 |
|
|
end if;
|
148 |
|
|
end process REG_MA;
|
149 |
|
|
|
150 |
|
|
MA <= maREG;
|
151 |
|
|
|
152 |
|
|
end rtl;
|