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

Subversion Repositories lattice6502

[/] [lattice6502/] [ghdl/] [ghdl_processor.vhd] - Blame information for rev 7

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 Linux ghdl not ispLeaver.
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 7 stanley82
--      This can be obtained from www.gnu.org.                    *
18 2 stanley82
--      *************************************************************
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
--      ghdl_processor.vhd
33
--
34
------------------------------------------------------------------
35
library IEEE;                   --Use standard IEEE libs as recommended by Tristan.
36
use IEEE.STD_LOGIC_1164.ALL;
37
use IEEE.numeric_std.all;
38
 
39
entity Processor is
40
 
41
Port (
42
--      data_wr : inout unsigned(7 downto 0);
43
        clk_pin : in std_logic;
44
--      clk_out : out std_logic;
45
--      u802 : out std_logic;
46
--      u702 : out std_logic;
47
--      u602 : out std_logic;
48
--      u1101 : out std_logic;  
49
--      u801 : out std_logic;
50
--      u701 : out std_logic;
51
        u601 : out std_logic;
52
        rst_pin : in std_logic;
53 7 stanley82
--      irq_pin : in std_logic;
54
--      nmi_pin : in std_logic;
55 2 stanley82
        RX_pin  : in std_logic;
56
--      PG_pin  : in std_logic;
57
        TX_pin  : out std_logic;
58
        Pwr_on_pin : out std_logic
59
    );
60
end Processor;
61
 
62
architecture structure of Processor is
63
 
64
--      COMPONENT DECLARATIONS
65
 
66
component P65C02
67
port(
68
        data_rd: in unsigned(7 downto 0);
69
        data_wr: out unsigned(7 downto 0);
70
--      cycle_mark : out std_logic;                     --Used to signal the cycle usually cycle 0.
71
        address: inout unsigned(15 downto 0);
72
        proc_write : inout std_logic;
73
        reset, clock : in std_logic;
74
        irq : in std_logic;
75
        nmi : in std_logic);
76
end component;
77
 
78
component UART_RX is
79
port(
80
        PG, OSC_10MHz,RX,  csr_usart :in std_logic;
81
        RX_rdy : out std_logic;
82
        rx_reg : out unsigned(7 downto 0)
83
        );
84
end component;
85
 
86
component UART_TX is
87
port(
88
        OSC_10MHz, PG, csw_usart :in std_logic;
89
        tx_dat : in unsigned(7 downto 0);
90
        TX ,tx_rdy : out std_logic
91
        );
92
end component;
93
 
94
--component Lattice_rom
95
--port (
96
--        OutClock: in  std_logic;
97
--        OutClockEn: in  std_logic;
98
--        Reset: in  std_logic;
99
--        Address: in  std_logic_vector(9 downto 0);
100
--        Q: out  std_logic_vector(7 downto 0));
101
--end component;
102
 
103
--component Lattice_ram
104
--port (
105
--        Clock: in  std_logic;
106
--        ClockEn: in  std_logic;
107
--        Reset: in  std_logic;
108
--        WE: in  std_logic;
109
--        Address: in  std_logic_vector(9 downto 0);
110
--        Data: in  std_logic_vector(7 downto 0);
111
--        Q: out  std_logic_vector(7 downto 0));
112
--end component;
113
 
114
component ghdl_rom
115
port    (
116
        rom_dat: out unsigned(7 downto 0);
117
        wr, clk, rst: in std_logic;
118
        address: in unsigned(15 downto 0)
119
    );
120
end component;
121
 
122
component ghdl_ram
123
port    (
124
        ram_dat: out unsigned(7 downto 0);
125
        data_wr : in unsigned(7 downto 0);
126
        clk, wr, rst: in std_logic;
127
        address: in unsigned(15 downto 0)
128
    );
129
end component;
130
 
131
 
132
------------------------------------------------------------------------
133
-- Signal Declarations
134
------------------------------------------------------------------------
135
signal address : unsigned(15 downto 0);
136
signal add : unsigned(15 downto 0);
137
signal proc_rd_dat, rom_dat, ram_dat, data_wr : unsigned(7 downto 0);
138
signal rx_dat : unsigned(7 downto 0);
139
signal proc_write : std_logic;
140
signal one, RX_rdy, csw_usart, csr_usart, tx_rdy  : std_logic;
141
signal rst_bar : std_logic;
142
signal ram_write : std_logic;
143
signal counter : unsigned(3 downto 0);
144
 
145 7 stanley82
signal nmi_pin, irq_pin : std_logic;
146
 
147 2 stanley82
--      I/O ports
148 7 stanley82
 
149 2 stanley82
constant        led_port    : unsigned (15 downto 0) := x"4007";
150
constant        rs232_dat   : unsigned (15 downto 0) := x"4000"; --input and output
151
constant        uart_stat   : unsigned (15 downto 0) := x"4001"; --RX and TX state found here
152
constant        uart: unsigned (15 downto 0) := x"4000"; --starts the uart transmitting
153
 
154 7 stanley82
constant        Kirq            : unsigned (15 downto 0) := X"4002";     --interrpt testing only
155
constant        Knmi            : unsigned (15 downto 0) := x"4003";
156
 
157 2 stanley82
begin
158
 
159
U1 : P65C02 port map(
160
        reset => rst_pin,
161
        Clock => clk_pin,
162
        data_rd => proc_rd_dat,
163
        data_wr => data_wr,
164
        address => address,
165
        proc_write => proc_write,
166
        irq => irq_pin,
167
        nmi => nmi_pin);
