Author Topic: How to add time delay in verilog code  (Read 3273 times)

0 Members and 1 Guest are viewing this topic.

Offline gauravmpTopic starter

  • Regular Contributor
  • *
  • Posts: 77
  • Country: us
How to add time delay in verilog code
« on: June 06, 2016, 09:57:59 pm »
Hi,

I'm wondering how you could add delay in verilog code for an FPGA. I understand, I can add a for loop and have it go for a number of cycles, but is there a better way. I'm more so looking for delays to a few seconds.

Can I have another clock go at a frequency very slow so that I could do this. If so, how could I implement it?

I'm using Altera MAX 10 FPGA and Quartus II 15.0

Thanks
 

Online John_ITIC

  • Frequent Contributor
  • **
  • Posts: 513
  • Country: us
  • ITIC Protocol Analyzers
    • International Test Instruments Corporation
Re: How to add time delay in verilog code
« Reply #1 on: June 06, 2016, 10:31:30 pm »
No, there's no better way. A digital, synchronous design uses counters to create delay. You can simply count up an integer or reg and act when reached whatever delay you need.
Pocket-Sized USB 2.0 LS/FS/HS Protocol Analyzer Model 1480A with OTG decoding.
Pocket-sized PCI Express 1.1 Protocol Analyzer Model 2500A. 2.5 Gbps with x1, x2 and x4 lane widths.
https://www.internationaltestinstruments.com
 
The following users thanked this post: gauravmp

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13745
  • Country: gb
    • Mike's Electric Stuff
Re: How to add time delay in verilog code
« Reply #2 on: June 06, 2016, 11:07:00 pm »
You must always keep in mind that you're describing hardware, not writing a program.
So you need to think how you would implement a delay in hardware - make a counter  (or maybe a shift-register - that can sometimes be more efficient for small counts), decide how many bits it needs, how to clock it, reset it and detect when it gets to the value you want.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: gauravmp

Offline helius

  • Super Contributor
  • ***
  • Posts: 3640
  • Country: us
Re: How to add time delay in verilog code
« Reply #3 on: June 06, 2016, 11:40:41 pm »
Of course, there's nothing preventing you from using a software approach in a FPGA. You simply need to build a machine in HDL that interprets the code you want to write. Or select an existing soft core that matches the needed capabilities.
 
The following users thanked this post: gauravmp

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: How to add time delay in verilog code
« Reply #4 on: June 07, 2016, 05:39:07 am »
Output it to external pins and use external hardware to delay the signal?
This might be feasible if the time is long and you want to save FPGA resources...?
[2c]
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 
The following users thanked this post: gauravmp

Offline gauravmpTopic starter

  • Regular Contributor
  • *
  • Posts: 77
  • Country: us
Re: How to add time delay in verilog code
« Reply #5 on: June 07, 2016, 02:53:25 pm »
Thanks guys! was able to do it!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf