Skip to content

Instantly share code, notes, and snippets.

@axayjha
Created April 8, 2019 19:50
Show Gist options
  • Save axayjha/fb5190638f59249d31c4bfc63043d90f to your computer and use it in GitHub Desktop.
Save axayjha/fb5190638f59249d31c4bfc63043d90f to your computer and use it in GitHub Desktop.
module counter (dout, din, ld, dec, clk);
input [15:0] din;
input ld, dec, clk;
output reg [15:0] dout;
always @(posedge clk)
if (ld) dout <= din;
else if (dec) dout <= dout - 1;
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment