Line 289... |
Line 289... |
ex_mem_addr <= 0;
|
ex_mem_addr <= 0;
|
ex_mem_addrnext <= 0;
|
ex_mem_addrnext <= 0;
|
ex_mem_addrjump <= 0;
|
ex_mem_addrjump <= 0;
|
ex_mem_addrbranch <= 0;
|
ex_mem_addrbranch <= 0;
|
ex_mem_aluout <= 0;
|
ex_mem_aluout <= 0;
|
|
ex_mem_carry <= 0;
|
ex_mem_branch <= 0;
|
ex_mem_branch <= 0;
|
ex_mem_jump <= 0;
|
ex_mem_jump <= 0;
|
ex_mem_jr <= 0;
|
ex_mem_jr <= 0;
|
ex_mem_linked <= 0;
|
ex_mem_linked <= 0;
|
ex_mem_mult <= 0;
|
ex_mem_mult <= 0;
|
Line 342... |
Line 343... |
if_id_opcode <= `BUBBLE;
|
if_id_opcode <= `BUBBLE;
|
end
|
end
|
|
|
end else begin
|
end else begin
|
|
|
// Branch taken: insert a bubble and increment PC
|
// If branch taken update the Program Counter
|
if(ex_mem_branch==1 && ex_mem_aluout==32'h00000001) begin
|
if(ex_mem_branch==1 && ex_mem_aluout==32'h00000001) begin
|
|
|
$display("INFO: CPU(%m)-IF: Bubble inserted due branch taken in EX/MEM instruction @ADDR=%X w/OPCODE=%X having ALUout=%X", ex_mem_addr, ex_mem_opcode, ex_mem_aluout);
|
$display("INFO: CPU(%m)-IF: Bubble inserted due branch taken in EX/MEM instruction @ADDR=%X w/OPCODE=%X having ALUout=%X", ex_mem_addr, ex_mem_opcode, ex_mem_aluout);
|
if_id_opcode <= `BUBBLE;
|
if_id_opcode <= `BUBBLE;
|
PC <= ex_mem_addrbranch;
|
PC <= ex_mem_addrbranch;
|
Line 1079... |
Line 1080... |
begin
|
begin
|
$display("INFO: CPU(%m)-ID: Decoded instruction @ADDR=%X w/OPCODE=%X as SRA r%d, r%d, %h", if_id_addr, if_id_opcode, if_id_rd, if_id_rt, if_id_shamt);
|
$display("INFO: CPU(%m)-ID: Decoded instruction @ADDR=%X w/OPCODE=%X as SRA r%d, r%d, %h", if_id_addr, if_id_opcode, if_id_rd, if_id_rt, if_id_shamt);
|
id_ex_alu_a <= GPR[if_id_rt];
|
id_ex_alu_a <= GPR[if_id_rt];
|
id_ex_alu_b <= if_id_shamt;
|
id_ex_alu_b <= if_id_shamt;
|
id_ex_alu_func <= `ALU_OP_SRA;
|
id_ex_alu_func <= `ALU_OP_SRA;
|
id_ex_alu_signed <= 1; // does nothing??
|
id_ex_alu_signed <= 1;
|
id_ex_branch <= 0;
|
id_ex_branch <= 0;
|
id_ex_jump <= 0;
|
id_ex_jump <= 0;
|
id_ex_jr <= 0;
|
id_ex_jr <= 0;
|
id_ex_linked <= 0;
|
id_ex_linked <= 0;
|
id_ex_mult <= 0;
|
id_ex_mult <= 0;
|
Line 1762... |
Line 1763... |
ex_mem_destreg <= id_ex_destreg;
|
ex_mem_destreg <= id_ex_destreg;
|
ex_mem_desthi <= id_ex_desthi;
|
ex_mem_desthi <= id_ex_desthi;
|
ex_mem_destlo <= id_ex_destlo;
|
ex_mem_destlo <= id_ex_destlo;
|
|
|
// Choose the output from ALU, Multiplier or Divider
|
// Choose the output from ALU, Multiplier or Divider
|
if(id_ex_mult) ex_mem_aluout <= mul_product_i;
|
if(id_ex_mult) begin
|
else if(id_ex_div) ex_mem_aluout <= { div_remainder_i, div_quotient_i };
|
ex_mem_aluout <= mul_product_i;
|
else begin
|
ex_mem_carry <= 1b'0;
|
|
end else if(id_ex_div) begin
|
|
ex_mem_aluout <= { div_remainder_i, div_quotient_i };
|
|
ex_mem_carry <= 1b'0;
|
|
end else begin
|
ex_mem_aluout <= {32'b0, alu_result_i[31:0]};
|
ex_mem_aluout <= {32'b0, alu_result_i[31:0]};
|
ex_mem_carry <= alu_result_i[32];
|
ex_mem_carry <= alu_result_i[32];
|
end
|
end
|
|
|
if(id_ex_store) begin
|
if(id_ex_store) begin
|
|
|
|
// Handle all supported store sizes
|
$display("INFO: CPU(%m)-EX: Execution of Store instruction @ADDR=%X w/OPCODE=%X started to STORE_ADDR=%X w/STORE_DATA=%X", id_ex_addr, id_ex_opcode, alu_result_i, id_ex_store_value);
|
$display("INFO: CPU(%m)-EX: Execution of Store instruction @ADDR=%X w/OPCODE=%X started to STORE_ADDR=%X w/STORE_DATA=%X", id_ex_addr, id_ex_opcode, alu_result_i, id_ex_store_value);
|
case(id_ex_size)
|
case(id_ex_size)
|
`SIZE_WORD: begin
|
`SIZE_WORD: begin
|
ex_mem_store_value <= id_ex_store_value;
|
ex_mem_store_value <= id_ex_store_value;
|
ex_mem_store_sel <= 4'b1111;
|
ex_mem_store_sel <= 4'b1111;
|