168
--      cycle_mark => cycle_mark);
169
 
170
U2 : UART_RX port map (
171
        PG => rst_pin,
172
        OSC_10MHz => clk_pin,
173
        RX => RX_pin,
174
        rx_reg =>  rx_dat,
175
        csr_usart => csr_usart,
176
        RX_rdy => RX_rdy);
177
 
178
U3 : UART_TX port map (
179
        PG => rst_pin,
180
        TX => TX_pin,
181
        tx_rdy => tx_rdy,
182
        OSC_10MHz => clk_pin,
183
        tx_dat => data_wr,
184
        csw_usart => csw_usart);
185
 
186
R1 : ghdl_rom port map(
187
        rom_dat=>rom_dat,
188
        address=>address,
189
        wr=>proc_write,
190
        clk=>clk_pin,
191
        rst=>rst_pin);
192
 
193
R2 : ghdl_ram port map(
194
        clk=>clk_pin,
195
        rst=>rst_pin,
196
        ram_dat=>ram_dat,
197
        data_wr=>data_wr,
198
        address=>address,
199
        wr=>ram_write);
200
 
201
--R3 : Lattice_rom port map(
202
--      Reset => rst_bar, 
203
--      OutClock => clk_pin,
204
--      (address(9 downto 0)) => std_logic_vector(Address(9 downto 0)),
205
--      unsigned(Q)  => rom_dat, 
206
--      OutClockEn => one);
207
 
208
--R4 : Lattice_ram port map(
209
--      Reset => rst_bar, 
210
--      Clock => clk_pin, 
211
--      WE => ram_write,
212
--      address(9 downto 0) => std_logic_vector(Address(9 downto 0)), 
213
--      Data => std_logic_vector(data_wr),
214 7 stanley82
--      unsigned(Q) => ram_dat
215
--      ClockEn => one);
216 2 stanley82
 
217
one <= '1';
218
rst_bar <= not rst_pin;
219 7 stanley82
 
220
ram_write <= proc_write and not address(15) and not address(14);
221
 
222
--one <= '1';
223 2 stanley82
--u601 <= cycle_mark;
224
 
225
 
226
 
227
mux_add : process(rst_pin, clk_pin)
228
begin
229
if rst_pin = '0' then
230
add <= (others => '0');
231
elsif rising_edge(clk_pin) then
232
        add <= address;
233
end if;
234
end process;
235
 
236 7 stanley82
--ram_address : process (proc_write, address(15 downto 14))
237
--begin
238
--      if proc_write = '1' and address(15 downto 14) = "00" then
239
--              ram_write <= '1';
240
--      else
241
--              ram_write <= '0';
242
--      end if;
243
--end process;
244 2 stanley82
 
245
 
246
 
247
 
248
--      ===================================================================
249
--      Updated muxer process
250
muxer : process (add(15 downto 14), rom_dat, ram_dat, rx_dat, tx_rdy, rx_rdy)
251
begin
252
if add(15 downto 14) = "11" then
253
        proc_rd_dat <= rom_dat;
254
end if;
255
if add(15 downto 14) = "00" then
256
        proc_rd_dat <= ram_dat;
257
end if;
258
if add(15 downto 0) = rs232_dat then
259
        proc_rd_dat <= rx_dat;
260
end if;
261
if add(15 downto 0) = uart_stat then
262
        proc_rd_dat <= tx_rdy & rx_rdy & "000000";
263
end if;
264
end process;
265
--      ===================================================================
266
 
267
rs232_cs : process (rst_pin, clk_pin, address, proc_write)
268
begin
269
if proc_write = '0' and address = uart then
270
        csr_usart <= '1';
271
else
272
        csr_usart <= '0';
273
end if;
274
 
275
if proc_write = '1' and address = uart then
276
        csw_usart <= '1';
277
else
278
        csw_usart <= '0';
279
end if;
280
end process;
281
 
282
 
283
 
284 7 stanley82
--relay : process (rst_pin, proc_write, address, data_wr(7), clk_pin)
285
--begin
286
--if rst_pin = '0' then
287
--      Pwr_on_pin <= '0';
288
--      elsif rising_edge(clk_pin) and address = led_port  and proc_write = '1' then
289
--      Pwr_on_pin <= data_wr(7);
290
--end if;
291
--end process;
292 2 stanley82
 
293 7 stanley82
--irq : process (rst_pin, proc_write, address, data_wr(0), clk_pin)
294
--begin
295
--if rst_pin = '0' then
296
--      irq_pin <= '1';
297
--      elsif rising_edge(clk_pin) then
298
--              if address = Kirq and proc_write = '1' then
299
--                      irq_pin <= data_wr(0);  --set and hold bit 0
300
--              end if;
301
--end if;
302
--end process;
303 2 stanley82
 
304 7 stanley82
--nmi : process (rst_pin, proc_write, address, data_wr(0), clk_pin)
305
--begin
306
--if rst_pin = '0' then
307
--      nmi_pin <= '1';
308
--      elsif rising_edge(clk_pin) then
309
--
310
--              if address = Knmi and proc_write = '1' then
311
--                      nmi_pin <= data_wr(0);  --set and hold bit 0
312
--              end if;
313
--end if;
314
--end process;
315
 
316 2 stanley82
end structure;

powered by: WebSVN 2.1.0

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