Skip to content

pranav1751/iiitb_pwm

Repository files navigation

Pulse Width Modulation signal Generator

This project simulates a variable duty cycle PWM signal generator with verilog. It generates a PWM signal of 10MHz, it has a button to increase the duty cycle by 10% and one to decrease the duty cycle by 10%. The verilog code has been taken from fpga4student.com

Introduction

A Pulse width modulated signal generator is used widely in the industry in many applications. PWM generator produces a square wave with a fixed time period but a variable duty cycle. Because the PWM can operate at high frequencies, it finds applications as a voltage controller in many devices.

Applications

PWM generator is used in many applications like:

  • DC/DC and DC/AC cconverters
  • Inverters
  • Controlling brightness of lights
  • Controlling loudness in speakers
  • Controlling speed of motor

Block Diagram

Screenshot 2022-08-08 at 11 38 58 PM

PWM1

In a PWM circuit, the pulse frequency is created using a comparator that resets a pulse-window counter, and the duty cycle is set by a comparator that drives the output waveform low whenever the count value is greater than the duty cycle value. Here, we have two buttons to either increase or decrease the duty cycle by 10% as shown above.

Tools installation

Install the following tools with commands given (for linux):

  • Verilog
  • GTKwave
  • Yosys
$   sudo apt-get update
$   sudo apt-get install iverilog gtkwave
$   sudo apt-get install -y yosys

Functional Simulation

Use the following commands to clone the github repo and run the files:

$   sudo apt install -y git
$   git clone https://github.com/pranav1751/iiitb_pwm
$   cd iiitb_pwm
$   iverilog iiitb_pwm_gen.v iiitb_pwm_gen_tb.v
$   ./a.out
$   gtkwave pwm.vcd

Functional Characteristics

The simulation results when increasing duty cycle image The simulation results when decreasing duty cycle image

Generating GLS with yosys

Note: in the yosys_run.sh file, change the path name for the lib file as it is in your directory

# read design
# read_liberty -lib /media/psf/Home/Stark/Education/ASIC/iiitb_pwm_gen/lib/sky130_fd_sc_hd__tt_025C_1v80.lib
read_verilog iiitb_pwm_gen.v

# generic synthesis
synth -top iiitb_pwm_gen

# mapping to mycells.lib

dfflibmap -liberty /home/imt2020544/iiitb_pwm/lib/sky130_fd_sc_hd__tt_025C_1v80.lib
abc -liberty /home/imt2020544/iiitb_pwm/lib/sky130_fd_sc_hd__tt_025C_1v80.lib -script +strash;scorr;ifraig;retime,{D};strash;dch,-f;map,-M,1,{D}
clean
flatten
# write synthesized design
write_verilog -noattr iiitb_pwm_synth.v
# stat
# show

Use the following commands to generate the Gate Level Simulation file from the initial iiitb_pwm_gen.v

$ iverilog -DFUNCTIONAL -DUNIT_DELAY=#1 primitives.v sky130_fd_sc_hd.v iiitb_pwm_gen_synth.v iiitb_pwm_gen_tb.v
$ ./a.out
$ gtkwave pwm.vcd

note: I extracted the files primitives.v sky130_fd_sc_hd.v out of the verilog_model folder and kept them in the main folder as there was an error accessing them inside the folder for some unknown reason.

Physical design with OpenLane

OpenLane is an automated RTL to GDSII flow based on several components including OpenROAD, Yosys, Magic, Netgen, CVC, SPEF-Extractor, KLayout and a number of custom scripts for design exploration and optimization. The flow performs all ASIC implementation steps from RTL all the way down to GDSII.
Read more and installation guide at https://github.com/The-OpenROAD-Project/OpenLane\ Installation Prerequisites:

Magic

Magic is a venerable VLSI layout tool, written in the 1980's at Berkeley by John Ousterhout, now famous primarily for writing the scripting interpreter language Tcl. Due largely in part to its liberal Berkeley open-source license, magic has remained popular with universities and small companies. The open-source license has allowed VLSI engineers with a bent toward programming to implement clever ideas and help magic stay abreast of fabrication technology. However, it is the well thought-out core algorithms which lend to magic the greatest part of its popularity. Magic is widely cited as being the easiest tool to use for circuit layout, even for people who ultimately rely on commercial tools for their product design flow.\ More about magic and installation guide at http://opencircuitdesign.com/magic/index.html

Genrating Layout with existing cells in OpenLane

run the following commands on the terminal:

$   cd OpenLane/
$   cd designs/
$   mkdir iiitb_pwm_gen
$   cd iiitb_pwm_gen/
$   wget https://raw.githubusercontent.com/pranav1751/iiitb_pwm_gen/main/config.json
$   mkdir src
$   cd src/
$   wget https://raw.githubusercontent.com/pranav1751/iiitb_pwm_gen/main/iiitb_pwm_gen.v
$   cd ../../../
$   sudo make mount
$   ./flow.tcl -design iiitb_pwm_gen!

