I am trying to create a 1 Hz clock signal on a Lattice ICE40 FPGA. I am writing my code in Verilog and using the Lattice Radiant software. This 1 Hz clock signal is going to be used to create a square wave.
However, I don't get any output, either from the pin the clock signal is supposed to be on or from the pin that is supposed to output a square wave. I am sure I am checking the correct pins. I am also sure the code is downloading to the board. I believe the FPGA is not actually creating the clock signal for some reason.
Here is my code:
module square (clk, x, y, z);
// Inputs and Outputs
input clk; // The clock signal
output x, y, z; // The square wave output
// Type Declaration
reg x; // x is a register
// Initialize x
initial
begin
x = 0;
end
// Run each time the clock transitions from low to high
always @(posedge clk)
begin
x = !x; // Flip x
end
// Outputs used to confirm the program is running
assign y = 0; //39A
assign z = 1; //41A
endmodule
And here is my synthesis constraint file (.ldc):
create_clock -name {clk} -period 1000000000 [get_ports clk]
The period is defined in nanoseconds, so this a 1 Hz clock.
Thank you.
clk
coming from? Really all yoursquare
module does (besides the staticy
andz
assignments) is makex
a copy ofclk
, whereclk
is expected to be a proper clock andx
is the output of a LUT or register (if it's not synthesized away entirely). Defining acreate_clock
constraint does not magically create a clock at the specified frequency.create_clock
is just a way to inform STA and routing processes of the characteristics of the clock. You still need to actually generate the clock somewhere. – Kevin Krusex
becomes half the frequency ofclk
. The rest of the issues still stand, you need to makeclk
somehow. – Kevin Kruse