Skip to content

Instantly share code, notes, and snippets.

@olofk
Created September 30, 2019 11:51
Show Gist options
  • Select an option

  • Save olofk/f6e004d7381dbbf13de185d112a8a481 to your computer and use it in GitHub Desktop.

Select an option

Save olofk/f6e004d7381dbbf13de185d112a8a481 to your computer and use it in GitHub Desktop.
always @ (posedge clk)
begin
if(write & ~full)
fifo[write_pointer&{CNT_WIDTH-2{clear}}] <= data_in;
end
always @ (posedge clk)
begin
data_out <= fifo[read_pointer&{CNT_WIDTH-2{clear}}];
end
@petergust

Copy link
Copy Markdown

CNT_WIDTH-2{clear} = {clear,clear,...,clear}
write_pointer & {clear,clear,...,clear} is {0,0,...,0} when clear=0, otherwise write_pointer.
Use !clear instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment