Verilog 无法在Lattice ICE40 FPGA上创建时钟信号
我试图在Lattice ICE40 FPGA上创建1 Hz时钟信号。我正在用Verilog编写代码,并使用Lattice Radiant软件。这个1Hz的时钟信号将被用来产生一个方波 然而,我并没有得到任何输出,无论是从时钟信号应该打开的管脚还是从应该输出方波的管脚。我确信我正在检查正确的针脚。我也确信代码正在下载到电路板上。我相信,由于某种原因,FPGA实际上并没有产生时钟信号 这是我的密码:Verilog 无法在Lattice ICE40 FPGA上创建时钟信号,verilog,fpga,clock,lattice,ice40,Verilog,Fpga,Clock,Lattice,Ice40,我试图在Lattice ICE40 FPGA上创建1 Hz时钟信号。我正在用Verilog编写代码,并使用Lattice Radiant软件。这个1Hz的时钟信号将被用来产生一个方波 然而,我并没有得到任何输出,无论是从时钟信号应该打开的管脚还是从应该输出方波的管脚。我确信我正在检查正确的针脚。我也确信代码正在下载到电路板上。我相信,由于某种原因,FPGA实际上并没有产生时钟信号 这是我的密码: module square (clk, x, y, z); // Inputs and Outpu
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
这是我的合成约束文件(.ldc):
周期定义为纳秒,因此这是一个1Hz的时钟
谢谢。谢谢大家。我没有意识到我需要自己创造时钟。我使用高速振荡器功能创建了一个时钟:
// Initialize the high speed oscillator
HSOSC clock (
.CLKHFEN(1'b1), // Enable the output
.CLKHFPU(1'b1), // Power up the oscillator
.CLKHF(clk) // Oscillator output
);
// Divide the oscillator down to 6 MHz
defparam clock.CLKHF_DIV = "0b11";
而且它似乎在工作。clk的
clk
来自哪里?实际上,您的square
模块所做的(除了静态y
和z
赋值之外)都是将x
制作成clk
的副本,其中clk
被认为是正确的时钟,x
是LUT或寄存器的输出(如果它没有完全合成)。定义create_clock
约束不会神奇地以指定频率创建时钟create_clock
只是通知STA和路由进程时钟特性的一种方式。您仍然需要在某个地方实际生成时钟。如果您想在FPGA上创建时钟,则需要从时钟源派生时钟。开发板上将有一个振荡器,如20MHz。你可以将20兆赫的频率分成你想要的频率,或者用PLL从中创建一个新的频率。因为对评论的编辑是时间选通的:我错了x
变为clk
频率的一半。其余问题仍然存在,您需要以某种方式使clk
。
// Initialize the high speed oscillator
HSOSC clock (
.CLKHFEN(1'b1), // Enable the output
.CLKHFPU(1'b1), // Power up the oscillator
.CLKHF(clk) // Oscillator output
);
// Divide the oscillator down to 6 MHz
defparam clock.CLKHF_DIV = "0b11";