add the block to setup registers for 0Efx

This commit is contained in:
Raphael Jacquot 2019-02-12 15:33:04 +01:00
parent e409021f35
commit eef2d13c60

View file

@ -145,12 +145,15 @@ always @(posedge i_clk) begin
`ALU_REG_C: $write("C");
`ALU_REG_RSTK: $write("RSTK");
`ALU_REG_ST: if (o_alu_op!=`ALU_OP_ZERO) $write("ST");
`ALU_REG_P: $write("P");
default: $write("[dest:%d]", o_reg_dest);
endcase
case (o_alu_op)
`ALU_OP_ZERO: if (o_reg_dest==`ALU_REG_ST) $write("CLRST"); else $write("=0");
`ALU_OP_COPY: $write("=");
`ALU_OP_COPY,
`ALU_OP_INC,
`ALU_OP_DEC: $write("=");
`ALU_OP_EXCH: begin end
default: $write("[op:%d]", o_alu_op);
endcase
@ -159,12 +162,15 @@ always @(posedge i_clk) begin
`ALU_OP_COPY,
`ALU_OP_EXCH,
`ALU_OP_AND,
`ALU_OP_OR:
`ALU_OP_OR,
`ALU_OP_INC,
`ALU_OP_DEC:
case (o_reg_src1)
`ALU_REG_A: $write("A");
`ALU_REG_C: $write("C");
`ALU_REG_RSTK: $write("RSTK");
`ALU_REG_ST: $write("ST");
`ALU_REG_P: $write("P");
default: $write("[src1:%d]", o_reg_src1);
endcase
endcase
@ -186,10 +192,16 @@ always @(posedge i_clk) begin
default: $write("[src2:%d]", o_reg_src2);
endcase
end
`ALU_OP_INC: $write("+1");
`ALU_OP_DEC: $write("-1");
`ALU_OP_ZERO,
`ALU_OP_COPY,
`ALU_OP_EXCH: begin end
endcase
if (!((o_reg_dest == `ALU_REG_RSTK) || (o_reg_src1 == `ALU_REG_RSTK) ||
(o_reg_dest == `ALU_REG_ST) || (o_reg_src1 == `ALU_REG_ST ))) begin
(o_reg_dest == `ALU_REG_ST) || (o_reg_src1 == `ALU_REG_ST ) ||
(o_reg_dest == `ALU_REG_P) || (o_reg_src1 == `ALU_REG_P ))) begin
$write("\t");
case (o_field)
default: $write("[f:%d]", o_field);
@ -290,89 +302,93 @@ always @(posedge i_clk) begin
endcase
end
/******************************************************************************
*
* 0x
*
* 00 RTNSXM
* 01 RTN
* 02 RTNSC
* 03 RTNCC
* 04 SETHEX
* 05 SETDEC
* 06 RSTK=C
* 07 C=RSTK
*
*****************************************************************************/
if (continue) begin
if (continue && block_0x) begin
case (i_nibble)
4'h0, 4'h1, 4'h2, 4'h3: begin
o_ins_rtn <= 1;
o_set_xm <= (i_nibble == 4'h0);
o_set_carry <= (i_nibble[3:1] == 1);
o_carry_val <= (i_nibble[1] && i_nibble[0]);
end
4'h4, 4'h5: begin
o_ins_set_mode <= 1;
o_mode_dec <= (i_nibble[0]);
end
/* RSTK=C
* C=RSTK
* those 2 are alu copy ops between RSTK and C
*/
4'h6, 6'h7: begin
o_ins_alu_op <= 1;
o_alu_op <= `ALU_OP_COPY;
o_push <= !i_nibble[0];
o_pop <= i_nibble[0];
end
4'h8: begin
o_ins_alu_op <= 1;
o_alu_op <= `ALU_OP_ZERO;
end
4'h9, 4'hA: begin
o_ins_alu_op <= 1;
o_alu_op <= `ALU_OP_COPY;
end
4'hB: begin
o_ins_alu_op <= 1;
o_alu_op <= `ALU_OP_EXCH;
end
4'hC, 4'hD: begin
o_ins_alu_op <= 1;
o_alu_op <= i_nibble[0]?`ALU_OP_DEC:`ALU_OP_INC;
end
4'hE: begin
block_0x <= 0;
o_fields_table <= `FT_TABLE_f;
end
default: begin
`ifdef SIM
$display("block_0x: nibble %h not handled", i_nibble);
`endif
o_dec_error <= 1;
end
endcase
continue <= (i_nibble == 4'hE);
block_0Efx <= (i_nibble == 4'hE);
fields_table <= (i_nibble == 4'hE);
o_ins_decoded <= (i_nibble != 4'hE);
end
/******************************************************************************
*
* 0x
*
* 00 RTNSXM
* 01 RTN
* 02 RTNSC
* 03 RTNCC
* 04 SETHEX
* 05 SETDEC
* 06 RSTK=C
* 07 C=RSTK
*
*****************************************************************************/
/******************************************************************************
*
* 0Ex
*
*
*****************************************************************************/
if (block_0x) begin
case (i_nibble)
4'h0, 4'h1, 4'h2, 4'h3: begin
o_ins_rtn <= 1;
o_set_xm <= (i_nibble == 4'h0);
o_set_carry <= (i_nibble[3:1] == 1);
o_carry_val <= (i_nibble[1] && i_nibble[0]);
end
4'h4, 4'h5: begin
o_ins_set_mode <= 1;
o_mode_dec <= (i_nibble[0]);
end
/* RSTK=C
* C=RSTK
* those 2 are alu copy ops between RSTK and C
*/
4'h6, 6'h7: begin
o_ins_alu_op <= 1;
o_alu_op <= `ALU_OP_COPY;
o_push <= !i_nibble[0];
o_pop <= i_nibble[0];
end
4'h8: begin
o_ins_alu_op <= 1;
o_alu_op <= `ALU_OP_ZERO;
end
4'h9, 4'hA: begin
o_ins_alu_op <= 1;
o_alu_op <= `ALU_OP_COPY;
end
4'hB: begin
o_ins_alu_op <= 1;
o_alu_op <= `ALU_OP_EXCH;
end
4'hC, 4'hD: begin
o_ins_alu_op <= 1;
o_alu_op <= i_nibble[0]?`ALU_OP_DEC:`ALU_OP_INC;
end
4'hE: begin
block_0x <= 0;
o_fields_table <= `FT_TABLE_f;
end
default: begin
`ifdef SIM
$display("block_0x: nibble %h not handled", i_nibble);
`endif
o_dec_error <= 1;
end
endcase
continue <= (i_nibble == 4'hE);
block_0Efx <= (i_nibble == 4'hE);
fields_table <= (i_nibble == 4'hE);
o_ins_decoded <= (i_nibble != 4'hE);
end
if (continue && block_0Efx && !fields_table) begin
o_ins_alu_op <= 1;
o_alu_op <= (!i_nibble[3])?`ALU_OP_AND:`ALU_OP_OR;
continue <= 0;
o_ins_decoded <= 1;
end
/******************************************************************************
*
* 0Ex
*
*
*****************************************************************************/
if (block_0Efx && !fields_table) begin
o_ins_alu_op <= 1;
o_alu_op <= (!i_nibble[3])?`ALU_OP_AND:`ALU_OP_OR;
continue <= 0;
o_ins_decoded <= 1;
end
end // (continue == 1)
end
end
end
@ -391,12 +407,16 @@ always @(posedge i_clk) begin
o_reg_src2 <= 0;
end else begin
// reset values on instruction decode start
if (i_en_dec && !i_stalled && !continue) begin
o_reg_dest <= 0;
o_reg_src1 <= 0;
o_reg_src2 <= 0;
end
if (i_en_dec && !i_stalled) begin
// reset values on instruction decode start
if (!continue) begin
o_reg_dest <= 0;
o_reg_src1 <= 0;
o_reg_src2 <= 0;
end
if (continue) begin
/************************************************************************
*
@ -404,32 +424,40 @@ always @(posedge i_clk) begin
*
************************************************************************/
if (i_en_dec && !i_stalled && continue) begin
if (block_0x) begin
case (i_nibble)
4'h6: begin
o_reg_dest <= `ALU_REG_RSTK;
o_reg_src1 <= `ALU_REG_C;
end
4'h7: begin
o_reg_dest <= `ALU_REG_C;
o_reg_src1 <= `ALU_REG_RSTK;
end
4'h8: o_reg_dest <= `ALU_REG_ST;
4'h9, 4'hB: begin
o_reg_dest <= `ALU_REG_C;
o_reg_src1 <= `ALU_REG_ST;
end
4'hA: begin
o_reg_dest <= `ALU_REG_ST;
o_reg_src1 <= `ALU_REG_C;
end
4'hC, 4'hD: begin
o_reg_dest <= `ALU_REG_P;
o_reg_src1 <= `ALU_REG_P;
end
endcase
end
if (block_0x) begin
case (i_nibble)
4'h6: begin
o_reg_dest <= `ALU_REG_RSTK;
o_reg_src1 <= `ALU_REG_C;
end
4'h7: begin
o_reg_dest <= `ALU_REG_C;
o_reg_src1 <= `ALU_REG_RSTK;
end
4'h8: o_reg_dest <= `ALU_REG_ST;
4'h9, 4'hB: begin
o_reg_dest <= `ALU_REG_C;
o_reg_src1 <= `ALU_REG_ST;
end
4'hA: begin
o_reg_dest <= `ALU_REG_ST;
o_reg_src1 <= `ALU_REG_C;
end
endcase
end
end
if (block_0Efx && !fields_table) begin
`ifdef SIM
$write("\nset registers for block_0Efx");
`endif
end
end
end
end
end