SHARE
TWEET

Untitled

a guest Aug 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. always_ff @(posedge clk) begin
  2.   if (!rst_n) begin
  3.     in_idx <= '0;  // input pointer
  4.     out_idx <= '0; // output pointer
  5.     bitcnt <= '0;  // number of stored bits
  6.     out_vld <= 1'b0;
  7.   end
  8.   else begin
  9.     bitcnt <= next_bitcnt;
  10.     if (in_vld) begin
  11.       store[ in_idx +: 6] <= in;
  12.       in_idx <= (in_idx + 6) % STORE_BITS;
  13.     end
  14.     out_vld <= (bitcnt >= 4 || in_vld);
  15.     if (out_vld) begin
  16.       out_idx <= (out_idx + 4) % STORE_BITS;
  17.     end
  18.   end
  19. end
  20.  
  21. always_comb begin
  22.   next_bitcnt = bitcnt;
  23.   if (in_vld) begin
  24.     next_bitcnt += 6;
  25.   end
  26.   if (bitcnt >= 4 || in_vld) begin
  27.     next_bitcnt -= 4;
  28.   end
  29. end
  30.  
  31. assign out = store[ out_idx +: 4 ];
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top