Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // next-state logic for read and write pointers
- always @*
- begin
- // successive pointer values
- w_ptr_succ = w_ptr_reg + 1;
- r_ptr_succ = r_ptr_reg + 1;
- // default: keep old values
- w_ptr_next = w_ptr_reg;
- r_ptr_next = r_ptr_reg;
- full_next = full_reg;
- empty_next = empty_reg;
- case ({wr, rd})
- // 2'b00: no op
- 2'b01: // read
- if (~empty_reg) // not empty
- begin
- r_ptr_next = r_ptr_succ;
- full_next = 1'b0;
- if (r_ptr_succ==w_ptr_reg)
- empty_next = 1'b1;
- end
- 2'b10: // write
- if (~full_reg) // not full
- begin
- w_ptr_next = w_ptr_succ ;
- empty_next = 1'b0;
- if (w_ptr_succ==r_ptr_reg)
- full_next = 1'b1;
- end
- 2'b11: // write and read
- begin
- w_ptr_next = w_ptr_succ;
- r_ptr_next = r_ptr_succ;
- end
- endcase
- end
- // output
- assign full = full_reg;
- assign empty = empty_reg;
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement