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

Subversion Repositories lattice6502

[/] [lattice6502/] [ispLeaver/] [Processor.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 stanley82
------------------------------------------------------------------
2
--      6502 Top module.
3
--
4
--      Copyright Ian Chapman October 28 2010
5
--
6
--      This file is part of the Lattice 6502 project
7
--      It is used to compile with ispLeaver not Linux ghdl.
8
--      It is the address mapping and connecting the other modules.
9
--      It is replaced by Processor.vhd when running ispLeaver.
10
--
11
--      To do
12
--              This will be work in process or replaced whatever
13
--              project file is needed to control other modules.
14
--
15
--      *************************************************************
16
--      Distributed under the GNU Lesser General Public License.    *
17
--      This can be obtained from “www.gnu.org”.                    *
18
--      *************************************************************
19
--      This program is free software: you can redistribute it and/or modify
20
--      it under the terms of the GNU General Public License as published by
21
--      the Free Software Foundation, either version 3 of the License, or
22
--      (at your option) any later version.
23
--
24
--      This program is distributed in the hope that it will be useful,
25
--      but WITHOUT ANY WARRANTY; without even the implied warranty of
26
--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
--      GNU General Public License for more details.
28
--
29
--      You should have received a copy of the GNU General Public License
30
--      along with this program.  If not, see <http://www.gnu.org/licenses/>
31
--
32
--      Processor.vhd
33
------------------------------------------------------------------
34
library IEEE;                   --Use standard IEEE libs as recommended by Tristan. 
35
use IEEE.STD_LOGIC_1164.ALL;
36
use IEEE.numeric_std.all;
37
 
38
entity Processor is
39
 
40
Port (
41
--      data_wr : inout unsigned(7 downto 0);
42
        clk_pin : in std_logic;
43
--      clk_out : out std_logic;
44
--      u802 : out std_logic;
45
--      u702 : out std_logic;
46
--      u602 : out std_logic;
47
--      u1101 : out std_logic;  
48
--      u801 : out std_logic;
49
--      u701 : out std_logic;
50
        u601 : out std_logic;
51
        rst_pin : in std_logic;
52
        irq_pin : in std_logic;
53
        nmi_pin : in std_logic;
54
        RX_pin  : in std_logic;
55
--      PG_pin  : in std_logic;
56
        TX_pin  : out std_logic;
57
        Pwr_on_pin : out std_logic
58
    );
59
end Processor;
60
 
61
architecture structure of Processor is
62
 
63
--      COMPONENT DECLARATIONS
64
 
65
component P65C02
66
port(
67
        data_rd: in unsigned(7 downto 0);
68
        data_wr: out unsigned(7 downto 0);
69
--      cycle_mark : out std_logic;                     --Used to signal the cycle usually cycle 0.
70
        address: inout unsigned(15 downto 0);
71
        proc_write : inout std_logic;
72
        reset, clock : in std_logic;
73
        irq : in std_logic;
74
        nmi : in std_logic);
75
end component;
76
 
77
component UART_RX is
78
port(
79
        PG, OSC_10MHz,RX,  csr_usart :in std_logic;
80
        RX_rdy : out std_logic;
81
        rx_reg : out unsigned(7 downto 0)
82
        );
83
end component;
84
 
85
component UART_TX is
86
port(
87
        OSC_10MHz, PG, csw_usart :in std_logic;
88
        tx_dat : in unsigned(7 downto 0);
89
        TX ,tx_rdy : out std_logic
90
        );
91
end component;
92
 
93
component Lattice_rom
94
port (
95
        OutClock: in  std_logic;
96
        OutClockEn: in  std_logic;
97
        Reset: in  std_logic;
98
        Address: in  std_logic_vector(9 downto 0);
99
        Q: out  std_logic_vector(7 downto 0));
100
end component;
101
 
102
component Lattice_ram
103
port (
104
        Clock: in  std_logic;
105
        ClockEn: in  std_logic;
106
        Reset: in  std_logic;
107
        WE: in  std_logic;
108
        Address: in  std_logic_vector(9 downto 0);
109
        Data: in  std_logic_vector(7 downto 0);
110
        Q: out  std_logic_vector(7 downto 0));
111
end component;
112
 
113
--component ghdl_rom
114
--port  (
115
--      rom_dat: out unsigned(7 downto 0);
116
--      wr, clk, rst: in std_logic;
117
--      address: in unsigned(15 downto 0)
118
--    );
119
--end component;
120
 
121
--component ghdl_ram
122
--port  (
123
--      ram_dat: out unsigned(7 downto 0);
124
--      data_wr : in unsigned(7 downto 0);
125
--      clk, wr, rst: in std_logic;
126
--      address: in unsigned(15 downto 0)
127
--      );
128
--end component;
129
 
130
 
131
------------------------------------------------------------------------
132
-- Signal Declarations
133
------------------------------------------------------------------------
134
signal address : unsigned(15 downto 0);
135
signal add : unsigned(15 downto 0);
136
signal proc_rd_dat, rom_dat, ram_dat, data_wr : unsigned(7 downto 0);
137
signal rx_dat : unsigned(7 downto 0);
138
signal proc_write : std_logic;
139
signal one, RX_rdy, csw_usart, csr_usart, tx_rdy : std_logic;
140
signal rst_bar : std_logic;
141
 
142
signal clk : std_logic;
143
--signal clk_pin : std_logic;
144
signal counter : unsigned(3 downto 0);
145
signal ram_write : std_logic;
146
 
147
--      I/O ports
148
constant        led_port    : unsigned (15 downto 0) := x"4007";
149
constant        rs232_dat   : unsigned (15 downto 0) := x"4000"; --input and output
150
constant        uart_stat   : unsigned (15 downto 0) := x"4001"; --RX and TX state found here
151
constant        uart: unsigned (15 downto 0) := x"4000"; --starts the uart transmitting
152
 
153
begin
154
 
155
U1 : P65C02 port map(
156
        reset => rst_pin,
157
        Clock => clk_pin,
158
        data_rd => proc_rd_dat,
159
        data_wr => data_wr,
160
        address => address,
161
        proc_write => proc_write,
162
        irq => irq_pin,
163
--      cycle_mark => cycle_mark);
164
        nmi => nmi_pin);
