electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

Help PLZ!! FPGA Clock- creating a clock from the input clock


Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design -> Help PLZ!! FPGA Clock- creating a clock from the input clock
Author Message
fallingrain_83



Joined: 24 Jul 2005
Posts: 17
Location: USA


Post04 Mar 2009 18:45   

Help PLZ!! FPGA Clock


Hi all
I want to creat a clock from the input clock that has less frequency
I tried this, however it is not working
module(clk,...)
input clk; // connected to C9 pin of Spartan3 XC3S200
reg [0:25] count;
reg clk2;

allways @(posedge clk)
begin
count<=count + 1;
clk2 <= count[25];
end

allways @(clk2)
begin
clk2<=0;
,.....
end
Crying or Very sad
Back to top
FvM



Joined: 22 Jan 2008
Posts: 5161
Helped: 767
Location: Bochum, Germany


Post04 Mar 2009 19:39   

Help PLZ!! FPGA Clock


If you remove the second always block, the design should basically work as a 2**26 clock divider.
Back to top
Google
AdSense
Google Adsense




Post04 Mar 2009 19:39   

Ads




Back to top
fallingrain_83



Joined: 24 Jul 2005
Posts: 17
Location: USA


Post04 Mar 2009 20:30   

Help PLZ!! FPGA Clock


but I have to do s.th in my always block
if I remove that I have to chek clk2 by if and I have an error with this syntax:
lways @(posedge clk)
begin
count <= count + 1;
clk2 <= count[25];
end;

if (clk2) //// ERROR:line 49 expecting 'endmodule', found 'if'
begin

clk2 <= 0;
if (i<9)
begin
if (num[i]>num[i+1])
begin
temp<=num[i];
Back to top
FvM



Joined: 22 Jan 2008
Posts: 5161
Helped: 767
Location: Bochum, Germany


Post04 Mar 2009 22:27   

Help PLZ!! FPGA Clock


At least you have to remove clk2 <= 0, it's causing a multiple source error otherwise. The reg clk2 can be set in one always block only. Missing endmodule is another issue of course. You showed just some snippets, I didn't check the overall syntax, but it has to comply with Verilog rules as well.

I you think, clk2 <= 0 is meaningful for your code, you have to redesign the first always respectively. You can use multiple concurrent assignment inside an always block (the last wins), so it would be possible within the first one.
Back to top
yanzixuan



Joined: 26 Feb 2009
Posts: 18
Helped: 1


Post05 Mar 2009 5:10   

Re: Help PLZ!! FPGA Clock


Quote:

but I have to do s.th in my always block
if I remove that I have to chek clk2 by if and I have an error with this syntax:
lways @(posedge clk)
begin
count <= count + 1;
clk2 <= count[25];
end;

if (clk2) //// ERROR:line 49 expecting 'endmodule', found 'if'
begin

clk2 <= 0;
if (i<9)
begin
if (num[i]>num[i+1])
begin
temp<=num[i];

if can only be used in "always" or "initial" block in RTL.
if you want to do that ,you can use "assign";
for example:
Code:

wire a,b;
assign a = (b) ? 1: 0;

it equal to:
if(b == 1)
a = 1;
else
a = 0
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design -> Help PLZ!! FPGA Clock- creating a clock from the input clock
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
Generate 27 MHz clock from a 40 MHz input clock on a FPGA (4)
UP3 cpu clock setting - the clock input is 100MHZ (1)
Generating a faster clock from the source clock.... (1)
[HELP] How to get a 32K clock from a 48M clock? (8)
May a CPLD have 3 clock input? these clock is not relevant. (5)
can we copy the CLOCK SIGNAL from fpga pin to LEDS on fpga?? (2)
how to tranfer a pulse from a clock domain to another clock? (1)
How can i balance the clock latency in different gated clock (5)
when clock and reset are on the same clock edge . (6)
need help, how about gate-clock and MUX-clock? (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS