Skip to content

Commit 2ef1c1b

Browse files
authored
Update ID stage to support ZCMP, ZCMT and CVXIF with Superscalar (#2756)
Add support for Superscalar with ZCMP, ZCMT and CVXIF. ZCMP decoder, ZCMT decoder and CVXIF interface driver are using port 0. Standard RVC and 32 bits instruction can take port 0 or 1.
1 parent fd8c890 commit 2ef1c1b

File tree

11 files changed

+320
-240
lines changed

11 files changed

+320
-240
lines changed

core/commit_stage.sv

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ module commit_stage
301301
end
302302

303303
if (CVA6Cfg.NrCommitPorts > 1) begin
304-
305-
commit_ack_o[1] = 1'b0;
306-
we_gpr_o[1] = 1'b0;
307-
wdata_o[1] = commit_instr_i[1].result;
304+
commit_macro_ack[1] = 1'b0;
305+
commit_ack_o[1] = 1'b0;
306+
we_gpr_o[1] = 1'b0;
307+
wdata_o[1] = commit_instr_i[1].result;
308308

309309
// -----------------
310310
// Commit Port 2
@@ -350,10 +350,9 @@ module commit_stage
350350
end
351351
end
352352
if (CVA6Cfg.RVZCMP) begin
353-
if (CVA6Cfg.NrCommitPorts > 1)
354-
commit_macro_ack_o = (commit_instr_i[0].is_macro_instr || commit_instr_i[1].is_macro_instr) ? commit_macro_ack : commit_ack_o;
355-
else
356-
commit_macro_ack_o = (commit_instr_i[0].is_macro_instr) ? commit_macro_ack : commit_ack_o;
353+
for (int i = 0; i < CVA6Cfg.NrCommitPorts; i++) begin
354+
commit_macro_ack_o[i] = commit_instr_i[i].is_macro_instr ? commit_macro_ack[i] : commit_ack_o[i];
355+
end
357356
end else commit_macro_ack_o = commit_ack_o;
358357
end
359358

core/cvxif_compressed_if_driver.sv

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ module cvxif_compressed_if_driver #(
1616
input logic clk_i,
1717
// Asynchronous reset active low - SUBSYSTEM
1818
input logic rst_ni,
19+
input logic flush_i,
1920
// CVA6 Hart id
2021
input logic [CVA6Cfg.XLEN-1:0] hart_id_i,
2122

22-
input logic [CVA6Cfg.NrIssuePorts-1:0] is_compressed_i,
23-
input logic [CVA6Cfg.NrIssuePorts-1:0] is_illegal_i,
24-
input logic [CVA6Cfg.NrIssuePorts-1:0] instruction_valid_i,
25-
input logic [CVA6Cfg.NrIssuePorts-1:0][31:0] instruction_i,
23+
input logic is_compressed_i,
24+
input logic is_illegal_i,
25+
input logic [31:0] instruction_i,
2626

27-
output logic [CVA6Cfg.NrIssuePorts-1:0] is_compressed_o,
28-
output logic [CVA6Cfg.NrIssuePorts-1:0] is_illegal_o,
29-
output logic [CVA6Cfg.NrIssuePorts-1:0][31:0] instruction_o,
30-
input logic stall_i,
31-
output logic [CVA6Cfg.NrIssuePorts-1:0] stall_o,
27+
output logic is_compressed_o,
28+
output logic is_illegal_o,
29+
output logic [31:0] instruction_o,
30+
input logic stall_i,
31+
output logic stall_o,
3232
// CVXIF Compressed interface
33-
input logic compressed_ready_i,
34-
input x_compressed_resp_t compressed_resp_i,
35-
output logic compressed_valid_o,
36-
output x_compressed_req_t compressed_req_o
33+
input logic compressed_ready_i,
34+
input x_compressed_resp_t compressed_resp_i,
35+
output logic compressed_valid_o,
36+
output x_compressed_req_t compressed_req_o
3737
);
3838

3939