165
 
166
 
167
U2 : UART_RX port map (
168
        PG => rst_pin,
169
        OSC_10MHz => clk_pin,
170
        RX => RX_pin,
171
        rx_reg =>  rx_dat,
172
        csr_usart => csr_usart,
173
        RX_rdy => RX_rdy);
174
 
175
U3 : UART_TX port map (
176
        PG => rst_pin,
177
        TX => TX_pin,
178
        tx_rdy => tx_rdy,
179
        OSC_10MHz => clk_pin,
180
        tx_dat => data_wr,
181
        csw_usart => csw_usart);
182
 
183
--R1 : ghdl_rom port map(
184
--      rom_dat=>rom_dat,
185
--      address=>address,
186
--      wr=>proc_write,
187
--      clk=>clk_pin,
188
--      rst=>rst_pin);
189
 
190
--R2 : ghdl_ram port map(
191
--      clk=>clk_pin,
192
--      rst=>rst_pin,
193
--      ram_dat=>ram_dat,
194
--      data_wr=>data_wr,
195
--      address=>address,
196
--      wr=>ram_write);
197
 
198
R3 : Lattice_rom port map(
199
        Reset => rst_bar,
200
        OutClock => clk_pin,
201
        (address(9 downto 0)) => std_logic_vector(Address(9 downto 0)),
202
        unsigned(Q)  => rom_dat,
203
        OutClockEn => one);
204
 
205
R4 : Lattice_ram port map(
206
        Reset => rst_bar,
207
        Clock => clk_pin,
208
        WE => ram_write,
209
        address(9 downto 0) => std_logic_vector(Address(9 downto 0)),
210
        Data => std_logic_vector(data_wr),
211
        unsigned(Q) => ram_dat, ClockEn => one);
212
 
213
--      address(9 downto 0) => (Address(9 downto 0)), 
214
--      Data => (data_wr),
215
--      (Q) => ram_dat, ClockEn => one);
216
 
217
one <= '1';
218
rst_bar <= not rst_pin;
219
one <= '1';
220
--u601 <= cycle_mark;
221
 
222
 
223
 
224
mux_add : process(rst_pin, clk_pin)
225
begin
226
if rst_pin = '0' then
227
add <= (others => '0');
228
elsif rising_edge(clk_pin) then
229
        add <= address;
230
end if;
231
end process;
232
 
233
ram_address : process (proc_write, address(15 downto 14))
234
begin
235
        if proc_write = '1' and address(15 downto 14) = "00" then
236
                ram_write <= '1';
237
        else
238
                ram_write <= '0';
239
        end if;
240
end process;
241
 
242
 
243
--      ===================================================================
244
--      Updated muxer process
245
muxer : process (add(15 downto 14), rom_dat, ram_dat, rx_dat, tx_rdy, rx_rdy)
246
begin
247
if add(15 downto 14) = "11" then
248
        proc_rd_dat <= rom_dat;
249
end if;
250
if add(15 downto 14) = "00" then
251
        proc_rd_dat <= ram_dat;
252
end if;
253
if add(15 downto 0) = rs232_dat then
254
        proc_rd_dat <= rx_dat;
255
end if;
256
if add(15 downto 0) = uart_stat then
257
        proc_rd_dat <= tx_rdy & rx_rdy & "000000";
258
end if;
259
end process;
260
--      ===================================================================
261
 
262
rs232_cs : process (rst_pin, clk_pin, address, proc_write)
263
begin
264
if proc_write = '0' and address = uart then
265
        csr_usart <= '1';
266
else
267
        csr_usart <= '0';
268
end if;
269
 
270
if proc_write = '1' and address = uart then
271
        csw_usart <= '1';
272
else
273
        csw_usart <= '0';
274
end if;
275
end process;
276
 
277
 
278
 
279
relay : process (rst_pin, proc_write, address, data_wr(7), clk_pin)
280
begin
281
if rst_pin = '0' then
282
        Pwr_on_pin <= '0';
283
        elsif rising_edge(clk_pin) and address = led_port  and proc_write = '1' then
284
        Pwr_on_pin <= data_wr(7);
285
end if;
286
end process;
287
 
288
 
289
end structure;

powered by: WebSVN 2.1.0

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