Skip to content

Instantly share code, notes, and snippets.

@ZipCPU
Created January 6, 2020 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZipCPU/249a17178a814065b534cc290b41da74 to your computer and use it in GitHub Desktop.
Save ZipCPU/249a17178a814065b534cc290b41da74 to your computer and use it in GitHub Desktop.
initial counts = 0;
always @(posedge i_clk)
if (i_reset)
// Tare the counter by setting it to zero on any reset
counts <= 0;
else begin
case({lst_a, lst_b, ck_a, ck_b})
4'h1: counts <= counts + 1'b1;
4'h7: counts <= counts + 1'b1;
4'he: counts <= counts + 1'b1;
4'h8: counts <= counts + 1'b1;
//
4'h4: counts <= counts - 1'b1;
4'hd: counts <= counts - 1'b1;
4'hb: counts <= counts - 1'b1;
4'h2: counts <= counts - 1'b1;
default: begin end // 0, 3, 5, 6, 9, a, c, f
endcase
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment