Advertisement
AlexanderAntonov

Untitled

Oct 17th, 2022
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module fifo
  2.     #(
  3.     parameter B=8,
  4.     W=4
  5.     )
  6. (
  7. input wire clk, reset,
  8. input wire rd, wr,
  9. input wire [B-1:0] w_data,
  10. output wire empty, full,
  11. output wire [B-1:0] r_data
  12. );
  13. // signal declaration
  14. reg [B-1:0] array_reg [2**W-1:0]; // register array
  15. reg [W-1:0] w_ptr_reg, w_ptr_next, w_ptr_succ;
  16. reg [W-1:0] r_ptr_reg, r_ptr_next, r_ptr_succ;
  17. reg full_reg, empty_reg, full_next, empty_next;
  18. wire wr_en;
  19.  
  20. // body
  21. // register file write operation
  22. always @(posedge clk)
  23.     if (wr_en)
  24.         array_reg [w_ptr_reg] <= w_data;
  25. // register file read operation
  26. assign r_data = array_reg[r_ptr_reg];
  27. // write enabled only when FIFO is not full
  28. assign wr_en = wr & ~full_reg;
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement