Skip to content
Snippets Groups Projects
Commit cd7dabb4 authored by Alban Gruin's avatar Alban Gruin
Browse files

sras: size improvements


Signed-off-by: default avatarAlban Gruin <alban.gruin@irit.fr>
parent e17128ee
Branches
No related tags found
No related merge requests found
...@@ -54,6 +54,10 @@ module sras #( ...@@ -54,6 +54,10 @@ module sras #(
logic overflow; logic overflow;
assign overflow = |ovf_counter_q[ptr_spec_q]; assign overflow = |ovf_counter_q[ptr_spec_q];
logic [SZ_OVF-1:0] ovf_plus_one, ovf_minus_one;
assign ovf_plus_one = ovf_counter_q[ptr_spec_q] + 1'b1;
assign ovf_minus_one = ovf_counter_q[ptr_spec_q] - 1'b1;
always_comb begin always_comb begin
ovf_counter_d = ovf_counter_q; ovf_counter_d = ovf_counter_q;
...@@ -62,23 +66,23 @@ module sras #( ...@@ -62,23 +66,23 @@ module sras #(
end else if (!bad_spec_i) begin end else if (!bad_spec_i) begin
if (push_i && !pop_i) begin if (push_i && !pop_i) begin
if (overflow || prev_plus_one == '0 || pp_plus_one == '0) begin if (overflow || prev_plus_one == '0 || pp_plus_one == '0) begin
ovf_counter_d[ptr_spec_d] = ovf_counter_q[ptr_spec_q] + 1'b1; ovf_counter_d[ptr_spec_d] = ovf_plus_one;
end end
if ((prev_plus_one == '0 || pp_plus_one == '0) && begin_spec_i) begin if ((prev_plus_one == '0 || pp_plus_one == '0) && begin_spec_i) begin
ovf_counter_d[ptr_spec_q] = ovf_counter_q[ptr_spec_q] + 1'b1; ovf_counter_d[ptr_spec_q] = ovf_plus_one;
end end
end else if (!push_i && pop_i) begin end else if (!push_i && pop_i) begin
if (ovf_counter_q[ptr_spec_q] == '0) begin if (ovf_counter_q[ptr_spec_q] == '0) begin
ovf_counter_d[ptr_spec_d] = '0; // ovf_counter_d[ptr_spec_d] = ovf_counter_q[ptr_spec_q]; ovf_counter_d[ptr_spec_d] = ovf_counter_q[ptr_spec_q];
end else begin end else begin
ovf_counter_d[ptr_spec_d] = ovf_counter_q[ptr_spec_q] - 1'b1; ovf_counter_d[ptr_spec_d] = ovf_minus_one;
end end
end else if (begin_spec_i) begin end else if (begin_spec_i) begin
ovf_counter_d[ptr_spec_d] = ovf_counter_q[ptr_spec_q]; ovf_counter_d[ptr_spec_d] = ovf_counter_q[ptr_spec_q];
end end
end else if (bad_spec_i && resolved_type_i == ariane_pkg::Return && ovf_counter_q[ptr_spec_q] != '0) begin end else if (bad_spec_i && resolved_type_i == ariane_pkg::Return && ovf_counter_q[ptr_spec_q] != '0) begin
ovf_counter_d[ptr_spec_d] = ovf_counter_q[ptr_spec_q] - 1'b1; ovf_counter_d[ptr_spec_d] = ovf_minus_one;
end end
end end
...@@ -112,7 +116,8 @@ module sras #( ...@@ -112,7 +116,8 @@ module sras #(
assign data_o = stack_q[previous_tos_addr][previous_tos]; assign data_o = stack_q[previous_tos_addr][previous_tos];
ariane_pkg::ras_t to_push; ariane_pkg::ras_t to_push;
assign to_push.ra = (can_push) ? data_i : 0; assign to_push.ra = data_i;
// assign to_push.ra = (can_push) ? data_i : 0;
assign to_push.valid = can_push; assign to_push.valid = can_push;
ariane_pkg::ras_t [DEPTH-1:0] new_stack, prev_stack; ariane_pkg::ras_t [DEPTH-1:0] new_stack, prev_stack;
...@@ -126,19 +131,14 @@ module sras #( ...@@ -126,19 +131,14 @@ module sras #(
if (can_pop) begin if (can_pop) begin
new_stack[previous_tos] = to_push; new_stack[previous_tos] = to_push;
end end else if (can_push) begin
if (can_push) begin
new_stack[prev_plus_one] = to_push; new_stack[prev_plus_one] = to_push;
end end
end end
always_comb begin for (genvar i = 0; i < DEPTH; i++) begin
prev_stack = stack_q[ptr_spec_q]; assign prev_stack[i] = (i == pp_plus_one && can_push && begin_spec_i) ? to_push :
stack_q[ptr_spec_q][i];
if (can_push && begin_spec_i) begin
prev_stack[pp_plus_one] = to_push;
end
end end
for (genvar i = 0; i < SpecDepth; i++) begin for (genvar i = 0; i < SpecDepth; i++) begin
...@@ -148,16 +148,16 @@ module sras #( ...@@ -148,16 +148,16 @@ module sras #(
stack_q[i]; stack_q[i];
end end
initial stack_q = '0; // initial stack_q <= '0;
always_ff @(posedge clk_i or negedge rst_ni) begin always_ff @(posedge clk_i or negedge rst_ni) begin
stack_q <= stack_d;
if (~rst_ni) begin if (~rst_ni) begin
stack_q <= '0;
ptr_spec_q <= '0; ptr_spec_q <= '0;
ptr_backup_q <= '0; ptr_backup_q <= '0;
tos_q <= '0; tos_q <= '0;
ovf_counter_q <= '0; ovf_counter_q <= '0;
end else begin end else begin
stack_q <= stack_d;
ptr_spec_q <= ptr_spec_d; ptr_spec_q <= ptr_spec_d;
ptr_backup_q <= ptr_backup_d; ptr_backup_q <= ptr_backup_d;
tos_q <= tos_d; tos_q <= tos_d;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment