Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21615 Discussions

Live Control of PWM Outputs (need advice)

Altera_Forum
Honored Contributor II
1,009 Views

I've been searching around google for how to implement what I need but I'm not understanding the underlying ideas as a whole, and I'm hoping for some explanation and advice. 

 

My project: Generate several PWM outputs. The frequency/phase/dutycycle should all be controllable WHILE the FPGA is running (if this is even possible?).  

 

My hardware: Altera DE0 Nano board 

 

What I understand so far (I think): 

I need to make some sort of live prompt on the screen where the user enters values for the freq/phase/dutycycle. I'm assuming this requires underlying C/C++ to read the keystrokes.  

I've written Verilog that uses a counter to turn the PWM outputs on/off according to a duty cycle parameter, as well as a shift register to introduce phase shifting to the outputs. 

I don't understand how to use keyboard input or even C/C++ code to change the Verilog module's parameters as the FPGA is running.  

The closest thing I can think of is using a NiosII with a C software application, but this would require the user to rebuild and run after every parameter is changed. 

Also, I assume there is some sort of Altera IP for PWM outputs, but my searches have given me nothing. 

 

 

I would really appreciate at least a high level explanation of how one can control Verilog parameters while the FPGA is running and how C code in NIOSII interacts with a Verilog module. 

 

Thank you for any help you can give!
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
318 Views

If you're not already using Qsys/SOPC Builder, then probably the easiest method is to use the In-System Sources and Probes (http://www.altera.com/literature/hb/qts/qts_qii53021.pdf). This allows you instantiate a megafunction which you connect to your control registers, and allows you to easily modify their content using a PC GUI that Altera provides. 

 

Otherwise, you should consider adding an Avalon-MM Slave interface to your block and packaging it as a Qsys component. This would allow you to write NIOS C software to modify it if you wanted to, or it would also allow you to use the System Console (another Altera PC GUI) to read/write your register values; you can even create simple GUI's using the Dashboard functionality of that tool. An alternate approach would be to instantiate a series of GPIO blocks and connect them to the control registers of your block (instead of adding the Avalon-MM Slave port to your block). 

 

From your description though, it sounds like In-System Sources and Probes is both less work and adequate for what you are trying to accomplish.
0 Kudos
Reply