Screenshot from 2022-09-11 18-22-37

The layout files for the run are created in iiitb_pwm_gen/runs. Find the most recent run, it has all the files, and the def physical layout files.\ Using magic to view the .def files.

  • Go to the folder where the final def file is located, here it is, /home/ubuntu/OpenLane/designs/iiitb_pwm/runs/RUN_2022.09.11_12.50.55/results/final/def
  • Run the command
 magic -T /home/ubuntu/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech lef read ../../../tmp/merged.nom.lef def read iiitb_pwm_gen.def &

The following window appears, showing the layout

Screenshot from 2022-09-11 18-30-45

Including a custom cell in the layout

Lets include in library and in the final layout. Clone the vsdcelldesign repo in Openlane/ using the following command

$ git clone https://github.com/nickson-jose/vsdstdcelldesign

copy sky130A.tech to vsdstdcelldesign directory Viewing the vsdinv cell ''' $ magic -T sky130A.tech sky130_inv.mag ''' Screenshot from 2022-09-11 18-35-06 in tkcon terminal using the following, generate the lef file

% lef write sky130_vsdinv

Screenshot from 2022-09-11 18-37-23 Copy the generated lef file to designs/iiit_pwm_gen/src. Also copy lib files from vsdcelldesign/libs to designs/iiit_pwm_gen/src. / Open the OpenLane directory and run the following commands:

$ sudo make mount
$ ./flow.tcl -interactive
% package require openlane 0.9
% prep -design iiitb_pwm_gen
% set lefs [glob $::env(DESIGN_DIR)/src/*.lef]
% add_lefs -src $lefs

Screenshot from 2022-09-11 18-43-37


% run_synthesis
% run_floorplan
% run_placement
% run_cts
% run_routing

Stats

Pre synthesis stats

Screenshot from 2022-09-11 18-45-37

Post synthesis stats Screenshot from 2022-09-11 22-17-49

Layout including vsdinv

To view the layout in magic, go to results/routing in your runs folder and enter the following command:

 magic -T /home/ubuntu/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech lef read ../../tmp/merged.nom.lef def read iiitb_pwm_gen.def &

Note: Change the directories for your PC. Screenshot from 2022-09-11 22-31-32

% getcell sky130_vsdinv

Screenshot from 2022-09-11 22-32-50

This shows that vsdinv cell is included. Screenshot from 2022-09-11 22-33-55 Screenshot from 2022-09-12 23-40-52

Screenshot from 2022-09-12 23-49-26

Reports

Screenshot from 2022-09-13 00-21-00

Performance Analysis using OpenSTA

OpenSTA is a gate level static timing verifier. As a stand-alone executable it can be used to verify the timing of a design using standard file formats. OpenSTA uses a TCL command interpreter to read the design, specify timing constraints and print timing reports. Read more at OpenSTA Github After opening openlane, enter sta to open it. Place the following files in the pdks/sky130A directory (from runs/results/ctc) WhatsApp Image 2022-09-28 at 12 44 51 PM

Run the following commands:

%	read_liberty -min /home/ubuntu/OpenLane/pdks/sky130A/libs.ref/sky130_fd_sc_hd/lib/sky130_fd_sc_hd__ff_n40C_1v56.lib
%	read_liberty -max /home/ubuntu/OpenLane/pdks/sky130A/libs.ref/sky130_fd_sc_hd/lib/sky130_fd_sc_hd__ff_n40C_1v56.lib
%	read_verilog /home/ubuntu/OpenLane/pdks/sky130A/iiitb_pwm_gen.v
%	link_design iiitb_pwm_gen
%	read_sdc /home/ubuntu/OpenLane/pdks/sky130A/iiitb_pwm_gen.sdc
%	set_propagated_clock [all_clocks]
%	report_checks

%	report_checks -from _247_ -to _244_
%	report_checks -from  _247_ -to _245_

Screenshot from 2022-09-28 13-10-33

Key Parameters

Post Synthesis gate count = 177

Screenshot from 2022-09-28 09-54-52

Area = 9064.8 micron^2

Screenshot from 2022-09-28 10-49-39

Performance = 272.47 MHz

Screenshot from 2022-09-28 13-10-33

Flipflop/Standard cell ratio = 40/177 = 0.2259

Screenshot from 2022-09-28 11-01-11

Power consumed = 0.141mW

Screenshot from 2022-09-28 11-08-31

Contributors

  • Pranav Vajreshwari, iMtech2020 IIITB

  • Kunal Ghosh, Director, VSD Corp. Pvt. Ltd.

Acknowledgements

  • Kunal Ghosh, Director, VSD Corp. Pvt. Ltd.

Contact information

References

About

This project simulates a variable duty cycle PWM signal generator with verilog.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published