made BIU snoop into the processor to deliver new instructions faster and fixed some bugs
This commit is contained in:
parent
c854818d6d
commit
7e612bb701
42
system/biu.v
42
system/biu.v
@ -41,7 +41,8 @@ module BIU (
|
|||||||
/*outside world*/ input clock, input reset, output reg [19:0] external_address_bus,
|
/*outside world*/ input clock, input reset, output reg [19:0] external_address_bus,
|
||||||
/* */ inout [15:0] external_data_bus,output reg read, output reg write,output reg BHE,output reg IOMEM,
|
/* */ inout [15:0] external_data_bus,output reg read, output reg write,output reg BHE,output reg IOMEM,
|
||||||
/* internal */ output reg [31:0] INSTRUCTION, output reg VALID_INSTRUCTION, output reg [15:0] INSTRUCTION_LOCATION, input [1:0] NEXT_POSITION,
|
/* internal */ output reg [31:0] INSTRUCTION, output reg VALID_INSTRUCTION, output reg [15:0] INSTRUCTION_LOCATION, input [1:0] NEXT_POSITION,
|
||||||
/* */ input[15:0] ADDRESS_INPUT, inout [15:0] DATA, input write_request, input read_request, input Wbit, output reg VALID_DATA, input MEM_OR_IO
|
/* */ input[15:0] ADDRESS_INPUT, inout [15:0] DATA, input write_request, input read_request, input Wbit, output reg VALID_DATA, input MEM_OR_IO,
|
||||||
|
/* */ input [`PROC_STATE_BITS-1:0] proc_state, input SIMPLE_MICRO
|
||||||
);
|
);
|
||||||
|
|
||||||
reg [15:0] data_bus_output_register;
|
reg [15:0] data_bus_output_register;
|
||||||
@ -276,6 +277,7 @@ always @(posedge clock) begin
|
|||||||
VALID_INSTRUCTION <= 0;
|
VALID_INSTRUCTION <= 0;
|
||||||
VALID_DATA <= 0;
|
VALID_DATA <= 0;
|
||||||
DATA_DIR <= 0;
|
DATA_DIR <= 0;
|
||||||
|
was_dec <= 0;
|
||||||
end
|
end
|
||||||
default: begin
|
default: begin
|
||||||
biu_state <= `BIU_NEXT_ACTION;/*Should be unreachable*/
|
biu_state <= `BIU_NEXT_ACTION;/*Should be unreachable*/
|
||||||
@ -291,19 +293,47 @@ wire [2:0] fifoIsize;
|
|||||||
wire Isit1;
|
wire Isit1;
|
||||||
/* verilator lint_on UNDRIVEN */
|
/* verilator lint_on UNDRIVEN */
|
||||||
`ifdef EARLY_VALID_INSTRUCTION
|
`ifdef EARLY_VALID_INSTRUCTION
|
||||||
InstrSize fifoInstrSize({INPUT_FIFO[FIFO_start][7:0],INPUT_FIFO[FIFO_start][5:3]},fifoIsize);
|
InstrSize fifoInstrSize({INPUT_FIFO[FIFO_start][7:0],INPUT_FIFO[FIFO_start+1][5:3]},fifoIsize);
|
||||||
Is1 Is1(INPUT_FIFO[FIFO_start][7:0],Isit1);
|
Is1 Is1(INPUT_FIFO[FIFO_start][7:0],Isit1);
|
||||||
`endif
|
`endif
|
||||||
|
|
||||||
always @( NEXT_POSITION ) begin
|
reg was_dec;
|
||||||
case(NEXT_POSITION)
|
reg was_simple;
|
||||||
2'b00:begin end /* no action */
|
|
||||||
2'b01:begin /* Next instruction */
|
always @( proc_state ) begin
|
||||||
|
case (proc_state)
|
||||||
|
`PROC_DE_STATE_ENTRY: begin
|
||||||
|
was_dec<=1;
|
||||||
|
end
|
||||||
|
default: begin
|
||||||
|
if( SIMPLE_MICRO==0 && was_dec==1 )begin
|
||||||
|
was_dec<=0;
|
||||||
/* verilator lint_off BLKSEQ */
|
/* verilator lint_off BLKSEQ */
|
||||||
FIFO_start = FIFO_start + {1'b0,Isize};
|
FIFO_start = FIFO_start + {1'b0,Isize};
|
||||||
INSTRUCTION_LOCATION <= INSTRUCTION_LOCATION + {12'b0,Isize};;
|
INSTRUCTION_LOCATION <= INSTRUCTION_LOCATION + {12'b0,Isize};;
|
||||||
/* verilator lint_on BLKSEQ */
|
/* verilator lint_on BLKSEQ */
|
||||||
VALID_INSTRUCTION <= 0;
|
VALID_INSTRUCTION <= 0;
|
||||||
|
end else if ( SIMPLE_MICRO==1 && was_simple == 1) begin
|
||||||
|
was_simple<=0;
|
||||||
|
was_dec<=0;
|
||||||
|
/* verilator lint_off BLKSEQ */
|
||||||
|
FIFO_start = FIFO_start + {1'b0,Isize};
|
||||||
|
INSTRUCTION_LOCATION <= INSTRUCTION_LOCATION + {12'b0,Isize};;
|
||||||
|
/* verilator lint_on BLKSEQ */
|
||||||
|
VALID_INSTRUCTION <= 0;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
|
||||||
|
always @( negedge SIMPLE_MICRO ) begin
|
||||||
|
was_simple <= 1;
|
||||||
|
end
|
||||||
|
|
||||||
|
always @( NEXT_POSITION ) begin
|
||||||
|
case(NEXT_POSITION)
|
||||||
|
2'b00:begin end /* no action */
|
||||||
|
2'b01:begin /* Next instruction */
|
||||||
end
|
end
|
||||||
2'b10:begin /* Jump to specific location based on register */
|
2'b10:begin /* Jump to specific location based on register */
|
||||||
jump_req <= 1;
|
jump_req <= 1;
|
||||||
|
@ -92,7 +92,7 @@ microcode ucode(seq_addr_input,ucode_data);
|
|||||||
// then branching off of that instead of the raw bits. otherwise the code
|
// then branching off of that instead of the raw bits. otherwise the code
|
||||||
// would be identical
|
// would be identical
|
||||||
// verilator lint_off BLKSEQ
|
// verilator lint_off BLKSEQ
|
||||||
always @( CIR or SIMPLE_MICRO or seq_addr_input ) begin
|
always @( FLAGS or CIR or SIMPLE_MICRO or seq_addr_input ) begin
|
||||||
if (SIMPLE_MICRO==0)begin
|
if (SIMPLE_MICRO==0)begin
|
||||||
casez({CIR[15:8],CIR[5:3]})
|
casez({CIR[15:8],CIR[5:3]})
|
||||||
11'b0000_010?_??? : begin
|
11'b0000_010?_??? : begin
|
||||||
|
@ -49,7 +49,8 @@ wire BIU_VALID_DATA;
|
|||||||
|
|
||||||
BIU BIU(
|
BIU BIU(
|
||||||
clock,reset,external_address_bus,external_data_bus,read,write,BHE,IOMEM,
|
clock,reset,external_address_bus,external_data_bus,read,write,BHE,IOMEM,
|
||||||
INSTRUCTION,VALID_INSTRUCTION,INSTRUCTION_LOCATION,BIU_NEXT_POSITION,BIU_ADDRESS_INPUT,BIU_DATA,biu_write_request,biu_read_request,Wbit,BIU_VALID_DATA,MEM_OR_IO
|
INSTRUCTION,VALID_INSTRUCTION,INSTRUCTION_LOCATION,BIU_NEXT_POSITION,BIU_ADDRESS_INPUT,BIU_DATA,biu_write_request,biu_read_request,Wbit,BIU_VALID_DATA,MEM_OR_IO,
|
||||||
|
state,SIMPLE_MICRO
|
||||||
);
|
);
|
||||||
assign BIU_DATA= biu_data_direction ? 16'hz : (memio_address_select?reg_read_port1_data:ALU_1O);
|
assign BIU_DATA= biu_data_direction ? 16'hz : (memio_address_select?reg_read_port1_data:ALU_1O);
|
||||||
|
|
||||||
@ -411,7 +412,7 @@ always @(posedge clock) begin
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
`PROC_NEXT_INSTRUCTION:begin
|
`PROC_NEXT_INSTRUCTION:begin
|
||||||
BIU_NEXT_POSITION <= 2'b01;
|
/*necessary for biu to see we went on another state from decode to give us a new instruction*/
|
||||||
state <= `PROC_DE_STATE_ENTRY;
|
state <= `PROC_DE_STATE_ENTRY;
|
||||||
end
|
end
|
||||||
`PROC_EX_STATE_ENTRY:begin
|
`PROC_EX_STATE_ENTRY:begin
|
||||||
@ -460,8 +461,6 @@ always @(posedge clock) begin
|
|||||||
state <= `PROC_MEMIO_WRITE;
|
state <= `PROC_MEMIO_WRITE;
|
||||||
end
|
end
|
||||||
endcase
|
endcase
|
||||||
if(BIU_NEXT_POSITION != 2'b10 )
|
|
||||||
BIU_NEXT_POSITION <= 2'b01;
|
|
||||||
end
|
end
|
||||||
3'b011:begin
|
3'b011:begin
|
||||||
reg_write_we <= 0;
|
reg_write_we <= 0;
|
||||||
@ -469,16 +468,12 @@ always @(posedge clock) begin
|
|||||||
state <= `PROC_DE_STATE_ENTRY;
|
state <= `PROC_DE_STATE_ENTRY;
|
||||||
else
|
else
|
||||||
state <= `PROC_NEXT_MICROCODE;
|
state <= `PROC_NEXT_MICROCODE;
|
||||||
if(BIU_NEXT_POSITION != 2'b10 )
|
|
||||||
BIU_NEXT_POSITION <= 2'b01;
|
|
||||||
end
|
end
|
||||||
3'b100:begin /*No output*/
|
3'b100:begin /*No output*/
|
||||||
if (ucode_seq_addr==`UCODE_NO_INSTRUCTION)
|
if (ucode_seq_addr==`UCODE_NO_INSTRUCTION)
|
||||||
state <= `PROC_DE_STATE_ENTRY;
|
state <= `PROC_DE_STATE_ENTRY;
|
||||||
else
|
else
|
||||||
state <= `PROC_NEXT_MICROCODE;
|
state <= `PROC_NEXT_MICROCODE;
|
||||||
if(BIU_NEXT_POSITION != 2'b10 )
|
|
||||||
BIU_NEXT_POSITION <= 2'b01;
|
|
||||||
end
|
end
|
||||||
3'b101:begin /* Program Counter*/
|
3'b101:begin /* Program Counter*/
|
||||||
BIU_ADDRESS_INPUT <= ALU_1O[15:0];
|
BIU_ADDRESS_INPUT <= ALU_1O[15:0];
|
||||||
@ -492,8 +487,6 @@ always @(posedge clock) begin
|
|||||||
3'b110:begin /* SP Indirect write*/
|
3'b110:begin /* SP Indirect write*/
|
||||||
reg_read_port1_addr <= 4'b1100;
|
reg_read_port1_addr <= 4'b1100;
|
||||||
state <= `PROC_MEMIO_WRITE;
|
state <= `PROC_MEMIO_WRITE;
|
||||||
if(BIU_NEXT_POSITION != 2'b10 )
|
|
||||||
BIU_NEXT_POSITION <= 2'b01;
|
|
||||||
end
|
end
|
||||||
3'b111:begin /* Write to PRAM1 (for microcode calculations) */
|
3'b111:begin /* Write to PRAM1 (for microcode calculations) */
|
||||||
PARAM1 <= ALU_1O;
|
PARAM1 <= ALU_1O;
|
||||||
@ -501,8 +494,6 @@ always @(posedge clock) begin
|
|||||||
state <= `PROC_DE_STATE_ENTRY;
|
state <= `PROC_DE_STATE_ENTRY;
|
||||||
else
|
else
|
||||||
state <= `PROC_NEXT_MICROCODE;
|
state <= `PROC_NEXT_MICROCODE;
|
||||||
if(BIU_NEXT_POSITION != 2'b10 )
|
|
||||||
BIU_NEXT_POSITION <= 2'b01;
|
|
||||||
end
|
end
|
||||||
default:begin
|
default:begin
|
||||||
`unimpl_addressing_mode
|
`unimpl_addressing_mode
|
||||||
|
Loading…
Reference in New Issue
Block a user