Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

fallingrain_83

Junior Member level 1
Joined
Jul 24, 2005
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
USA
Activity points
1,450
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
:cry:
 

Help PLZ!! FPGA Clock

If you remove the second always block, the design should basically work as a 2**26 clock divider.
 

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>num[i+1])
begin
temp<=num;
 

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.
 

Re: 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>num[i+1])
begin
temp<=num;

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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top