OpenCores
URL https://opencores.org/ocsvn/t80/t80/trunk

Subversion Repositories t80

[/] [t80/] [trunk/] [rtl/] [vhdl/] [T80a.vhd] - Blame information for rev 35

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 jesus
--
2
-- Z80 compatible microprocessor core, asynchronous top level
3
--
4 35 jesus
-- Version : 0242
5 7 jesus
--
6 15 jesus
-- Copyright (c) 2001-2002 Daniel Wallner (jesus@opencores.org)
7 7 jesus
--
8
-- All rights reserved
9
--
10
-- Redistribution and use in source and synthezised forms, with or without
11
-- modification, are permitted provided that the following conditions are met:
12
--
13
-- Redistributions of source code must retain the above copyright notice,
14
-- this list of conditions and the following disclaimer.
15
--
16
-- Redistributions in synthesized form must reproduce the above copyright
17
-- notice, this list of conditions and the following disclaimer in the
18
-- documentation and/or other materials provided with the distribution.
19
--
20
-- Neither the name of the author nor the names of other contributors may
21
-- be used to endorse or promote products derived from this software without
22
-- specific prior written permission.
23
--
24
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
28
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
-- POSSIBILITY OF SUCH DAMAGE.
35
--
36
-- Please report bugs to the author, but before you do so, please
37
-- make sure that this is not a derivative work and that
38
-- you have the latest version of this file.
39
--
40
-- The latest version of this file can be found at:
41 15 jesus
--      http://www.opencores.org/cvsweb.shtml/t80/
42 7 jesus
--
43
-- Limitations :
44
--
45
-- File history :
46
--
47
--      0208 : First complete release
48
--
49
--      0211 : Fixed interrupt cycle
50
--
51 15 jesus
--      0235 : Updated for T80 interface change
52
--
53 25 jesus
--      0238 : Updated for T80 interface change
54
--
55 29 jesus
--      0240 : Updated for T80 interface change
56
--
57 35 jesus
--      0242 : Updated for T80 interface change
58
--
59 7 jesus
 
60
library IEEE;
61
use IEEE.std_logic_1164.all;
62
use IEEE.numeric_std.all;
63
use work.T80_Pack.all;
64
 
65
entity T80a is
66
        generic(
67
                Mode : integer := 0      -- 0 => Z80, 1 => Fast Z80, 2 => 8080, 3 => GB
68
        );
69
        port(
70
                RESET_n         : in std_logic;
71
                CLK_n           : in std_logic;
72
                WAIT_n          : in std_logic;
73
                INT_n           : in std_logic;
74
                NMI_n           : in std_logic;
75
                BUSRQ_n         : in std_logic;
76
                M1_n            : out std_logic;
77
                MREQ_n          : out std_logic;
78
                IORQ_n          : out std_logic;
79
                RD_n            : out std_logic;
80
                WR_n            : out std_logic;
81
                RFSH_n          : out std_logic;
82
                HALT_n          : out std_logic;
83
                BUSAK_n         : out std_logic;
84
                A                       : out std_logic_vector(15 downto 0);
85
                D                       : inout std_logic_vector(7 downto 0)
86
        );
87
end T80a;
88
 
89
architecture rtl of T80a is
90
 
91 15 jesus
        signal CEN                      : std_logic;
92 7 jesus
        signal Reset_s          : std_logic;
93
        signal IntCycle_n       : std_logic;
94
        signal IORQ                     : std_logic;
95 25 jesus
        signal NoRead           : std_logic;
96 7 jesus
        signal Write            : std_logic;
97
        signal MREQ                     : std_logic;
98
        signal MReq_Inhibit     : std_logic;
99
        signal Req_Inhibit      : std_logic;
100
        signal RD                       : std_logic;
101
        signal WR_i                     : std_logic;
102
        signal DO                       : std_logic_vector(7 downto 0);
103
        signal DI_Reg           : std_logic_vector (7 downto 0); -- Input synchroniser
104
        signal Wait_s           : std_logic;
105
        signal MCycle           : std_logic_vector(2 downto 0);
106
        signal TState           : std_logic_vector(2 downto 0);
107
 
108
begin
109
 
110 15 jesus
        CEN <= '1';
111
 
112 7 jesus
        process (RESET_n, CLK_n)
113
        begin
114
                if RESET_n = '0' then
115
                        Reset_s <= '0';
