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

Subversion Repositories t80

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

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 25 jesus
-- Version : 0238
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 7 jesus
 
56
library IEEE;
57
use IEEE.std_logic_1164.all;
58
use IEEE.numeric_std.all;
59
use work.T80_Pack.all;
60
 
61
entity T80a is
62
        generic(
63
                Mode : integer := 0      -- 0 => Z80, 1 => Fast Z80, 2 => 8080, 3 => GB
64
        );
65
        port(
66
                RESET_n         : in std_logic;
67
                CLK_n           : in std_logic;
68
                WAIT_n          : in std_logic;
69
                INT_n           : in std_logic;
70
                NMI_n           : in std_logic;
71
                BUSRQ_n         : in std_logic;
72
                M1_n            : out std_logic;
73
                MREQ_n          : out std_logic;
74
                IORQ_n          : out std_logic;
75
                RD_n            : out std_logic;
76
                WR_n            : out std_logic;
77
                RFSH_n          : out std_logic;
78
                HALT_n          : out std_logic;
79
                BUSAK_n         : out std_logic;
80
                A                       : out std_logic_vector(15 downto 0);
81
                D                       : inout std_logic_vector(7 downto 0)
82
        );
83
end T80a;
84
 
85
architecture rtl of T80a is
86
 
87 15 jesus
        signal CEN                      : std_logic;
88 7 jesus
        signal Reset_s          : std_logic;
89
        signal False_M1         : std_logic;
90
        signal IntCycle_n       : std_logic;
91
        signal IORQ                     : std_logic;
92 25 jesus
        signal NoRead           : std_logic;
93 7 jesus
        signal Write            : std_logic;
94
        signal MREQ                     : std_logic;
95
        signal MReq_Inhibit     : std_logic;
96
        signal Req_Inhibit      : std_logic;
97
        signal RD                       : std_logic;
98
        signal WR_i                     : std_logic;
99
        signal DO                       : std_logic_vector(7 downto 0);
100
        signal DI_Reg           : std_logic_vector (7 downto 0); -- Input synchroniser
101
        signal Wait_s           : std_logic;
102
        signal MCycle           : std_logic_vector(2 downto 0);
103
        signal TState           : std_logic_vector(2 downto 0);
104
 
105
begin
106
 
107 15 jesus
        CEN <= '1';
108
 
109 7 jesus
        process (RESET_n, CLK_n)
110
        begin
111
                if RESET_n = '0' then
112
                        Reset_s <= '0';
113
                elsif CLK_n'event and CLK_n = '1' then
114
                        Reset_s <= '1';
115
                end if;
116
        end process;
117
 
118
        u0 : T80
119
                generic map(
120
                        Mode => Mode)
121
                port map(
122 15 jesus
                        CEN => CEN,
123 7 jesus
                        M1_n => M1_n,
124
                        IORQ => IORQ,
125 25 jesus
                        NoRead => NoRead,
126 7 jesus
                        Write => Write,
127
                        RFSH_n => RFSH_n,
128
                        HALT_n => HALT_n,
129
                        WAIT_n => Wait_s,
130
                        INT_n => INT_n,
131
                        NMI_n => NMI_n,
132
                        RESET_n => Reset_s,
133
                        BUSRQ_n => BUSRQ_n,
134
                        BUSAK_n => BUSAK_n,
135
                        CLK_n => CLK_n,
136
                        A => A,
137
                        DInst => D,
138
                        DI => DI_Reg,
139
                        DO => DO,
140
                        MC => MCycle,
141
                        TS => TState,
142
                        False_M1 => False_M1,
143
                        IntCycle_n => IntCycle_n);
144
 
145
        D <= DO when Write = '1' else (others => 'Z');
146
 
147
        process (CLK_n)
148
        begin
149
                if CLK_n'event and CLK_n = '0' then
150
                        WR_n <= WR_i;
151
                        Wait_s <= WAIT_n;
152
                        if TState = "011" then
153
                                DI_Reg <= to_x01(D);
154
                        end if;
155
                end if;
156
        end process;
157
 
158
        MREQ_n <= not MREQ or (Req_Inhibit and MReq_Inhibit);
159
        RD_n <= not RD or Req_Inhibit;
160
 
161
        process (Reset_s,CLK_n)
162
        begin
163
                if Reset_s = '0' then
164
                        WR_i <= '1';
165
                elsif CLK_n'event and CLK_n = '1' then
166
                        WR_i <= '1';
167
                        if TState = "001" then  -- To short for IO writes !!!!!!!!!!!!!!!!!!!
168
                                WR_i <= not Write;
169
                        end if;
170
                end if;
171
        end process;
172
 
173
        process (Reset_s,CLK_n)
174
        begin
175
                if Reset_s = '0' then
176
                        Req_Inhibit <= '0';
177
                elsif CLK_n'event and CLK_n = '1' then
178
                        if MCycle = "001" and TState = "010" and False_M1 = '0' then
179
                                Req_Inhibit <= '1';
180
                        else
181
                                Req_Inhibit <= '0';
182
                        end if;
183
                end if;
184
        end process;
185
 
186
        process (Reset_s,CLK_n)
187
        begin
188
                if Reset_s = '0' then
189
                        MReq_Inhibit <= '0';
190
                elsif CLK_n'event and CLK_n = '0' then
191
                        if MCycle = "001" and TState = "010" then
192
                                MReq_Inhibit <= '1';
193
                        else
194
                                MReq_Inhibit <= '0';
195
                        end if;
196
                end if;
197
        end process;
198
 
199
        process(Reset_s,CLK_n)
200
        begin
201
                if Reset_s = '0' then
202
                        RD <= '0';
203
                        IORQ_n <= '1';
204
                        MREQ <= '0';
205
                elsif CLK_n'event and CLK_n = '0' then
206
 
207
                        if MCycle = "001" and False_M1 = '0' then
208
                                if TState = "001" then
209
                                        RD <= IntCycle_n;
210
                                        MREQ <= IntCycle_n;
211
                                        IORQ_n <= IntCycle_n;
212
                                end if;
213
                                if TState = "011" then
214
                                        RD <= '0';
215
                                        IORQ_n <= '1';
216
                                        MREQ <= '1';
217
                                end if;
218
                                if TState = "100" then
219
                                        MREQ <= '0';
220
                                end if;
221
                        else
222 25 jesus
                                if TState = "001" and NoRead = '0' then
223 7 jesus
                                        RD <= not Write;
224
                                        IORQ_n <= not IORQ;
225
                                        MREQ <= not IORQ;
226
                                end if;
227
                                if TState = "011" then
228
                                        RD <= '0';
229
                                        IORQ_n <= '1';
230
                                        MREQ <= '0';
231
                                end if;
232
                        end if;
233
                end if;
234
        end process;
235
 
236
end;

powered by: WebSVN 2.1.0

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