Line 20... |
Line 20... |
//
|
//
|
// ============================================================================
|
// ============================================================================
|
//
|
//
|
IFETCH:
|
IFETCH:
|
begin
|
begin
|
|
ic_whence <= IFETCH;
|
vect <= {vbr[31:9],`BRK_VECTNO,2'b00};
|
vect <= {vbr[31:9],`BRK_VECTNO,2'b00};
|
suppress_pcinc <= 4'hF; // default: no suppression of increment
|
suppress_pcinc <= 4'hF; // default: no suppression of increment
|
opc <= pc;
|
opc <= pc;
|
hwi <= `FALSE;
|
hwi <= `FALSE;
|
isBusErr <= `FALSE;
|
isBusErr <= `FALSE;
|
pg2 <= `FALSE;
|
pg2 <= `FALSE;
|
|
isIY <= `FALSE;
|
|
isIY24 <= `FALSE;
|
store_what <= `STW_DEF;
|
store_what <= `STW_DEF;
|
if (nmi_edge & gie & !isExec & !isAtni) begin
|
if (nmi_edge & gie & !isExec & !isAtni) begin
|
ir[7:0] <= `BRK;
|
ir[7:0] <= `BRK;
|
nmi_edge <= 1'b0;
|
nmi_edge <= 1'b0;
|
wai <= 1'b0;
|
wai <= 1'b0;
|
hwi <= `TRUE;
|
hwi <= `TRUE;
|
next_state(DECODE);
|
next_state(DECODE);
|
vect <= `NMI_VECT;
|
vect <= `NMI_VECT;
|
end
|
end
|
else if (irq_i & gie & !isExec & !isAtni) begin
|
else if ((irq_i|spi) & gie & !isExec & !isAtni) begin
|
wai <= 1'b0;
|
wai <= 1'b0;
|
if (im) begin
|
if (im) begin
|
if (ttrig) begin
|
if (ttrig) begin
|
ir[7:0] <= `BRK;
|
ir[7:0] <= `BRK;
|
vect <= {vbr[31:9],9'd490,2'b00};
|
vect <= {vbr[31:9],9'd490,2'b00};
|
Line 68... |
Line 71... |
exbuf <= 64'd0;
|
exbuf <= 64'd0;
|
next_state(DECODE);
|
next_state(DECODE);
|
end
|
end
|
else begin
|
else begin
|
pg2 <= pg2;
|
pg2 <= pg2;
|
state <= ICACHE1;
|
next_state(ICACHE1);
|
end
|
end
|
end
|
end
|
end
|
end
|
else begin
|
else begin
|
ir[7:0] <= `BRK;
|
ir[7:0] <= `BRK;
|
hwi <= `TRUE;
|
hwi <= `TRUE;
|
|
if (spi) begin
|
|
spi <= 1'b0;
|
|
spi_cnt <= SPIN_CYCLES;
|
|
vect <= {vbr[31:9],9'd3,2'b00};
|
|
end
|
|
else begin
|
vect <= {vbr[31:9],irq_vect,2'b00};
|
vect <= {vbr[31:9],irq_vect,2'b00};
|
|
end
|
next_state(DECODE);
|
next_state(DECODE);
|
end
|
end
|
end
|
end
|
else if (!wai) begin
|
else if (!wai) begin
|
if (ttrig) begin
|
if (ttrig) begin
|
Line 142... |
Line 152... |
`endif
|
`endif
|
end
|
end
|
4'h5: lfsr <= res[31:0];
|
4'h5: lfsr <= res[31:0];
|
4'h7: abs8 <= res[31:0];
|
4'h7: abs8 <= res[31:0];
|
4'h8: begin vbr <= {res[31:9],9'h000}; nmoi <= res[0]; end
|
4'h8: begin vbr <= {res[31:9],9'h000}; nmoi <= res[0]; end
|
4'hE: begin sp <= res[7:0]; spage[31:8] <= res[31:8]; end
|
4'hE: begin sp <= res[15:0]; spage[31:16] <= res[31:16]; end
|
4'hF: begin isp <= res[31:0]; gie <= 1'b1; end
|
4'hF: begin isp <= res[31:0]; gie <= 1'b1; end
|
endcase
|
endcase
|
end
|
end
|
`RR:
|
`RR:
|
case(ir[23:20])
|
case(ir[23:20])
|
Line 164... |
Line 174... |
default:
|
default:
|
begin nf <= resn32; zf <= resz32; end
|
begin nf <= resn32; zf <= resz32; end
|
endcase
|
endcase
|
`LD_RR: begin zf <= resz32; nf <= resn32; end
|
`LD_RR: begin zf <= resz32; nf <= resn32; end
|
`DEC_RR,`INC_RR: begin zf <= resz32; nf <= resn32; end
|
`DEC_RR,`INC_RR: begin zf <= resz32; nf <= resn32; end
|
|
`ADD_IMM4,`ADD_R,
|
`ADD_IMM8,`ADD_IMM16,`ADD_IMM32,`ADD_ZPX,`ADD_IX,`ADD_IY,`ADD_ABS,`ADD_ABSX,`ADD_RIND:
|
`ADD_IMM8,`ADD_IMM16,`ADD_IMM32,`ADD_ZPX,`ADD_IX,`ADD_IY,`ADD_ABS,`ADD_ABSX,`ADD_RIND:
|
begin vf <= resv32; cf <= resc32; nf <= resn32; zf <= resz32; end
|
begin vf <= resv32; cf <= resc32; nf <= resn32; zf <= resz32; end
|
|
`SUB_IMM4,`SUB_R,
|
`SUB_IMM8,`SUB_IMM16,`SUB_IMM32,`SUB_ZPX,`SUB_IX,`SUB_IY,`SUB_ABS,`SUB_ABSX,`SUB_RIND:
|
`SUB_IMM8,`SUB_IMM16,`SUB_IMM32,`SUB_ZPX,`SUB_IX,`SUB_IY,`SUB_ABS,`SUB_ABSX,`SUB_RIND:
|
if (Rt==4'h0) // CMP doesn't set overflow
|
if (Rt==4'h0) // CMP doesn't set overflow
|
begin cf <= ~resc32; nf <= resn32; zf <= resz32; end
|
begin cf <= ~resc32; nf <= resn32; zf <= resz32; end
|
else
|
else
|
begin vf <= resv32; cf <= ~resc32; nf <= resn32; zf <= resz32; end
|
begin vf <= resv32; cf <= ~resc32; nf <= resn32; zf <= resz32; end
|
Line 177... |
Line 189... |
`DIV_IMM8,`DIV_IMM16,`DIV_IMM32,
|
`DIV_IMM8,`DIV_IMM16,`DIV_IMM32,
|
`MOD_IMM8,`MOD_IMM16,`MOD_IMM32,
|
`MOD_IMM8,`MOD_IMM16,`MOD_IMM32,
|
`endif
|
`endif
|
`MUL_IMM8,`MUL_IMM16,`MUL_IMM32:
|
`MUL_IMM8,`MUL_IMM16,`MUL_IMM32:
|
begin nf <= resn32; zf <= resz32; end
|
begin nf <= resn32; zf <= resz32; end
|
|
`AND_IMM4,`AND_R,
|
`AND_IMM8,`AND_IMM16,`AND_IMM32,`AND_ZPX,`AND_IX,`AND_IY,`AND_ABS,`AND_ABSX,`AND_RIND:
|
`AND_IMM8,`AND_IMM16,`AND_IMM32,`AND_ZPX,`AND_IX,`AND_IY,`AND_ABS,`AND_ABSX,`AND_RIND:
|
if (Rt==4'h0) // BIT sets overflow
|
if (Rt==4'h0) // BIT sets overflow
|
begin nf <= b[31]; vf <= b[30]; zf <= resz32; end
|
begin nf <= b[31]; vf <= b[30]; zf <= resz32; end
|
else
|
else
|
begin nf <= resn32; zf <= resz32; end
|
begin nf <= resn32; zf <= resz32; end
|
`ORB_ZPX,`ORB_ABS,`ORB_ABSX,
|
`ORB_ZPX,`ORB_ABS,`ORB_ABSX,
|
|
`OR_IMM4,`OR_R,
|
`OR_IMM8,`OR_IMM16,`OR_IMM32,`OR_ZPX,`OR_IX,`OR_IY,`OR_ABS,`OR_ABSX,`OR_RIND,
|
`OR_IMM8,`OR_IMM16,`OR_IMM32,`OR_ZPX,`OR_IX,`OR_IY,`OR_ABS,`OR_ABSX,`OR_RIND,
|
|
`EOR_IMM4,`EOR_R,
|
`EOR_IMM8,`EOR_IMM16,`EOR_IMM32,`EOR_ZPX,`EOR_IX,`EOR_IY,`EOR_ABS,`EOR_ABSX,`EOR_RIND:
|
`EOR_IMM8,`EOR_IMM16,`EOR_IMM32,`EOR_ZPX,`EOR_IX,`EOR_IY,`EOR_ABS,`EOR_ABSX,`EOR_RIND:
|
begin nf <= resn32; zf <= resz32; end
|
begin nf <= resn32; zf <= resz32; end
|
`ASL_ACC,`ROL_ACC,`LSR_ACC,`ROR_ACC:
|
`ASL_ACC,`ROL_ACC,`LSR_ACC,`ROR_ACC:
|
begin cf <= resc32; nf <= resn32; zf <= resz32; end
|
begin cf <= resc32; nf <= resn32; zf <= resz32; end
|
`ASL_RR,`ROL_RR,`LSR_RR,`ROR_RR,
|
`ASL_RR,`ROL_RR,`LSR_RR,`ROR_RR,
|
Line 215... |
Line 230... |
`POP: begin nf <= resn32; zf <= resz32; end
|
`POP: begin nf <= resn32; zf <= resz32; end
|
`TRB_ZPX,`TRB_ABS,`TSB_ZPX,`TSB_ABS:
|
`TRB_ZPX,`TRB_ABS,`TSB_ZPX,`TSB_ABS:
|
begin zf <= resz32; end
|
begin zf <= resz32; end
|
`BMT_ZPX,`BMT_ABS,`BMT_ABSX:
|
`BMT_ZPX,`BMT_ABS,`BMT_ABSX:
|
begin zf <= resz32; nf <= resn32; end
|
begin zf <= resz32; nf <= resn32; end
|
|
// `SPL: begin if (radr==65002) acc <= 32'h52544600; end
|
endcase
|
endcase
|
end
|
end
|
|
|
No newline at end of file
|
No newline at end of file
|