Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module fifo
- #(
- parameter B=8,
- W=4
- )
- (
- input wire clk, reset,
- input wire rd, wr,
- input wire [B-1:0] w_data,
- output wire empty, full,
- output wire [B-1:0] r_data
- );
- // signal declaration
- reg [B-1:0] array_reg [2**W-1:0]; // register array
- reg [W-1:0] w_ptr_reg, w_ptr_next, w_ptr_succ;
- reg [W-1:0] r_ptr_reg, r_ptr_next, r_ptr_succ;
- reg full_reg, empty_reg, full_next, empty_next;
- wire wr_en;
- // body
- // register file write operation
- always @(posedge clk)
- if (wr_en)
- array_reg [w_ptr_reg] <= w_data;
- // register file read operation
- assign r_data = array_reg[r_ptr_reg];
- // write enabled only when FIFO is not full
- assign wr_en = wr & ~full_reg;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement