Line 50... |
Line 50... |
// a dedicated bus interface unit (BIU).
|
// a dedicated bus interface unit (BIU).
|
// It is able to execute up to 40Mips on Spartan XC3S700AN speed grade -4, performances comparable with a 486 CPU.
|
// It is able to execute up to 40Mips on Spartan XC3S700AN speed grade -4, performances comparable with a 486 CPU.
|
// Small size, the CPU + BIU requires ~25% or 1500 slices - on Spartan XC3S700AN
|
// Small size, the CPU + BIU requires ~25% or 1500 slices - on Spartan XC3S700AN
|
//
|
//
|
// 16May2012 - fixed REP CMPS/SCAS bug when interrupted on the <equal> item
|
// 16May2012 - fixed REP CMPS/SCAS bug when interrupted on the <equal> item
|
|
// 23Dec2012 - fixed DIV bug (exception on sign bit)
|
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
|
|
module Next186_CPU(
|
module Next186_CPU(
|
output [19:0] ADDR,
|
output [19:0] ADDR,
|
Line 914... |
Line 915... |
ALUOP = {2'b00, DIVSGN ? 3'b000 : 3'b101}; // add/sub
|
ALUOP = {2'b00, DIVSGN ? 3'b000 : 3'b101}; // add/sub
|
ISEL = 2'b01;
|
ISEL = 2'b01;
|
DIVSTAGE = ~DIVEND;
|
DIVSTAGE = ~DIVEND;
|
ALUSTAGE = ~DIVEND | ~DIVQSGN;
|
ALUSTAGE = ~DIVEND | ~DIVQSGN;
|
DIVOP = 1'b1;
|
DIVOP = 1'b1;
|
IRQ = ~|STAGE[6:3] & DIVC & ~(STAGE[2] & DIVSGN); // early overflow for positive quotient
|
// IRQ = ~|STAGE[6:3] & DIVC & ~(STAGE[2] & DIVSGN); - DIV bug, fixed 23Dec2012
|
|
IRQ = ~|STAGE[6:3] & DIVC & (~STAGE[2] | (~DIVSGN & IDIV)); // early overflow for positive quotient
|
IFETCH = (DIVEND && ~DIVQSGN && ~DIVRSGN) || IRQ;
|
IFETCH = (DIVEND && ~DIVQSGN && ~DIVRSGN) || IRQ;
|
end
|
end
|
3'b100: begin // stage5, post inc R
|
3'b100: begin // stage5, post inc R
|
RASEL = WORD ? 3'b010 : 3'b100; // DX/AH
|
RASEL = WORD ? 3'b010 : 3'b100; // DX/AH
|
WE[1:0] = {1'b1, WORD}; // RASEL_HI, RASEL_LO
|
WE[1:0] = {1'b1, WORD}; // RASEL_HI, RASEL_LO
|