-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hw: CSR-based hardware cluster barrier
- Loading branch information
Showing
9 changed files
with
66 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,37 @@ | ||
// Copyright 2020 ETH Zurich and University of Bologna. | ||
// Copyright 2023 ETH Zurich and University of Bologna. | ||
// Solderpad Hardware License, Version 0.51, see LICENSE for details. | ||
// SPDX-License-Identifier: SHL-0.51 | ||
|
||
// Author: Florian Zaruba <[email protected]> | ||
// Author: Fabian Schuiki <[email protected]> | ||
// | ||
// Author: Luca Colagrande <[email protected]> | ||
|
||
`include "common_cells/registers.svh" | ||
|
||
/// Hardware barrier to synchronize all cores in a cluster. | ||
module snitch_barrier | ||
import snitch_pkg::*; | ||
import snitch_cluster_peripheral_reg_pkg::*; | ||
#( | ||
parameter int unsigned AddrWidth = 0, | ||
parameter int NrPorts = 0, | ||
parameter type dreq_t = logic, | ||
parameter type drsp_t = logic, | ||
/// Derived parameter *Do not override* | ||
parameter type addr_t = logic [AddrWidth-1:0] | ||
module snitch_barrier #( | ||
parameter int NrCores = 0 | ||
) ( | ||
input logic clk_i, | ||
input logic rst_ni, | ||
input dreq_t [NrPorts-1:0] in_req_i, | ||
output drsp_t [NrPorts-1:0] in_rsp_o, | ||
|
||
output dreq_t [NrPorts-1:0] out_req_o, | ||
input drsp_t [NrPorts-1:0] out_rsp_i, | ||
|
||
input addr_t cluster_periph_start_address_i | ||
input logic clk_i, | ||
input logic rst_ni, | ||
input logic [NrCores-1:0] barrier_i, | ||
output logic barrier_o | ||
); | ||
|
||
typedef enum logic [1:0] { | ||
Idle, | ||
Wait, | ||
Take | ||
} barrier_state_e; | ||
barrier_state_e [NrPorts-1:0] state_d, state_q; | ||
logic [NrPorts-1:0] is_barrier; | ||
logic take_barrier; | ||
logic [NrCores-1:0] arrival_d, arrival_q; | ||
|
||
generate | ||
for (genvar i = 0; i < NrCores; i++) begin : gen_arrival_bit | ||
|
||
assign take_barrier = &is_barrier; | ||
`FF(arrival_q[i], arrival_d[i], 1'b0, clk_i, rst_ni) | ||
|
||
always_comb begin | ||
state_d = state_q; | ||
is_barrier = '0; | ||
out_req_o = in_req_i; | ||
in_rsp_o = out_rsp_i; | ||
always_comb begin | ||
if (barrier_o) arrival_d[i] = 1'b0; | ||
else if (barrier_i[i]) arrival_d[i] = 1'b1; | ||
else arrival_d[i] = arrival_q[i]; | ||
end | ||
|
||
for (int i = 0; i < NrPorts; i++) begin | ||
case (state_q[i]) | ||
Idle: begin | ||
if (in_req_i[i].q_valid && | ||
(in_req_i[i].q.addr == | ||
cluster_periph_start_address_i + | ||
SNITCH_CLUSTER_PERIPHERAL_HW_BARRIER_OFFSET)) begin | ||
state_d[i] = Wait; | ||
out_req_o[i].q_valid = 0; | ||
in_rsp_o[i].q_ready = 0; | ||
end | ||
end | ||
Wait: begin | ||
is_barrier[i] = 1; | ||
out_req_o[i].q_valid = 0; | ||
in_rsp_o[i].q_ready = 0; | ||
if (take_barrier) state_d[i] = Take; | ||
end | ||
Take: begin | ||
if (out_req_o[i].q_valid && in_rsp_o[i].q_ready) state_d[i] = Idle; | ||
end | ||
default: state_d[i] = Idle; | ||
endcase | ||
end | ||
end | ||
endgenerate | ||
|
||
for (genvar i = 0; i < NrPorts; i++) begin : gen_ff | ||
`FFARN(state_q[i], state_d[i], Idle, clk_i, rst_ni) | ||
end | ||
assign barrier_o = &arrival_q; | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters