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

Subversion Repositories z80soc

[/] [z80soc/] [trunk/] [V0.7/] [DE1/] [vhdl/] [T80se.vhd] - Blame information for rev 45

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

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

powered by: WebSVN 2.1.0

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