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

Subversion Repositories z80soc

[/] [z80soc/] [branches/] [RonivonCosta/] [S3E/] [T80s.vhd] - Blame information for rev 31

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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