moonnightingale
Full Member level 6
Hi all, Today i finally executed my kit and now its LEDs are glowing after 4 seconds. I am attaching the code. kindly see it and tell me how can i further make it good code. At present the code is not giving any warning.
Initiall the code gave 10 warnings but i was able to remove all warnings.
Just see the code and tell me can i further refine it.
The two LEDs glow after 4 seconds when select is 0. When select is one, LED get off.
module clock(zero,two,select,clk);
output zero,two;
input select,clk;
reg zero,two;
reg [40:0] cnt;
always@(posedge clk)
begin
if (select==0)
cnt<=cnt+1;
else
cnt<=5'b0;
if (cnt[40:0]==40'd200000000) // Since the Clk is of 50 MHz, so it means it will execute always loop
// 50000000 times in one second. since i want LEDs to glow after 4 seconds
// so i declared counter equivalent to 200000000 = 50000000 x 4.
begin
two=1'b1;
zero=1'b1;
end
if (select==1)
begin
two=1'b0;
zero=1'b0;
end
end
endmodule
UCF file
NET "select" LOC = "N17" | IOSTANDARD = LVTTL | PULLUP ; //For Select Switch
NET "zero" LOC = "F12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ; //for minute
NET "two" LOC = "E11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ; //for hours
NET "clk" LOC = "C9" | IOSTANDARD = LVCMOS33 ;
Lastly The spatran manual says
# ==== Clock inputs (CLK) ====
NET "CLK_50MHZ" LOC = "C9" | IOSTANDARD = LVCMOS33 ;
# Define clock period for 50 MHz oscillator (40%/60% duty-cycle)
NET "CLK_50MHZ" PERIOD = 20.0ns HIGH 40%; // What is this
NET "CLK_AUX" LOC = "B8" | IOSTANDARD = LVCMOS33 ; // What is aux clk and what is its freq. Can i use this clk
NET "CLK_SMA" LOC = "A10" | IOSTANDARD = LVCMOS33 ; // Whats is SMA clock what is its freq. Can i use this clk
Initiall the code gave 10 warnings but i was able to remove all warnings.
Just see the code and tell me can i further refine it.
The two LEDs glow after 4 seconds when select is 0. When select is one, LED get off.
module clock(zero,two,select,clk);
output zero,two;
input select,clk;
reg zero,two;
reg [40:0] cnt;
always@(posedge clk)
begin
if (select==0)
cnt<=cnt+1;
else
cnt<=5'b0;
if (cnt[40:0]==40'd200000000) // Since the Clk is of 50 MHz, so it means it will execute always loop
// 50000000 times in one second. since i want LEDs to glow after 4 seconds
// so i declared counter equivalent to 200000000 = 50000000 x 4.
begin
two=1'b1;
zero=1'b1;
end
if (select==1)
begin
two=1'b0;
zero=1'b0;
end
end
endmodule
UCF file
NET "select" LOC = "N17" | IOSTANDARD = LVTTL | PULLUP ; //For Select Switch
NET "zero" LOC = "F12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ; //for minute
NET "two" LOC = "E11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ; //for hours
NET "clk" LOC = "C9" | IOSTANDARD = LVCMOS33 ;
Lastly The spatran manual says
# ==== Clock inputs (CLK) ====
NET "CLK_50MHZ" LOC = "C9" | IOSTANDARD = LVCMOS33 ;
# Define clock period for 50 MHz oscillator (40%/60% duty-cycle)
NET "CLK_50MHZ" PERIOD = 20.0ns HIGH 40%; // What is this
NET "CLK_AUX" LOC = "B8" | IOSTANDARD = LVCMOS33 ; // What is aux clk and what is its freq. Can i use this clk
NET "CLK_SMA" LOC = "A10" | IOSTANDARD = LVCMOS33 ; // Whats is SMA clock what is its freq. Can i use this clk