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

Subversion Repositories lattice6502

[/] [lattice6502/] [ghdl/] [ghdl_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 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
--      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
--      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
        irq_pin : in std_logic;
54
        nmi_pin : in std_logic;
55
        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 cycle_mark : std_logic
142
signal rst_bar : std_logic;
143
signal ram_write : std_logic;
144
 
145
--signal clk : std_logic;
146
--signal clk_pin : std_logic;
147
signal counter : unsigned(3 downto 0);
148
 
149
--      I/O ports
150
constant        led_port    : unsigned (15 downto 0) := x"4007";
151
constant        rs232_dat   : unsigned (15 downto 0) := x"4000"; --input and output
152
constant        uart_stat   : unsigned (15 downto 0) := x"4001"; --RX and TX state found here
153
constant        uart: unsigned (15 downto 0) := x"4000"; --starts the uart transmitting
154
 
155
begin
156
 
157
U1 : P65C02 port map(
158
        reset => rst_pin,
159
        Clock => clk_pin,
160
        data_rd => proc_rd_dat,
161
        data_wr => data_wr,
162
        address => address,
163
        proc_write => proc_write,
164
        irq => irq_pin,
165
        nmi => nmi_pin);
166
--      cycle_mark => cycle_mark);
167
 
168
U2 : UART_RX port map (
169
        PG => rst_pin,
170
        OSC_10MHz => clk_pin,
171
        RX => RX_pin,
172
        rx_reg =>  rx_dat,
173
        csr_usart => csr_usart,
174
        RX_rdy => RX_rdy);
175
 
176
U3 : UART_TX port map (
177
        PG => rst_pin,
178
        TX => TX_pin,
179
        tx_rdy => tx_rdy,
180
        OSC_10MHz => clk_pin,
181
        tx_dat => data_wr,
182
        csw_usart => csw_usart);
183
 
184
R1 : ghdl_rom port map(
185
        rom_dat=>rom_dat,
186
        address=>address,
187
        wr=>proc_write,
188
        clk=>clk_pin,
189
        rst=>rst_pin);
190
 
191
R2 : ghdl_ram port map(
192
        clk=>clk_pin,
193
        rst=>rst_pin,
194
        ram_dat=>ram_dat,
195
        data_wr=>data_wr,
196
        address=>address,
197
        wr=>ram_write);
198
 
199
--R3 : Lattice_rom port map(
200
--      Reset => rst_bar, 
201
--      OutClock => clk_pin,
202
--      (address(9 downto 0)) => std_logic_vector(Address(9 downto 0)),
203
--      unsigned(Q)  => rom_dat, 
204
--      OutClockEn => one);
205
 
206
--R4 : Lattice_ram port map(
207
--      Reset => rst_bar, 
208
--      Clock => clk_pin, 
209
--      WE => ram_write,
210
--      address(9 downto 0) => std_logic_vector(Address(9 downto 0)), 
211
--      Data => std_logic_vector(data_wr),
212
--      unsigned(Q) => ram_dat, ClockEn => one);
213
 
214
one <= '1';
215
rst_bar <= not rst_pin;
216
one <= '1';
217
--u601 <= cycle_mark;
218
 
219
 
220
 
221
mux_add : process(rst_pin, clk_pin)
222
begin
223
if rst_pin = '0' then
224
add <= (others => '0');
225
elsif rising_edge(clk_pin) then
226
        add <= address;
227
end if;
228
end process;
229
 
230
ram_address : process (proc_write, address(15 downto 14))
231
begin
232
        if proc_write = '1' and address(15 downto 14) = "00" then
233
                ram_write <= '1';
234
        else
235
                ram_write <= '0';
236
        end if;
237
end process;
238
 
239
 
240
 
241
 
242
--      ===================================================================
243
--      Updated muxer process
244
muxer : process (add(15 downto 14), rom_dat, ram_dat, rx_dat, tx_rdy, rx_rdy)
245
begin
246
if add(15 downto 14) = "11" then
247
        proc_rd_dat <= rom_dat;
248
end if;
249
if add(15 downto 14) = "00" then
250
        proc_rd_dat <= ram_dat;
251
end if;
252
if add(15 downto 0) = rs232_dat then
253
        proc_rd_dat <= rx_dat;
254
end if;
255
if add(15 downto 0) = uart_stat then
256
        proc_rd_dat <= tx_rdy & rx_rdy & "000000";
257
end if;
258
end process;
259
--      ===================================================================
260
 
261
rs232_cs : process (rst_pin, clk_pin, address, proc_write)
262
begin
263
if proc_write = '0' and address = uart then
264
        csr_usart <= '1';
265
else
266
        csr_usart <= '0';
267
end if;
268
 
269
if proc_write = '1' and address = uart then
270
        csw_usart <= '1';
271
else
272
        csw_usart <= '0';
273
end if;
274
end process;
275
 
276
 
277
 
278
relay : process (rst_pin, proc_write, address, data_wr(7), clk_pin)
279
begin
280
if rst_pin = '0' then
281
        Pwr_on_pin <= '0';
282
        elsif rising_edge(clk_pin) and address = led_port  and proc_write = '1' then
283
        Pwr_on_pin <= data_wr(7);
284
end if;
285
end process;
286
 
287
 
288
end structure;

powered by: WebSVN 2.1.0

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