1 ------------------------------------------------------------------------------
2 -- t80as.vhd : The non-tristate signal edition of t80a.vhd
4 -- 2003.2.7 non-tristate modification by Tatsuyuki Satoh
6 -- 1.separate 'D' to 'DO' and 'DI'.
7 -- 2.added 'DOE' to 'DO' enable signal.(data direction)
8 -- 3.MREQ_n,IORQ_n,RD_n,WR_n,RFSH_n,A doesn't become the condition of 'Z'.
10 -- There is a mark of "--AS" in all the change points.
12 ------------------------------------------------------------------------------
15 -- Z80 compatible microprocessor core, asynchronous top level
19 -- Copyright (c) 2001-2002 Daniel Wallner (jesus@opencores.org)
21 -- All rights reserved
23 -- Redistribution and use in source and synthezised forms, with or without
24 -- modification, are permitted provided that the following conditions are met:
26 -- Redistributions of source code must retain the above copyright notice,
27 -- this list of conditions and the following disclaimer.
29 -- Redistributions in synthesized form must reproduce the above copyright
30 -- notice, this list of conditions and the following disclaimer in the
31 -- documentation and/or other materials provided with the distribution.
33 -- Neither the name of the author nor the names of other contributors may
34 -- be used to endorse or promote products derived from this software without
35 -- specific prior written permission.
37 -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38 -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
39 -- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 -- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
41 -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43 -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44 -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45 -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
47 -- POSSIBILITY OF SUCH DAMAGE.
49 -- Please report bugs to the author, but before you do so, please
50 -- make sure that this is not a derivative work and that
51 -- you have the latest version of this file.
53 -- The latest version of this file can be found at:
54 -- http://www.opencores.org/cvsweb.shtml/t80/
60 -- 0208 : First complete release
62 -- 0211 : Fixed interrupt cycle
64 -- 0235 : Updated for T80 interface change
66 -- 0238 : Updated for T80 interface change
68 -- 0240 : Updated for T80 interface change
70 -- 0242 : Updated for T80 interface change
72 -- 0247 : Fixed bus req/ack cycle
76 use IEEE.std_logic_1164.all;
77 use IEEE.numeric_std.all;
78 use work.T80_Pack.all;
82 Mode : integer := 0 -- 0 => Z80, 1 => Fast Z80, 2 => 8080, 3 => GB
85 RESET_n : in std_logic;
87 WAIT_n : in std_logic;
90 BUSRQ_n : in std_logic;
92 MREQ_n : out std_logic;
93 IORQ_n : out std_logic;
96 RFSH_n : out std_logic;
97 HALT_n : out std_logic;
98 BUSAK_n : out std_logic;
99 A : out std_logic_vector(15 downto 0);
100 --AS-- D : inout std_logic_vector(7 downto 0)
102 DI : in std_logic_vector(7 downto 0);
103 DO : out std_logic_vector(7 downto 0);
109 architecture rtl of T80as is
111 signal CEN : std_logic;
112 signal Reset_s : std_logic;
113 signal IntCycle_n : std_logic;
114 signal IORQ : std_logic;
115 signal NoRead : std_logic;
116 signal Write : std_logic;
117 signal MREQ : std_logic;
118 signal MReq_Inhibit : std_logic;
119 signal Req_Inhibit : std_logic;
120 signal RD : std_logic;
121 signal MREQ_n_i : std_logic;
122 signal IORQ_n_i : std_logic;
123 signal RD_n_i : std_logic;
124 signal WR_n_i : std_logic;
125 signal RFSH_n_i : std_logic;
126 signal BUSAK_n_i : std_logic;
127 signal A_i : std_logic_vector(15 downto 0);
128 --AS-- signal DO : std_logic_vector(7 downto 0);
129 signal DI_Reg : std_logic_vector (7 downto 0); -- Input synchroniser
130 signal Wait_s : std_logic;
131 signal MCycle : std_logic_vector(2 downto 0);
132 signal TState : std_logic_vector(2 downto 0);
138 BUSAK_n <= BUSAK_n_i;
139 MREQ_n_i <= not MREQ or (Req_Inhibit and MReq_Inhibit);
140 RD_n_i <= not RD or Req_Inhibit;
142 --AS-- MREQ_n <= MREQ_n_i when BUSAK_n_i = '1' else 'Z';
143 --AS-- IORQ_n <= IORQ_n_i when BUSAK_n_i = '1' else 'Z';
144 --AS-- RD_n <= RD_n_i when BUSAK_n_i = '1' else 'Z';
145 --AS-- WR_n <= WR_n_i when BUSAK_n_i = '1' else 'Z';
146 --AS-- RFSH_n <= RFSH_n_i when BUSAK_n_i = '1' else 'Z';
147 --AS-- A <= A_i when BUSAK_n_i = '1' else (others => 'Z');
148 --AS-- D <= DO when Write = '1' and BUSAK_n_i = '1' else (others => 'Z');
156 DOE <= Write when BUSAK_n_i = '1' else '0';
158 process (RESET_n, CLK_n)
160 if RESET_n = '0' then
162 elsif CLK_n'event and CLK_n = '1' then
184 BUSAK_n => BUSAK_n_i,
193 IntCycle_n => IntCycle_n);
197 if CLK_n'event and CLK_n = '0' then
199 if TState = "011" and BUSAK_n_i = '1' then
200 --AS-- DI_Reg <= to_x01(D);
202 DI_Reg <= to_x01(DI);
208 process (Reset_s,CLK_n)
210 if Reset_s = '0' then
212 elsif CLK_n'event and CLK_n = '1' then
214 if TState = "001" then -- To short for IO writes !!!!!!!!!!!!!!!!!!!
220 process (Reset_s,CLK_n)
222 if Reset_s = '0' then
224 elsif CLK_n'event and CLK_n = '1' then
225 if MCycle = "001" and TState = "010" then
233 process (Reset_s,CLK_n)
235 if Reset_s = '0' then
237 elsif CLK_n'event and CLK_n = '0' then
238 if MCycle = "001" and TState = "010" then
246 process(Reset_s,CLK_n)
248 if Reset_s = '0' then
252 elsif CLK_n'event and CLK_n = '0' then
254 if MCycle = "001" then
255 if TState = "001" then
258 IORQ_n_i <= IntCycle_n;
260 if TState = "011" then
265 if TState = "100" then
269 if TState = "001" and NoRead = '0' then
271 IORQ_n_i <= not IORQ;
274 if TState = "011" then