116
                elsif CLK_n'event and CLK_n = '1' then
117
                        Reset_s <= '1';
118
                end if;
119
        end process;
120
 
121
        u0 : T80
122
                generic map(
123 35 jesus
                        Mode => Mode,
124
                        IOWait => 1)
125 7 jesus
                port map(
126 15 jesus
                        CEN => CEN,
127 7 jesus
                        M1_n => M1_n,
128
                        IORQ => IORQ,
129 25 jesus
                        NoRead => NoRead,
130 7 jesus
                        Write => Write,
131
                        RFSH_n => RFSH_n,
132
                        HALT_n => HALT_n,
133
                        WAIT_n => Wait_s,
134
                        INT_n => INT_n,
135
                        NMI_n => NMI_n,
136
                        RESET_n => Reset_s,
137
                        BUSRQ_n => BUSRQ_n,
138
                        BUSAK_n => BUSAK_n,
139
                        CLK_n => CLK_n,
140
                        A => A,
141
                        DInst => D,
142
                        DI => DI_Reg,
143
                        DO => DO,
144
                        MC => MCycle,
145
                        TS => TState,
146
                        IntCycle_n => IntCycle_n);
147
 
148
        D <= DO when Write = '1' else (others => 'Z');
149
 
150
        process (CLK_n)
151
        begin
152
                if CLK_n'event and CLK_n = '0' then
153
                        WR_n <= WR_i;
154
                        Wait_s <= WAIT_n;
155
                        if TState = "011" then
156
                                DI_Reg <= to_x01(D);
157
                        end if;
158
                end if;
159
        end process;
160
 
161
        MREQ_n <= not MREQ or (Req_Inhibit and MReq_Inhibit);
162
        RD_n <= not RD or Req_Inhibit;
163
 
164
        process (Reset_s,CLK_n)
165
        begin
166
                if Reset_s = '0' then
167
                        WR_i <= '1';
168
                elsif CLK_n'event and CLK_n = '1' then
169
                        WR_i <= '1';
170
                        if TState = "001" then  -- To short for IO writes !!!!!!!!!!!!!!!!!!!
171
                                WR_i <= not Write;
172
                        end if;
173
                end if;
174
        end process;
175
 
176
        process (Reset_s,CLK_n)
177
        begin
178
                if Reset_s = '0' then
179
                        Req_Inhibit <= '0';
180
                elsif CLK_n'event and CLK_n = '1' then
181 29 jesus
                        if MCycle = "001" and TState = "010" then
182 7 jesus
                                Req_Inhibit <= '1';
183
                        else
184
                                Req_Inhibit <= '0';
185
                        end if;
186
                end if;
187
        end process;
188
 
189
        process (Reset_s,CLK_n)
190
        begin
191
                if Reset_s = '0' then
192
                        MReq_Inhibit <= '0';
193
                elsif CLK_n'event and CLK_n = '0' then
194
                        if MCycle = "001" and TState = "010" then
195
                                MReq_Inhibit <= '1';
196
                        else
197
                                MReq_Inhibit <= '0';
198
                        end if;
199
                end if;
200
        end process;
201
 
202
        process(Reset_s,CLK_n)
203
        begin
204
                if Reset_s = '0' then
205
                        RD <= '0';
206
                        IORQ_n <= '1';
207
                        MREQ <= '0';
208
                elsif CLK_n'event and CLK_n = '0' then
209
 
210 29 jesus
                        if MCycle = "001" then
211 7 jesus
                                if TState = "001" then
212
                                        RD <= IntCycle_n;
213
                                        MREQ <= IntCycle_n;
214
                                        IORQ_n <= IntCycle_n;
215
                                end if;
216
                                if TState = "011" then
217
                                        RD <= '0';
218
                                        IORQ_n <= '1';
219
                                        MREQ <= '1';
220
                                end if;
221
                                if TState = "100" then
222
                                        MREQ <= '0';
223
                                end if;
224
                        else
225 25 jesus
                                if TState = "001" and NoRead = '0' then
226 7 jesus
                                        RD <= not Write;
227
                                        IORQ_n <= not IORQ;
228
                                        MREQ <= not IORQ;
229
                                end if;
230
                                if TState = "011" then
231
                                        RD <= '0';
232
                                        IORQ_n <= '1';
233
                                        MREQ <= '0';
234
                                end if;
235
                        end if;
236
                end if;
237
        end process;
238
 
239
end;

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.