Skip to content

Commit

Permalink
Synthesis fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thommythomaso committed Mar 6, 2024
1 parent e61e2c1 commit dcf84ce
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/bvt_arb_tree.sv
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,59 @@ module bvt_arb_tree #(
/// type holding the virtual time of every input
typedef logic [TimeWidth-1:0] time_t;

/// type holding the prio sum
localparam int unsigned PrioSumWidth = PrioWidth + IdxWidth + 32'd1;
typedef logic [PrioSumWidth-1:0] priority_sum_t;

// time counter storage
time_t [NumIn-1:0] virtual_time_d, virtual_time_q;

// valid signal
logic [NumIn-1:0] valid;

// get minimal time
min_max_tree #(
.NumIn ( NumIn ),
.DataWidth ( TimeWidth )
) i_min_max_tree (
.data_i ( virtual_time_q ),
.valid_i ( req_i ),
.valid_i ( valid ),
.is_max_i ( 1'b0 ),
.data_o ( /* NC */ ),
.valid_o ( req_o ),
.idx_o ( idx_o )
);

// hold the sum of all prios
priority_sum_t priority_sum;


// calc the priority sum
always_comb begin : proc_calc_sum
priority_sum = '0;
for (int unsigned i = 0; i < NumIn; i++) begin
priority_sum = priority_sum + prio_i[i];
end
end


// not all are valid
always_comb begin : gen_valid
valid = '0;
for (int unsigned i = 0; i < NumIn; i++) begin
valid[i] = req_i[i] & (virtual_time_q[i] < (NumIn * prio_i[i] / priority_sum));
end
end


// update counters
always_comb begin : proc_next_counters
// default: add time to the counters
for (int unsigned i = 0; i < NumIn; i++) begin
virtual_time_d[i] = virtual_time_q[i] + prio_i[i];
end

// reset the counter that was joust handshacked
// reset the counter that was just handshacked
if (req_o & gnt_i) begin
virtual_time_d[idx_o] = '0;
end
Expand Down

0 comments on commit dcf84ce

Please sign in to comment.