Created
June 25, 2020 19:05
-
-
Save rschlaikjer/f2095e6d90f37c29c566a3f0bbf70161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`define CLOCK_HZ 54_000_000 | |
module foo(input wire i_clk); | |
localparam PRESCALER = `CLOCK_HZ / 50; | |
reg [$clog2(PRESCALER)-1:0] counter; | |
always @(posedge i_clk) begin | |
// Comparison generates warning: | |
// Operator LT expects 32 or 26 bits on the LHS, but LHS's VARREF 'counter' generates 21 bits. | |
if (counter < PRESCALER) begin | |
counter <= counter + 1; | |
end else begin | |
counter <= 0; | |
end | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment