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.

[Moved] How to count the clock and repeat the process?

Status
Not open for further replies.

haseena

Newbie level 3
Joined
Oct 20, 2005
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,307
Hi
I want to know, how to count the clock pulse and for first 20 cycles it must go high and for next 20 cycles it should go low. Also, this process must repeat like a loop. I want the verilog code/program to execute in spartan 3aN. Iam new to this verilog, and i need your help. thank you in advance
 

Re: How to count the clock and repeat the process?

Use the "forever" verilog construct...
 

Re: How to count the clock and repeat the process?

Use the "forever" verilog construct...


But "forever" keyword can be used if we know the timing of 20 cycles? without using timing units or delays how i should repeat the process? In my code i used "repeat" keyword. I will give you my code here for a reference., so that you can get some idea.thank you in advance sir.


module SQU_WAVE(output reg q,input clk);
reg [7:0] count=0;
always@(posedge clk)
repeat(10)
begin
count=count+1;
if(clk)
q=1;
else
q=0;
end
endmodule
 

Re: How to count the clock and repeat the process?

Hi
I want to know, how to count the clock pulse and for first 20 cycles it must go high and for next 20 cycles it should go low. Also, this process must repeat like a loop. I want the verilog code/program to execute in spartan 3aN. Iam new to this verilog, and i need your help. thank you in advance
1. Poor problem description, must make many assumptions on what you are really trying to accomplish
2. Posted in wrong forum (ASIC) should be in FPGA (Xilinx Spartan 3AN)
3. Asking for code, without showing that you've made any effort.
4. At least you gave a polite thanks.

But "forever" keyword can be used if we know the timing of 20 cycles? without using timing units or delays how i should repeat the process? In my code i used "repeat" keyword. I will give you my code here for a reference., so that you can get some idea.thank you in advance sir.

module SQU_WAVE(output reg q,input clk);
reg [7:0] count=0;
always@(posedge clk)
repeat(10)
begin
count=count+1;
if(clk)
q=1;
else
q=0;
end
endmodule
1. Ah, now we get to see code.
2. This isn't synthesizable Verilog code.
3. Still don't know exactly what you want to accomplish, would have to make many assumptions to give any meaningful help.
4. Should read: http://www.catb.org/~esr/faqs/smart-questions.html so you know how to ask questions the "right" way.

As a complete guess, assuming you have a clock clk that is used to count out the timing of the 20 cycles high and 20 cycles low...
1. create a 6-bit counter that rolls over at a count equal to 39
2. for any count less than 20 output high on q
3. for any count greater than 19 output low on q
4. write code.
5. run simulation.
6. hand in working homework
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
Re: How to count the clock and repeat the process?

1. Poor problem description, must make many assumptions on what you are really trying to accomplish
2. Posted in wrong forum (ASIC) should be in FPGA (Xilinx Spartan 3AN)
3. Asking for code, without showing that you've made any effort.
4. At least you gave a polite thanks.


1. Ah, now we get to see code.
2. This isn't synthesizable Verilog code.
3. Still don't know exactly what you want to accomplish, would have to make many assumptions to give any meaningful help.
4. Should read: http://www.catb.org/~esr/faqs/smart-questions.html so you know how to ask questions the "right" way.

As a complete guess, assuming you have a clock clk that is used to count out the timing of the 20 cycles high and 20 cycles low...
1. create a 6-bit counter that rolls over at a count equal to 39
2. for any count less than 20 output high on q
3. for any count greater than 19 output low on q
4. write code.
5. run simulation.
6. hand in working homework


Thank you for your feedback sir. The thing is I want to generate a square pulse. For that I used clk as input and then I kept output("q") as high for 20 cycles and for next 20 cycles "q" as low. I want this process to be executed repeatedly, so that i will get a square pulse.
Thank you for that last 1 to 6 points:)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top