always @(posedge my_clk) begin
if (counter == 10000) begin
counter <= 0;
clk <= ~clk;
end
else begin
clk <= clk;
counter <= counter + 1;
end
end
endmodule
约束文件如下:
#" PlanAhead Generated physical constraints "
NET "c" LOC = H18
#"Created by Constraints Editor (xc5vsx50t-ff1136-1) - 2011/04/01"
NET "my_clk" TNM_NET = my_clk
TIMESPEC TS_my_clk = PERIOD "my_clk" 1 ms HIGH 50% INPUT_JITTER 10 us
#"Created by Constraints Editor (xc5vsx50t-ff1136-1) - 2011/04/02"
OFFSET = OUT 50 ns AFTER "my_clk"
1.intial语句是不可综合的,它只用在测试文件。你要是想对c和counter赋初值,你可以采用复位的方式。例如:
always @(posedge clk,negedge rst)
begin
if(!rst) //一般板子是低电平复位,且是上电就复位
begin
c<=1'b1;
end
else
begin
c<=~c;
end
end
你要是改成500的话,不应该是亮了一下,应该是一直亮的,只是亮度变低。你可以做个仿真先……