- if (!in_r && in_a && !inAmount_r) in_a <= 0;
- if (!inAmount_r && inAmount_a) inAmount_a <= 0;
- if (out_r && out_a) out_r <= 0;
- if (in_r && !in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin
- in_a <= 1;
- out_d <= in_d;
- shamt <= 0;
- end else if (in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin
- if (!shamt_eq) begin
- out_d <= { out_d[`DATAWIDTH-2:0], out_d[`DATAWIDTH-1] };
- shamt <= shamt+1;
+ `cleanup
+ if (`in_full && `inAmount_full && `out_empty) begin
+ if (!full) begin
+ out_d <= { 1'b0, in_d };
+ shamt <= 0;
+ full <= 1;
+ end else if (!shamt_eq) begin
+ out_d <= { out_d[0], out_d[0], out_d[`WORDWIDTH-1:1] };
+ shamt <= shamt+1;