Medium · Data converters05. Build a PWM DAC
Turn a 4-bit code into pulse-width modulation. An analog reconstruction filter can recover its average voltage.
Specification
- Inputs phase[3:0] and duty[3:0]; output pwm.
- pwm is high exactly when phase < duty. There are 16 phase slots per period.
- Code 0 gives 0% duty and code 15 gives 15/16 duty, not 100%.
256 supplied checksRun uses the testbench in tb.sv. Submit checks your design with the original supplied testbench, even if you edit tb.sv.
Practice results stay in this browser. They do not count as server-verified scores.
Explore the analog circuit →
Language and tools
Choose Verilog 2005 or SystemVerilog 2012. Icarus supports a subset of SystemVerilog; classes, UVM and full SVA are outside this runtime. Download the project to continue in OSS CAD Suite with Icarus, Yosys and GTKWave.
Open-source credits and runtime provenance
Drag the dividers to resize. Focus a divider and use its arrow keys for precise adjustments.