@@ -44,32 +44,22 @@ module cvxif_compressed_if_driver #(
4444
compressed_valid_o = 1'b0;
4545
compressed_req_o.instr = '0;
4646
compressed_req_o.hartid = hart_id_i;
47-
stall_o[0] = stall_i;
48-
stall_o[1] = 1'b0;
49-
if (is_illegal_i[0]) begin
50-
compressed_valid_o = is_illegal_i[0] && instruction_valid_i[0];
51-
compressed_req_o.instr = instruction_i[0][15:0];
52-
is_illegal_o[0] = ~compressed_resp_i.accept;
53-
instruction_o[0] = compressed_resp_i.accept ? compressed_resp_i.instr : instruction_i[0];
54-
is_compressed_o[0] = compressed_resp_i.accept ? 1'b0 : is_compressed_i[0];
47+
stall_o = stall_i;
48+
if (is_illegal_i) begin
49+
compressed_valid_o = is_illegal_i;
50+
compressed_req_o.instr = instruction_i[15:0];
51+
is_illegal_o = ~compressed_resp_i.accept;
52+
instruction_o = compressed_resp_i.accept ? compressed_resp_i.instr : instruction_i;
53+
is_compressed_o = compressed_resp_i.accept ? 1'b0 : is_compressed_i;
5554
if (~stall_i) begin
5655
// Propagate stall from macro decoder or wait for compressed ready if compressed transaction is happening.
57-
// Stall if both instruction are illegal
58-
stall_o[0] = (compressed_valid_o && ~compressed_ready_i);
59-
if (CVA6Cfg.SuperscalarEn) begin
60-
stall_o[1] = is_illegal_i[1];
61-
end
56+
stall_o = (compressed_valid_o && ~compressed_ready_i);
6257
end
6358
end
64-
if (CVA6Cfg.SuperscalarEn) begin
65-
if (~is_illegal_i[0] && is_illegal_i[1]) begin // 2nd instruction is illegal
66-
compressed_valid_o = is_illegal_i[1] && instruction_valid_i[1];
67-
compressed_req_o.instr = instruction_i[1][15:0];
68-
is_illegal_o[1] = ~compressed_resp_i.accept;
69-
instruction_o[1] = compressed_resp_i.accept ? compressed_resp_i.instr : instruction_i[1];
70-
is_compressed_o[1] = compressed_resp_i.accept ? 1'b0 : is_compressed_i[1];
71-
stall_o[1] = (compressed_valid_o && ~compressed_ready_i);
72-
end
59+
if (flush_i) begin
60+
compressed_valid_o = 1'b0;
61+
compressed_req_o.instr = '0;
62+
compressed_req_o.hartid = hart_id_i;
7363
end
7464
end
7565

core/cvxif_fu.sv

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,18 @@ module cvxif_fu
5656

5757
assign x_ready_o = 1'b1; // Readyness of cvxif_fu is determined in issue stage by CVXIF issue interface
5858
// Result signals
59-
assign x_valid_o = x_illegal_i && x_valid_i ? 1'b1 : result_valid_i;
59+
assign x_valid_o = x_illegal_i || result_valid_i;
6060
assign x_result_o = result_i.data;
6161
assign x_trans_id_o = x_illegal_i ? x_trans_id_i : result_i.id;
6262
assign x_we_o = result_i.we;
6363
assign x_rd_o = result_i.rd;
6464

6565
// Handling of illegal instruction exception
6666
always_comb begin
67-
x_exception_o = '0; // No exception in this interface
68-
if (x_illegal_i && x_valid_i) begin
69-
x_exception_o.valid = '1;
70-
x_exception_o.cause = riscv::ILLEGAL_INSTR;
71-
if (CVA6Cfg.TvalEn)
72-
x_exception_o.tval = x_off_instr_i; // TODO Optimization : Set exception in IRO.
73-
end
67+
x_exception_o.valid = x_illegal_i;
68+
x_exception_o.cause = x_illegal_i ? riscv::ILLEGAL_INSTR : '0;
69+
if (CVA6Cfg.TvalEn)
70+
x_exception_o.tval = x_off_instr_i; // TODO Optimization : Set exception in IRO.
7471
end
7572

7673
endmodule

0 commit comments

Comments
 (0)