Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- always_ff @(posedge clk) begin
- if (!rst_n) begin
- in_idx <= '0; // input pointer
- out_idx <= '0; // output pointer
- bitcnt <= '0; // number of stored bits
- out_vld <= 1'b0;
- end
- else begin
- bitcnt <= next_bitcnt;
- if (in_vld) begin
- store[ in_idx +: 6] <= in;
- in_idx <= (in_idx + 6) % STORE_BITS;
- end
- out_vld <= (bitcnt >= 4 || in_vld);
- if (out_vld) begin
- out_idx <= (out_idx + 4) % STORE_BITS;
- end
- end
- end
- always_comb begin
- next_bitcnt = bitcnt;
- if (in_vld) begin
- next_bitcnt += 6;
- end
- if (bitcnt >= 4 || in_vld) begin
- next_bitcnt -= 4;
- end
- end
- assign out = store[ out_idx +: 4 ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement