Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
15334 Discussions

Best practices for verifying PWM (measuring time)...

Altera_Forum
Honored Contributor II
969 Views

Folks: 

I am writing a testbench for a pulse-width modulator and wanted to check for several hundred different values. I figured I'd use a loop for each value, but I'm not sure of the best way to confirm (using assert) that the pulse is the correct length for each value. I was planning on just using a "wait until" and then "now - output'last_event" but I want to use the loop index in a comparison with a time value, which isn't going to work. I suppose I could use some sort of inner loop that counted the clock cycles, but that seems very clunky. 

I'd appreciate any recommendations or links to good resources.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
96 Views

Perhaps this post might help... 

https://alteraforum.com/forum/showthread.php?t=6493 

 

Combine that with a 'wait until {rising/falling edge(signal)}' and you should be able to automatically measure the mark or space width. 

 

Cheers, 

Alex
Altera_Forum
Honored Contributor II
96 Views

You can use the 'stable' VHDL attribute with a value consistent with the pwd command. 

Example: 

assert pwm_out'stable(TIME) report "signal is not stable during the expected time" severity error;
Reply