ariane: Support less than 2 commit ports (#365)

This commit is contained in:
b1f6c1c4 2020-04-15 03:46:15 -04:00 committed by GitHub
parent ce2f96f14f
commit f0d2a6d635
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 45 deletions

View file

@ -281,7 +281,8 @@ module ariane #(
// ---------
issue_stage #(
.NR_ENTRIES ( NR_SB_ENTRIES ),
.NR_WB_PORTS ( NR_WB_PORTS )
.NR_WB_PORTS ( NR_WB_PORTS ),
.NR_COMMIT_PORTS ( NR_COMMIT_PORTS )
) issue_stage_i (
.clk_i,
.rst_ni,
@ -426,7 +427,9 @@ module ariane #(
// used e.g. for fence instructions.
assign no_st_pending_commit = no_st_pending_ex & dcache_commit_wbuffer_empty;
commit_stage commit_stage_i (
commit_stage #(
.NR_COMMIT_PORTS ( NR_COMMIT_PORTS )
) commit_stage_i (
.clk_i,
.rst_ni,
.halt_i ( halt_ctrl ),
@ -465,7 +468,8 @@ module ariane #(
// ---------
csr_regfile #(
.AsidWidth ( ASID_WIDTH ),
.DmBaseAddress ( ArianeCfg.DmBaseAddress )
.DmBaseAddress ( ArianeCfg.DmBaseAddress ),
.NrCommitPorts ( NR_COMMIT_PORTS )
) csr_regfile_i (
.flush_o ( flush_csr_ctrl ),
.halt_csr_o ( halt_csr_ctrl ),

View file

@ -69,9 +69,9 @@ module commit_stage #(
// .probe9(1'b0) // input wire [0:0] probe9
// );
// TODO make these parametric with NR_COMMIT_PORTS
assign waddr_o[0] = commit_instr_i[0].rd[4:0];
assign waddr_o[1] = commit_instr_i[1].rd[4:0];
for (genvar i = 0; i < NR_COMMIT_PORTS; i++) begin : gen_waddr
assign waddr_o[i] = commit_instr_i[i].rd[4:0];
end
assign pc_o = commit_instr_i[0].pc;
// Dirty the FP state if we are committing anything related to the FPU
@ -209,38 +209,40 @@ module commit_stage #(
end
end
// -----------------
// Commit Port 2
// -----------------
// check if the second instruction can be committed as well and the first wasn't a CSR instruction
// also if we are in single step mode don't retire the second instruction
if (commit_ack_o[0] && commit_instr_i[1].valid
&& !halt_i
&& !(commit_instr_i[0].fu inside {CSR})
&& !flush_dcache_i
&& !instr_0_is_amo
&& !single_step_i) begin
// only if the first instruction didn't throw an exception and this instruction won't throw an exception
// and the functional unit is of type ALU, LOAD, CTRL_FLOW, MULT, FPU or FPU_VEC
if (!exception_o.valid && !commit_instr_i[1].ex.valid
&& (commit_instr_i[1].fu inside {ALU, LOAD, CTRL_FLOW, MULT, FPU, FPU_VEC})) begin
if (NR_COMMIT_PORTS > 1) begin
// -----------------
// Commit Port 2
// -----------------
// check if the second instruction can be committed as well and the first wasn't a CSR instruction
// also if we are in single step mode don't retire the second instruction
if (commit_ack_o[0] && commit_instr_i[1].valid
&& !halt_i
&& !(commit_instr_i[0].fu inside {CSR})
&& !flush_dcache_i
&& !instr_0_is_amo
&& !single_step_i) begin
// only if the first instruction didn't throw an exception and this instruction won't throw an exception
// and the functional unit is of type ALU, LOAD, CTRL_FLOW, MULT, FPU or FPU_VEC
if (!exception_o.valid && !commit_instr_i[1].ex.valid
&& (commit_instr_i[1].fu inside {ALU, LOAD, CTRL_FLOW, MULT, FPU, FPU_VEC})) begin
if (is_rd_fpr(commit_instr_i[1].op))
we_fpr_o[1] = 1'b1;
else
we_gpr_o[1] = 1'b1;
commit_ack_o[1] = 1'b1;
// additionally check if we are retiring an FPU instruction because we need to make sure that we write all
// exception flags
if (commit_instr_i[1].fu inside {FPU, FPU_VEC}) begin
if (csr_write_fflags_o)
csr_wdata_o = {59'b0, (commit_instr_i[0].ex.cause[4:0] | commit_instr_i[1].ex.cause[4:0])};
if (is_rd_fpr(commit_instr_i[1].op))
we_fpr_o[1] = 1'b1;
else
csr_wdata_o = {59'b0, commit_instr_i[1].ex.cause[4:0]};
we_gpr_o[1] = 1'b1;
csr_write_fflags_o = 1'b1;
commit_ack_o[1] = 1'b1;
// additionally check if we are retiring an FPU instruction because we need to make sure that we write all
// exception flags
if (commit_instr_i[1].fu inside {FPU, FPU_VEC}) begin
if (csr_write_fflags_o)
csr_wdata_o = {59'b0, (commit_instr_i[0].ex.cause[4:0] | commit_instr_i[1].ex.cause[4:0])};
else
csr_wdata_o = {59'b0, commit_instr_i[1].ex.cause[4:0]};
csr_write_fflags_o = 1'b1;
end
end
end
end

@ -1 +1 @@
Subproject commit 790f2385c01c83022474eede55809666209216e3
Subproject commit b2a4b2d3decdfc152ad9b4564a48ed3b2649fd6c

View file

@ -349,9 +349,11 @@ module issue_read_operands #(
logic [NR_COMMIT_PORTS-1:0][63:0] wdata_pack;
logic [NR_COMMIT_PORTS-1:0] we_pack;
assign raddr_pack = {issue_instr_i.rs2[4:0], issue_instr_i.rs1[4:0]};
assign waddr_pack = {waddr_i[1], waddr_i[0]};
assign wdata_pack = {wdata_i[1], wdata_i[0]};
assign we_pack = {we_gpr_i[1], we_gpr_i[0]};
for (genvar i = 0; i < NR_COMMIT_PORTS; i++) begin : gen_write_back_port
assign waddr_pack[i] = waddr_i[i];
assign wdata_pack[i] = wdata_i[i];
assign we_pack[i] = we_gpr_i[i];
end
ariane_regfile #(
.DATA_WIDTH ( 64 ),
@ -380,7 +382,9 @@ module issue_read_operands #(
generate
if (FP_PRESENT) begin : float_regfile_gen
assign fp_raddr_pack = {issue_instr_i.result[4:0], issue_instr_i.rs2[4:0], issue_instr_i.rs1[4:0]};
assign fp_wdata_pack = {wdata_i[1][FLEN-1:0], wdata_i[0][FLEN-1:0]};
for (genvar i = 0; i < NR_COMMIT_PORTS; i++) begin : gen_fp_wdata_pack
assign fp_wdata_pack[i] = {wdata_i[i][FLEN-1:0]};
end
ariane_regfile #(
.DATA_WIDTH ( FLEN ),
@ -438,9 +442,6 @@ module issue_read_operands #(
@(posedge clk_i) (branch_valid_q) |-> (!$isunknown(operand_a_q) && !$isunknown(operand_b_q)))
else $warning ("Got unknown value in one of the operands");
initial begin
assert (NR_COMMIT_PORTS == 2) else $error("Only two commit ports are supported at the moment!");
end
`endif
//pragma translate_on
endmodule

View file

@ -118,7 +118,8 @@ module issue_stage #(
// ---------------------------------------------------------
scoreboard #(
.NR_ENTRIES (NR_ENTRIES ),
.NR_WB_PORTS(NR_WB_PORTS)
.NR_WB_PORTS(NR_WB_PORTS),
.NR_COMMIT_PORTS(NR_COMMIT_PORTS)
) i_scoreboard (
.sb_full_o ( sb_full_o ),
.unresolved_branch_i ( 1'b0 ),
@ -151,7 +152,9 @@ module issue_stage #(
// ---------------------------------------------------------
// 3. Issue instruction and read operand, also commit
// ---------------------------------------------------------
issue_read_operands i_issue_read_operands (
issue_read_operands #(
.NR_COMMIT_PORTS ( NR_COMMIT_PORTS )
)i_issue_read_operands (
.flush_i ( flush_unissued_instr_i ),
.issue_instr_i ( issue_instr_sb_iro ),
.issue_instr_valid_i ( issue_instr_valid_sb_iro ),