I'm working on a Verilog module where I want to add a clock that is able to be changed through frequency values. I tried referencing two variables as integers, assigned the first variable [frequency] a number that corresponds to the frequency value (in MHz), and I used that variable's name to do math operations to get the value of the second variable [clk_period]. It doesn't let me though.
I have the following code:
integer frequency = 100; //in MHz
integer clk_period = (1/(frequency*1e6))*1e9; // 1/freq = clk_prd (in seconds) * 10^9 (in nanoseconds)
and this is the error I get:
error: A reference to a wire or reg (`frequency') is not allowed in a constant expression.
I haven't referenced 'frequency' as a wire or a reg, rather as integer. Is this feature (using an integer to assign a value to another integer) unavailable, or am I doing something wrong here?