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

Subversion Repositories t80

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

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

powered by: WebSVN 2.1.0

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