1 |
30 |
robfinch |
// ============================================================================
|
2 |
|
|
// __
|
3 |
|
|
// \\__/ o\ (C) 2013 Robert Finch, Stratford
|
4 |
|
|
// \ __ / All rights reserved.
|
5 |
|
|
// \/_// robfinch<remove>@opencores.org
|
6 |
|
|
// ||
|
7 |
|
|
//
|
8 |
|
|
// This source file is free software: you can redistribute it and/or modify
|
9 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
10 |
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
11 |
|
|
// (at your option) any later version.
|
12 |
|
|
//
|
13 |
|
|
// This source file is distributed in the hope that it will be useful,
|
14 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
// GNU General Public License for more details.
|
17 |
|
|
//
|
18 |
|
|
// You should have received a copy of the GNU General Public License
|
19 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20 |
|
|
//
|
21 |
|
|
// ============================================================================
|
22 |
|
|
//
|
23 |
|
|
`include "rtf65002_defines.v"
|
24 |
|
|
|
25 |
|
|
// This table being setup to set the pc increment. It should synthesize to a ROM.
|
26 |
|
|
module rtf65002_pcinc(opcode,suppress_pcinc,inc);
|
27 |
32 |
robfinch |
input [8:0] opcode;
|
28 |
30 |
robfinch |
input [3:0] suppress_pcinc;
|
29 |
|
|
output reg [3:0] inc;
|
30 |
|
|
|
31 |
|
|
always @(opcode)
|
32 |
|
|
if (suppress_pcinc==4'hF)
|
33 |
|
|
case(opcode)
|
34 |
|
|
`BRK: inc <= 4'd0;
|
35 |
|
|
`INT0,`INT1: inc <= 4'd0;
|
36 |
|
|
`BPL,`BMI,`BCS,`BCC,`BVS,`BVC,`BEQ,`BNE,`BRA,`BGT,`BLE,`BGE,`BLT,`BHI,`BLS: inc <= 4'd2;
|
37 |
|
|
`BRL: inc <= 4'd3;
|
38 |
|
|
`EXEC,`ATNI: inc <= 4'd2;
|
39 |
|
|
`CLC,`SEC,`CLD,`SED,`CLV,`CLI,`SEI: inc <= 4'd1;
|
40 |
|
|
`TAS,`TSA,`TAY,`TYA,`TAX,`TXA,`TSX,`TXS,`TYX,`TXY: inc <= 4'd1;
|
41 |
|
|
`TRS,`TSR: inc <= 4'd2;
|
42 |
|
|
`INY,`DEY,`INX,`DEX,`INA,`DEA: inc <= 4'd1;
|
43 |
|
|
`EMM: inc <= 4'd1;
|
44 |
|
|
`STP,`WAI: inc <= 4'd1;
|
45 |
|
|
`JMP,`JML,`JMP_IND,`JMP_INDX,`JMP_RIND,
|
46 |
|
|
`JSR,`JSR_RIND,`JSL,`BSR,`JSR_INDX,`RTS,`RTL,`RTI: inc <= 4'd0;
|
47 |
|
|
`JML,`JSL,`JMP_IND,`JMP_INDX,`JSR_INDX: inc <= 4'd5;
|
48 |
|
|
`JMP_RIND,`JSR_RIND: inc <= 4'd2;
|
49 |
|
|
`NOP: inc <= 4'd1;
|
50 |
|
|
`BSR: inc <= 4'd3;
|
51 |
|
|
`RR: inc <= 4'd3;
|
52 |
|
|
`LD_RR: inc <= 4'd2;
|
53 |
|
|
`ADD_IMM8,`SUB_IMM8,`AND_IMM8,`OR_IMM8,`EOR_IMM8,`ASL_IMM8,`LSR_IMM8: inc <= 4'd3;
|
54 |
32 |
robfinch |
`MUL_IMM8,`DIV_IMM8,`MOD_IMM8: inc <= 4'd3;
|
55 |
30 |
robfinch |
`LDX_IMM8,`LDA_IMM8,`CMP_IMM8,`SUB_SP8: inc <= 4'd2;
|
56 |
|
|
`ADD_IMM16,`SUB_IMM16,`AND_IMM16,`OR_IMM16,`EOR_IMM16: inc <= 4'd4;
|
57 |
32 |
robfinch |
`MUL_IMM16,`DIV_IMM16,`MOD_IMM16: inc <= 4'd4;
|
58 |
30 |
robfinch |
`LDX_IMM16,`LDA_IMM16,`SUB_SP16: inc <= 4'd3;
|
59 |
|
|
`ADD_IMM32,`SUB_IMM32,`AND_IMM32,`OR_IMM32,`EOR_IMM32: inc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c <= 4'd3;
|
76 |
30 |
robfinch |
`ORB_ZPX,`ST_ZPX,`STB_ZPX,`ADD_ZPX,`SUB_ZPX,`OR_ZPX,`AND_ZPX,`EOR_ZPX,
|
77 |
|
|
`ADD_IX,`SUB_IX,`OR_IX,`AND_IX,`EOR_IX,`ST_IX,
|
78 |
|
|
`ADD_IY,`SUB_IY,`OR_IY,`AND_IY,`EOR_IY,`ST_IY: inc <= 4'd4;
|
79 |
|
|
`LDX_ABS,`LDY_ABS,`STX_ABS,`STY_ABS,
|
80 |
32 |
robfinch |
`BMS_ABS,`BMC_ABS,`BMF_ABS,`BMT_ABS,
|
81 |
30 |
robfinch |
`ASL_ABS,`ROL_ABS,`LSR_ABS,`ROR_ABS,`INC_ABS,`DEC_ABS,`CPX_ABS,`CPY_ABS: inc <= 4'd5;
|
82 |
|
|
`ORB_ABS,`LDX_ABSY,`LDY_ABSX,`ST_ABS,`STB_ABS,
|
83 |
|
|
`ADD_ABS,`SUB_ABS,`OR_ABS,`AND_ABS,`EOR_ABS,
|
84 |
32 |
robfinch |
`BMS_ABSX,`BMC_ABSX,`BMF_ABSX,`BMT_ABSX,
|
85 |
30 |
robfinch |
`ASL_ABSX,`ROL_ABSX,`LSR_ABSX,`ROR_ABSX,`INC_ABSX,`DEC_ABSX: inc <= 4'd6;
|
86 |
|
|
`ORB_ABSX,`ST_ABSX,`STB_ABSX,
|
87 |
|
|
`ADD_ABSX,`SUB_ABSX,`OR_ABSX,`AND_ABSX,`EOR_ABSX: inc <= 4'd7;
|
88 |
|
|
`PHP,`PHA,`PHX,`PHY,`PLP,`PLA,`PLX,`PLY: inc <= 4'd1;
|
89 |
|
|
`PUSH,`POP: inc <= 4'd2;
|
90 |
32 |
robfinch |
`MVN,`MVP,`STS: inc <= 4'd0;
|
91 |
|
|
`PG2: inc <= 4'd1;
|
92 |
|
|
`TON,`TOFF: inc <= 4'd1;
|
93 |
|
|
`PUSHA,`POPA: inc <= 4'd1;
|
94 |
30 |
robfinch |
default: inc <= 4'd0; // unimplemented instruction
|
95 |
|
|
endcase
|
96 |
|
|
else
|
97 |
|
|
inc <= 4'd0;
|
98 |
|
|
endmodule
|
99 |
32 |
robfinch |
|