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

Subversion Repositories t80

[/] [t80/] [trunk/] [rtl/] [vhdl/] [T80se.vhd] - Blame information for rev 23

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

Line No. Rev Author Line
1 15 jesus
--
2
-- Z80 compatible microprocessor core, synchronous top level with clock enable
3
-- Different timing than the original z80
4
-- Inputs needs to be synchronous and outputs may glitch
5
--
6 23 jesus
-- Version : 0237
7 15 jesus
--
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
--      0235 : First release
50
--
51 18 jesus
--      0236 : Added T2Write generic
52
--
53 23 jesus
--      0237 : Fixed T2Write with wait state
54
--
55 15 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 T80se is
62
        generic(
63 18 jesus
                Mode : integer := 0;     -- 0 => Z80, 1 => Fast Z80, 2 => 8080, 3 => GB
64
                T2Write : integer := 0   -- 0 => WR_n active in T3, /=0 => WR_n active in T2
65 15 jesus
        );
66
        port(
67
                RESET_n         : in std_logic;
68
                CLK_n           : in std_logic;
69
                CLKEN           : in std_logic;
70
                WAIT_n          : in std_logic;
71
                INT_n           : in std_logic;
72
                NMI_n           : in std_logic;
73
                BUSRQ_n         : in std_logic;
74
                M1_n            : out std_logic;
75
                MREQ_n          : out std_logic;
76
                IORQ_n          : out std_logic;
77
                RD_n            : out std_logic;
78
                WR_n            : out std_logic;
79
                RFSH_n          : out std_logic;
80
                HALT_n          : out std_logic;
81
                BUSAK_n         : out std_logic;
82
                A                       : out std_logic_vector(15 downto 0);
83
                DI                      : in std_logic_vector(7 downto 0);
84
                DO                      : out std_logic_vector(7 downto 0)
85
        );
86
end T80se;
87
 
88
architecture rtl of T80se is
89
 
90
        signal False_M1         : std_logic;
91
        signal IntCycle_n       : std_logic;
92
        signal Write            : std_logic;
93
        signal IORQ                     : std_logic;
94
        signal DI_Reg           : std_logic_vector(7 downto 0);
95
        signal MCycle           : std_logic_vector(2 downto 0);
96
        signal TState           : std_logic_vector(2 downto 0);
97
 
98
begin
99
 
100
        u0 : T80
101
                generic map(
102
                        Mode => Mode)
103
                port map(
104
                        CEN => CLKEN,
105
                        M1_n => M1_n,
106
                        IORQ => IORQ,
107
                        Write => Write,
108
                        RFSH_n => RFSH_n,
109
                        HALT_n => HALT_n,
110
                        WAIT_n => Wait_n,
111
                        INT_n => INT_n,
112
                        NMI_n => NMI_n,
113
                        RESET_n => RESET_n,
114
                        BUSRQ_n => BUSRQ_n,
115
                        BUSAK_n => BUSAK_n,
116
                        CLK_n => CLK_n,
117
                        A => A,
118
                        DInst => DI,
119
                        DI => DI_Reg,
120
                        DO => DO,
121
                        MC => MCycle,
122
                        TS => TState,
123
                        False_M1 => False_M1,
124
                        IntCycle_n => IntCycle_n);
125
 
126
        process (RESET_n, CLK_n)
127
        begin
128
                if RESET_n = '0' then
129
                        RD_n <= '1';
130
                        WR_n <= '1';
131
                        IORQ_n <= '1';
132
                        MREQ_n <= '1';
133
                        DI_Reg <= "00000000";
134
                elsif CLK_n'event and CLK_n = '1' then
135
                        if CLKEN = '1' then
136
                                RD_n <= '1';
137
                                WR_n <= '1';
138
                                IORQ_n <= '1';
139
                                MREQ_n <= '1';
140
                                if MCycle = "001" and False_M1 = '0' then
141
                                        if TState = "001" or (TState = "010" and Wait_n = '0') then
142
                                                RD_n <= not IntCycle_n;
143
                                                MREQ_n <= not IntCycle_n;
144
                                                IORQ_n <= IntCycle_n;
145
                                        end if;
146
                                        if TState = "011" then
147
                                                MREQ_n <= '0';
148
                                        end if;
149
                                else
150
                                        if (TState = "001" or (TState = "010" and Wait_n = '0')) and Write = '0' then
151
                                                RD_n <= '0';
152
                                                IORQ_n <= not IORQ;
153
                                                MREQ_n <= IORQ;
154
                                        end if;
155 18 jesus
                                        if T2Write = 0 then
156
                                                if TState = "010" and Write = '1' then
157
                                                        WR_n <= '0';
158
                                                        IORQ_n <= not IORQ;
159
                                                        MREQ_n <= IORQ;
160
                                                end if;
161
                                        else
162 23 jesus
                                                if (TState = "001" or (TState = "010" and READY = '0')) and Write = '1' then
163 18 jesus
                                                        WR_n <= '0';
164
                                                        IORQ_n <= not IORQ;
165
                                                        MREQ_n <= IORQ;
166
                                                end if;
167 15 jesus
                                        end if;
168
                                end if;
169
                                if TState = "010" and Wait_n = '1' then
170
                                        DI_Reg <= DI;
171
                                end if;
172
                        end if;
173
                end if;
174
        end process;
175
 
176
end;

powered by: WebSVN 2.1.0

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