1 |
24 |
fpga_is_fu |
LIBRARY ieee;
|
2 |
|
|
USE ieee.std_logic_1164.all;
|
3 |
|
|
USE ieee.std_logic_arith.all;
|
4 |
|
|
|
5 |
|
|
entity r65c02_tc is
|
6 |
|
|
port(
|
7 |
|
|
clk_clk_i : in std_logic;
|
8 |
|
|
d_i : in std_logic_vector (7 downto 0);
|
9 |
|
|
irq_n_i : in std_logic;
|
10 |
|
|
nmi_n_i : in std_logic;
|
11 |
|
|
rdy_i : in std_logic;
|
12 |
|
|
rst_rst_n_i : in std_logic;
|
13 |
|
|
so_n_i : in std_logic;
|
14 |
|
|
a_o : out std_logic_vector (15 downto 0);
|
15 |
|
|
d_o : out std_logic_vector (7 downto 0);
|
16 |
|
|
rd_o : out std_logic;
|
17 |
|
|
sync_o : out std_logic;
|
18 |
|
|
wr_n_o : out std_logic;
|
19 |
|
|
wr_o : out std_logic
|
20 |
|
|
);
|
21 |
|
|
|
22 |
|
|
-- Declarations
|
23 |
|
|
|
24 |
|
|
end r65c02_tc ;
|
25 |
|
|
-- (C) 2008 - 2021 Jens Gutschmidt
|
26 |
|
|
-- (email: opencores@vivare-services.com)
|
27 |
|
|
--
|
28 |
|
|
-- Versions:
|
29 |
|
|
-- Revision 1.53 2021/01/08 22:20:00 jens
|
30 |
|
|
-- - Bug Fix rdy_i='0' causes hang after res_res_n_i='0' -> '1'
|
31 |
|
|
-- at state RES1/s545 and malfunction of:
|
32 |
|
|
-- STA ABS,Y state s208 -> no write of data
|
33 |
|
|
-- STA (IND,X) state s209 -> no write of data
|
34 |
|
|
-- Revision 1.52 2018/09/10 12:14:00 jens
|
35 |
|
|
-- - RESET generates SYNC now, 1 dead cycle delayed
|
36 |
|
|
-- Revision 1.52 RC 2018/09/09 03:00:00 jens
|
37 |
|
|
-- - ADC / SBC flags and A like R65C02 now
|
38 |
|
|
-- Revision 1.52 BETA 2018/09/05 19:35:00 jens
|
39 |
|
|
-- - BBRx/BBSx internal cycles like real 65C02 now
|
40 |
|
|
-- - Bug Fix ADC and SBC in decimal mode (all op codes -
|
41 |
|
|
-- 1 cycle is missing
|
42 |
|
|
-- - Bug Fix ADC and SBC in decimal mode (all op codes -
|
43 |
|
|
-- "Overflow" flag was computed wrong)
|
44 |
|
|
-- Revision 1.52 BETA 2018/09/02 18:49:00 jens
|
45 |
|
|
-- - Interrupt NMI and IRQ processing via FETCH stage now
|
46 |
|
|
-- Revision 1.52 BETA 2018/08/30 15:39:00 jens
|
47 |
|
|
-- - Interrupt priority order is now: BRQ - NMI - IRQ
|
48 |
|
|
-- - Performance improvements on-going (Mealy -> Moore)
|
49 |
|
|
-- Revision 1.52 BETA 2018/08/23 20:27:00 jens
|
50 |
|
|
-- - Bug Fixes All Branch Instructions
|
51 |
|
|
-- (BCC, BCS, BEQ, BNE, BPL, BMI, BVC, BVS, BRA)
|
52 |
|
|
-- 3 cycles now if branch forward occur and the branch
|
53 |
|
|
-- instruction lies on a xxFEh location.
|
54 |
|
|
-- (BBR, BBS) 6 cycles now if branch forward occur and the
|
55 |
|
|
-- branch instruction lies on a xxFDh location.
|
56 |
|
|
-- - Bug Fix Hardware Interrupts NMI & IRQ - 7 cycles & "SYNC" now
|
57 |
|
|
-- - Bug Fix Now all cycles are delayable (WR and internal)
|
58 |
|
|
--
|
59 |
|
|
-- Revision 1.51 RC 2014/04/19 14:44:00 jens
|
60 |
|
|
-- (never submitted to opencores)
|
61 |
|
|
-- - Bug Fix JMP ABS - produced a 6502 like JMP (IND) PCH.
|
62 |
|
|
-- When the ABS address data bytes cross the page
|
63 |
|
|
-- boundary (e.g. $02FE JMP hhll reads hh from
|
64 |
|
|
-- $02FF and ll from $0200, instead $02FF and $0300)
|
65 |
|
|
--
|
66 |
|
|
-- Revision 1.5 RC 2013/08/01 11:00:00 jens
|
67 |
|
|
-- - Change Block name to lower case
|
68 |
|
|
-- - Bug Fix CMP (IND) - wrongly decoded as function AND
|
69 |
|
|
-- - Bug Fix BRK should clear decimal flag in P Reg
|
70 |
|
|
-- - Bug Fix JMP (ABS,X) - Low Address outputted twice - no
|
71 |
|
|
-- High Address
|
72 |
|
|
-- - Bug Fix Unknown Ops - Used always 1b2c NOP ($EA) -
|
73 |
|
|
-- new NOPs created
|
74 |
|
|
-- - Bug Fix DECIMAL ADC and SBC (all op codes - "C" flag
|
75 |
|
|
-- was computed wrong)
|
76 |
|
|
-- - Bug Fix INC/DEC ABS,X - N/Z flag wrongly computed
|
77 |
|
|
-- - Bug Fix RTI - should increment stack pointer
|
78 |
|
|
-- - Bug Fix "E" & "B" flags (Bits 5 & 4) - should be always "1"
|
79 |
|
|
-- in P Reg. Change "RES", "RTI", "IRQ" & "NMI" substates.
|
80 |
|
|
-- - Bug Fix ADC and SBC (all sub codes - "Overflow" flag was computed wrong)
|
81 |
|
|
-- - Bug Fix RMB, SMB Bug - Bit position decoded wrong
|
82 |
|
|
--
|
83 |
|
|
-- Revision 1.4 2013/07/21 11:11:00 jens
|
84 |
|
|
-- - Changing the title block and internal revision history
|
85 |
|
|
-- - Bug Fix STA [(IND)] op$92 ($92 was missed in the con-
|
86 |
|
|
-- nection list at state FETCH)
|
87 |
|
|
--
|
88 |
|
|
-- Revision 1.3 2009/01/04 10:20:50 eda
|
89 |
|
|
-- Changes for cosmetic issues only
|
90 |
|
|
--
|
91 |
|
|
-- Revision 1.2 2009/01/04 09:23:12 eda
|
92 |
|
|
-- - Delete unused nets and blocks (same as R6502_TC)
|
93 |
|
|
-- - Rename blocks
|
94 |
|
|
-- - Re-arrage FSM symbols in block FSM_Execution_Unit
|
95 |
|
|
--
|
96 |
|
|
-- Revision 1.1 2009/01/03 16:36:48 eda
|
97 |
|
|
-- -- no description --
|
98 |
|
|
--
|
99 |
|
|
--
|
100 |
|
|
--
|
101 |
|
|
-- r65c02_tc.r65c02_tc.struct
|
102 |
|
|
--
|
103 |
|
|
-- Date: 09.01.2021
|
104 |
|
|
-- Time: 02:11:37
|
105 |
|
|
-- By: VIVARE GmbH, Switzerland
|
106 |
|
|
--
|
107 |
|
|
-- COPYRIGHT (C) 2008 - 2021 by Jens Gutschmidt
|
108 |
|
|
--
|
109 |
|
|
-- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
|
110 |
|
|
--
|
111 |
|
|
-- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
112 |
|
|
--
|
113 |
|
|
-- You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
114 |
|
|
--
|
115 |
|
|
--
|
116 |
|
|
LIBRARY ieee;
|
117 |
|
|
USE ieee.std_logic_1164.all;
|
118 |
|
|
USE ieee.std_logic_arith.all;
|
119 |
|
|
|
120 |
|
|
library r65c02_tc;
|
121 |
|
|
|
122 |
|
|
architecture struct of r65c02_tc is
|
123 |
|
|
|
124 |
|
|
-- Architecture declarations
|
125 |
|
|
|
126 |
|
|
-- Internal signal declarations
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
-- Component Declarations
|
130 |
|
|
component core
|
131 |
|
|
port (
|
132 |
|
|
clk_clk_i : in std_logic ;
|
133 |
|
|
d_i : in std_logic_vector (7 downto 0);
|
134 |
|
|
irq_n_i : in std_logic ;
|
135 |
|
|
nmi_n_i : in std_logic ;
|
136 |
|
|
rdy_i : in std_logic ;
|
137 |
|
|
rst_rst_n_i : in std_logic ;
|
138 |
|
|
so_n_i : in std_logic ;
|
139 |
|
|
a_o : out std_logic_vector (15 downto 0);
|
140 |
|
|
d_o : out std_logic_vector (7 downto 0);
|
141 |
|
|
rd_o : out std_logic ;
|
142 |
|
|
sync_o : out std_logic ;
|
143 |
|
|
wr_n_o : out std_logic ;
|
144 |
|
|
wr_o : out std_logic
|
145 |
|
|
);
|
146 |
|
|
end component;
|
147 |
|
|
|
148 |
|
|
-- Optional embedded configurations
|
149 |
|
|
-- pragma synthesis_off
|
150 |
|
|
for all : core use entity r65c02_tc.core;
|
151 |
|
|
-- pragma synthesis_on
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
begin
|
155 |
|
|
|
156 |
|
|
-- Instance port mappings.
|
157 |
|
|
U_0 : core
|
158 |
|
|
port map (
|
159 |
|
|
clk_clk_i => clk_clk_i,
|
160 |
|
|
d_i => d_i,
|
161 |
|
|
irq_n_i => irq_n_i,
|
162 |
|
|
nmi_n_i => nmi_n_i,
|
163 |
|
|
rdy_i => rdy_i,
|
164 |
|
|
rst_rst_n_i => rst_rst_n_i,
|
165 |
|
|
so_n_i => so_n_i,
|
166 |
|
|
a_o => a_o,
|
167 |
|
|
d_o => d_o,
|
168 |
|
|
rd_o => rd_o,
|
169 |
|
|
sync_o => sync_o,
|
170 |
|
|
wr_n_o => wr_n_o,
|
171 |
|
|
wr_o => wr_o
|
172 |
|
|
);
|
173 |
|
|
|
174 |
|
|
end struct;
|