// ============================================================================
|
// ============================================================================
|
// FETCH_DISP16
|
// FETCH_DISP16
|
// - detch 16 bit displacement
|
// - detch 16 bit displacement
|
//
|
//
|
//
|
//
|
// 2009-2012 Robert Finch
|
// 2009-2013 Robert Finch
|
// robfinch[remove]@opencores.org
|
// robfinch[remove]@finitron.ca
|
// Stratford
|
// Stratford
|
//
|
//
|
//
|
//
|
// This source file is free software: you can redistribute it and/or modify
|
// This source file is free software: you can redistribute it and/or modify
|
// it under the terms of the GNU Lesser General Public License as published
|
// it under the terms of the GNU Lesser General Public License as published
|
// by the Free Software Foundation, either version 3 of the License, or
|
// by the Free Software Foundation, either version 3 of the License, or
|
// (at your option) any later version.
|
// (at your option) any later version.
|
//
|
//
|
// This source file is distributed in the hope that it will be useful,
|
// This source file is distributed in the hope that it will be useful,
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
//
|
//
|
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
//
|
//
|
//
|
//
|
// Verilog
|
// Verilog
|
//
|
//
|
// Fetch 16 bit displacement
|
// Fetch 16 bit displacement
|
// ============================================================================
|
// ============================================================================
|
//
|
//
|
FETCH_DISP16:
|
FETCH_DISP16:
|
begin
|
begin
|
`INITIATE_CODE_READ;
|
code_read();
|
state <= FETCH_DISP16_ACK;
|
state <= FETCH_DISP16_ACK;
|
end
|
end
|
|
|
FETCH_DISP16_ACK:
|
FETCH_DISP16_ACK:
|
if (ack_i) begin
|
if (ack_i) begin
|
state <= FETCH_DISP16a;
|
state <= FETCH_DISP16a;
|
`PAUSE_CODE_READ
|
pause_code_read();
|
disp16[7:0] <= dat_i;
|
disp16[7:0] <= dat_i;
|
end
|
end
|
|
|
FETCH_DISP16a:
|
FETCH_DISP16a:
|
begin
|
begin
|
state <= FETCH_DISP16a_ACK;
|
state <= FETCH_DISP16a_ACK;
|
`INITIATE_CODE_READ
|
code_read();
|
end
|
end
|
|
|
FETCH_DISP16a_ACK:
|
FETCH_DISP16a_ACK:
|
if (ack_i) begin
|
if (ack_i) begin
|
state <= FETCH_DISP16b;
|
state <= FETCH_DISP16b;
|
`TERMINATE_CODE_READ
|
term_code_read();
|
disp16[15:8] <= dat_i;
|
disp16[15:8] <= dat_i;
|
end
|
end
|
|
|
FETCH_DISP16b:
|
FETCH_DISP16b:
|
casex(ir)
|
casex(ir)
|
|
|
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
// Flow control operations
|
// Flow control operations
|
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
`CALL: state <= CALL;
|
`CALL: state <= CALL;
|
`JMP: begin ip <= ip + disp16; state <= IFETCH; end
|
`JMP: begin ip <= ip + disp16; state <= IFETCH; end
|
`JMPS: begin ip <= ip + disp16; state <= IFETCH; end
|
`JMPS: begin ip <= ip + disp16; state <= IFETCH; end
|
|
|
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
// Memory Operations
|
// Memory Operations
|
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
|
|
`MOV_AL2M,`MOV_AX2M:
|
`MOV_AL2M,`MOV_AX2M:
|
begin
|
begin
|
res <= ax;
|
res <= ax;
|
ea <= {seg_reg,`SEG_SHIFT} + disp16;
|
ea <= {seg_reg,`SEG_SHIFT} + disp16;
|
state <= STORE_DATA;
|
state <= STORE_DATA;
|
end
|
end
|
`MOV_M2AL,`MOV_M2AX:
|
`MOV_M2AL,`MOV_M2AX:
|
begin
|
begin
|
d <= 1'b0;
|
d <= 1'b0;
|
rrr <= 3'd0;
|
rrr <= 3'd0;
|
ea <= {seg_reg,`SEG_SHIFT} + disp16;
|
ea <= {seg_reg,`SEG_SHIFT} + disp16;
|
state <= FETCH_DATA;
|
state <= FETCH_DATA;
|
end
|
end
|
|
|
`MOV_MA:
|
`MOV_MA:
|
case(substate)
|
case(substate)
|
FETCH_DATA:
|
FETCH_DATA:
|
if (hasFetchedData) begin
|
if (hasFetchedData) begin
|
ir <= {4'b0,w,3'b0};
|
ir <= {4'b0,w,3'b0};
|
wrregs <= 1'b1;
|
wrregs <= 1'b1;
|
res <= disp16;
|
res <= disp16;
|
state <= IFETCH;
|
state <= IFETCH;
|
end
|
end
|
endcase
|
endcase
|
|
|
`MOV_AM:
|
`MOV_AM:
|
begin
|
begin
|
w <= ir[0];
|
w <= ir[0];
|
state <= STORE_DATA;
|
state <= STORE_DATA;
|
ea <= {ds,`SEG_SHIFT} + disp16;
|
ea <= {ds,`SEG_SHIFT} + disp16;
|
res <= ir[0] ? {ah,al} : {al,al};
|
res <= ir[0] ? {ah,al} : {al,al};
|
end
|
end
|
default: state <= IFETCH;
|
default: state <= IFETCH;
|
endcase
|
endcase
|
|
|