Skip to content

sanampudig/iiitb_pwm_gen

Repository files navigation

iiitb_pwm_gen -> Pulse Width Modulated Wave Generator with Variable Duty Cycle

image

This project simulates the designed Pulse Width Modulated Wave Generator with Variable Duty Cycle. We can generate PWM wave and varry its DUTYCYCLE in steps of 10%

Note: Circuit requires further optimization to improve performance. Design yet to be modified.

1. Introduction to PWM Generator

Pulse Width Modulation is a famous technique used to create modulated electronic pulses of the desired width. The duty cycle is the ratio of how long that PWM signal stays at the high position to the total time period.

2. Applications

Pulse Width Modulated Wave Generator can be used to

  • control the brightness of the LED
  • drive buzzers at different loudnes
  • control the angle of the servo motor
  • encode messages in telecommunication
  • used in speed controlers of motors

3. Blocked Diagram of PWM GENERATOR

This PWM generator generates 10Mhz signal. We can control duty cycles in steps of 10%. The default duty cycle is 50%. Along with clock signal we provide another two external signals to increase and decrease the duty cycle.

In this specific circuit, we mainly require a n-bit counter and comparator. Duty given to the comparator is compared with the current value of the counter. If current value of counter is lower than duty then comparator results in output high. Similarly, If current value of counter is higher than duty is then comparator results in output low. As counter starts at zero, initially comparator gives high output and when counter crosses duty it becomes low. Hence by controlling duty, we can control duty cycle.

As the comparator is a combinational circuit and the counter is sequential, while counting from 011 to 100 due to improper delays there might be an intermediate state like 111 which might be higher or lower than duty. This might cause a glitch. To avoid these glitches output of the comparator is passed through a D flipflop.

4. Functional Simulation

4.1 About iverilog

Icarus Verilog is an implementation of the Verilog hardware description language.

4.2 About GTKWave

GTKWave is a fully featured GTK+ v1. 2 based wave viewer for Unix and Win32 which reads Ver Structural Verilog Compiler generated AET files as well as standard Verilog VCD/EVCD files and allows their viewing

4.3 Installing iverilog and GTKWave

For Ubuntu

Open your terminal and type the following to install iverilog and GTKWave

$   sudo apt-get update
$   sudo apt-get install iverilog gtkwave

4.4 Functional Simulation Process

To clone the Repository and download the Netlist files for Simulation, enter the following commands in your terminal.

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

4.5 Functional Characteristics

image

Simulation Results while increasing Dutycycle

image

Simulation Results while decreasing Dutycycle

image

5. SYNTHESIS

5.1 About Synthesys

Synthesis: Synthesis transforms the simple RTL design into a gate-level netlist with all the constraints as specified by the designer. In simple language, Synthesis is a process that converts the abstract form of design to a properly implemented chip in terms of logic gates.

Synthesis takes place in multiple steps:

  • Converting RTL into simple logic gates.
  • Mapping those gates to actual technology-dependent logic gates available in the technology libraries.
  • Optimizing the mapped netlist keeping the constraints set by the designer intact.

5.2 Synthesizer

Synthesizer: It is a tool we use to convert out RTL design code to netlist. Yosys is the tool I've used in this project.

About Yosys

Yosys is a framework for Verilog RTL synthesis. It currently has extensive Verilog-2005 support and provides a basic set of synthesis algorithms for various application domains.

To install yosys follow the instructions in this github repository

https://github.com/YosysHQ/yosys

Now you need to create a yosys_run.sh file , which is the yosys script file used to run the synthesis. The contents of the yosys_run file are given below:

  • note: Identify the .lib file path in cloned folder and change the path in highlighted text to indentified path

image

Now, in the terminal of your verilog files folder, run the following commands:

  • Run the following commands to syhthesize
$   yosys
$   yosys>    script yosys_run.sh
  • To see diffarent types of cells after synthesys
$   yosys>    stat
  • To generate schematics
$   yosys>    show

Now the synthesized netlist is written in iiitb_pwm_gen_synth.v file.

6. GATE LEVEL SIMULATION

6.1 About GLS

GLS is generating the simulation output by running test bench with netlist file generated from synthesis as design under test. Netlist is logically same as RTL code, therefore, same test bench can be used for it.We perform this to verify logical correctness of the design after synthesizing it. Also ensuring the timing of the design is met.

6.2 Running GLS

Folllowing are the commands to run the GLS simulation:

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

The gtkwave output for the netlist should match the output waveform for the RTL design file. As netlist and design code have same set of inputs and outputs, we can use the same testbench and compare the waveforms.

GLS Waveforms

image

  • Simulation Results while increasing Dutycycle

image

  • Simulation Results while decreasing Dutycycle

image

6.3 Observations from GLS Waveforms

Output characteristics of Functional simulation is matched with output of Gate Level Simulation.

7. PHYSICAL DESIGN

7.1 Overview of Physical Design flow

Place and Route (PnR) is the core of any ASIC implementation and Openlane flow integrates into it several key open source tools which perform each of the respective stages of PnR. Below are the stages and the respective tools that are called by openlane for the functionalities as described:

image

7.2 Opensource EDA tools

OpenLANE utilises a variety of opensource tools in the execution of the ASIC flow:

Task Tool/s
RTL Synthesis & Technology Mapping yosys, abc
Floorplan & PDN init_fp, ioPlacer, pdn and tapcell
Placement RePLace, Resizer, OpenPhySyn & OpenDP
Static Timing Analysis OpenSTA
Clock Tree Synthesis TritonCTS
Routing FastRoute and TritonRoute
SPEF Extraction SPEF-Extractor
DRC Checks, GDSII Streaming out Magic, Klayout
LVS check Netgen
Circuit validity checker CVC

7.3 Openlane

OpenLane is an automated RTL to GDSII flow based on several components including OpenROAD, Yosys, Magic, Netgen, CVC, SPEF-Extractor, CU-GR, Klayout and a number of custom scripts for design exploration and optimization. The flow performs full ASIC implementation steps from RTL all the way down to GDSII.

OpenLANE design stages

  1. Synthesis
    • yosys - Performs RTL synthesis
    • abc - Performs technology mapping
    • OpenSTA - Performs static timing analysis on the resulting netlist to generate timing reports
  2. Floorplan and PDN
    • init_fp - Defines the core area for the macro as well as the rows (used for placement) and the tracks (used for routing)
    • ioplacer - Places the macro input and output ports
    • pdn - Generates the power distribution network
    • tapcell - Inserts welltap and decap cells in the floorplan
  3. Placement
    • RePLace - Performs global placement
    • Resizer - Performs optional optimizations on the design
    • OpenDP - Perfroms detailed placement to legalize the globally placed components
  4. CTS
    • TritonCTS - Synthesizes the clock distribution network (the clock tree)
  5. Routing
    • FastRoute - Performs global routing to generate a guide file for the detailed router
    • CU-GR - Another option for performing global routing.
    • TritonRoute - Performs detailed routing
    • SPEF-Extractor - Performs SPEF extraction
  6. GDSII Generation
    • Magic - Streams out the final GDSII layout file from the routed def
    • Klayout - Streams out the final GDSII layout file from the routed def as a back-up
  7. Checks
    • Magic - Performs DRC Checks & Antenna Checks
    • Klayout - Performs DRC Checks
    • Netgen - Performs LVS Checks
    • CVC - Performs Circuit Validity Checks

more at https://github.com/The-OpenROAD-Project/OpenLane

Openlane Installation instructions

$   apt install -y build-essential python3 python3-venv python3-pip
$   git clone https://github.com/The-OpenROAD-Project/OpenLane.git
$   cd OpenLane/
$   sudo make
  • To test the Openlane
$ sudo make test

It takes approximate time of 5min to complete. After 43 steps, if it ended with saying Basic test passed then open lane installed succesfully.

7.4 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 at http://opencircuitdesign.com/magic/index.html

Run following commands one by one to fulfill the system requirement.

$   sudo apt-get install m4
$   sudo apt-get install tcsh
$   sudo apt-get install csh
$   sudo apt-get install libx11-dev
$   sudo apt-get install tcl-dev tk-dev
$   sudo apt-get install libcairo2-dev
$   sudo apt-get install mesa-common-dev libglu1-mesa-dev
$   sudo apt-get install libncurses-dev

To install magic Goto home directory

$   git clone https://github.com/RTimothyEdwards/magic
$   cd magic/
$   ./configure
$   sudo make
$   sudo make install

Type magic terminal to check whether it installed succesfully or not. type exit to exit magic.

7.5 Generating Layout with existing library cells

NON-INTERACTIVE MODE: Here we are generating the layout in the non-interactive mode or the automatic mode. In this we cant interact with the flow in the middle of each stage of the flow.The flow completes all the stages starting from synthesis until you obtain the final layout and the reports of various stages which specify the violations and problems if present during the flow.

  • Open terminal in home directory
$   cd OpenLane/
$   cd designs/
$   mkdir iiitb_pwm_gen
$   cd iiitb_pwm_gen/
$   wget https://raw.githubusercontent.com/sanampudig/iiitb_pwm_gen/main/config.json
$   mkdir src
$   cd src/
$   wget https://raw.githubusercontent.com/sanampudig/iiitb_pwm_gen/main/iiitb_pwm_gen.v
$   cd ../../../
$   sudo make mount
$   ./flow.tcl -design iiitb_pwm_gen

image

To see the layout we use a tool called magic which we installed earlier.

Open terminal in home directory

$   cd OpenLane/designs/iiitb_pwm_gen/run
$   ls

Select most run directoy from list

Example: image

$  cd RUN_2022.08.24_18.20.10

Run following instruction

$   cd results/final/def

Update the highlited text with appropriate path image

$   magic -T /home/parallels/Desktop/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech lef read ../../../tmp/merged.max.lef def read iiitb_pwm_gen.def &

Layout will be open in new window

Layout without sky130_vsdinv

  • The final layout obtained after the completion of the flow in non-interactive mode is shown below:

image

7.6 Customizing the layout

7.6.1 sky130_vsdinv cell creation

Here we are going to customise our layout by including our custom made sky130_vsdinv cell into our layout.

  • CREATING THE SKY130_VSDINV CELL LEF FILE

    -You need to first get the git repository of the vsdstdccelldesign.To get the repository type the following command:

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

image

image

  • Now you need to copy your tech file sky130A.tech to this folder.

  • Next run the magic command to open the sky130_vsdinv.mag file.Use the following command:

$ magic -T sky130A.tech sky130_inv.mag 
  • One can zoom into Magic layout by selecting an area with left and right mouse click followed by pressing "z" key.
  • Various components can be identified by using the what command in tkcon window after making a selection on the component.
  • The image showing the invoked magic tool using the above command:

7.6.2 layout of inverter cell

image

  • The next step is setting port class and port use attributes. The "class" and "use" properties of the port have no internal meaning to magic but are used by the LEF and DEF format read and write routines, and match the LEF/DEF CLASS and USE properties for macro cell pins. These attributes are set in tkcon window (after selecting each port on layout window. A keyboard shortcut would be,repeatedly pressing s till that port gets highlighed).

The tkcon command window of the port classification is shown in the image below:

image

7.6.3 Generating lef file

  • In the next step, use lef write command to write the LEF file with the same nomenclature as that of the layout .mag file. This will create a sky130_vsdinv.lef file in the same folder.

in tkcon terminal type the following command to generate .lef file

% lef write sky130_vsdinv

image

Copy the generated lef file to designs/iiit_pwm_gen/src Also copy lib files from vsdcelldesign/libs to designs/iiit_pwm_gen/src

image

  • Next modify the config.json file in our design to folloing code:

image

{
  "DESIGN_NAME": "iiitb_pwm_gen",
  "VERILOG_FILES": "dir::src/iiitb_pwm_gen.v",
  "CLOCK_PORT": "clk",
  "CLOCK_NET": "clk",
  "FP_SIZING": "relative",
  "LIB_SYNTH" : "dir::src/sky130_fd_sc_hd__typical.lib",
  "LIB_FASTEST" : "dir::src/sky130_fd_sc_hd__fast.lib",
  "LIB_SLOWEST" : "dir::src/sky130_fd_sc_hd__slow.lib",
  "LIB_TYPICAL":"dir::src/sky130_fd_sc_hd__typical.lib",
  "TEST_EXTERNAL_GLOB":"dir::../sd_fsm/src/*",
  "SYNTH_DRIVING_CELL":"sky130_vsdinv",
  "pdk::sky130*": {
    "FP_CORE_UTIL": 35,
    "CLOCK_PERIOD": 24,
    "scl::sky130_fd_sc_hd": {
      "FP_CORE_UTIL": 30
    }
  }
}

this config file is avilable in repo under name config1.json.

7.7 Generating Layout which inculdes custom made sky130_vsdinv

7.7.1 invkoing openlane

Goto openlane directory and open terminal there

$ sudo make mount

image

  • INTERACTIVE MODE: We need to run the openlane now in the interactive mode to include our custom made lef file before synthesis.Such that the openlane recognises our lef files during the flow for mapping.

  • Running openlane in interactive mode: The commands to the run the flow in interactive mode is given below:

$ ./flow.tcl -interactive

Loading the package file

% package require openlane 0.9

7.7.2 Preparing the design

  • Preparing the design and including the lef files: The commands to prepare the design and overwite in a existing run folder the reports and results along with the command to include the lef files is given below:
% prep -design iiitb_pwm_gen

image

Include the below command to include the additional lef (i.e sky130_vsdinv) into the flow:

% set lefs [glob $::env(DESIGN_DIR)/src/*.lef]
% add_lefs -src $lefs

image

7.7.3 Synthesis

Logic synthesis uses the RTL netlist to perform HDL technology mapping. The synthesis process is normally performed in two major steps:

  • GTECH Mapping – Consists of mapping the HDL netlist to generic gates what are used to perform logical optimization based on AIGERs and other topologies created from the generic mapped netlist.

  • Technology Mapping – Consists of mapping the post-optimized GTECH netlist to standard cells described in the PDK

To synthesize the code run the following command

% run_synthesis

image

Statistics after synthesis

Post synthesis stat

image

Calculation of Flop Ratio

 
             Number of D Flip flops 
Flop ratio = -------------------------
             Total Number of cells
   	     

image

7.7.4 Floorplan

Goal is to plan the silicon area and create a robust power distribution network (PDN) to power each of the individual components of the synthesized netlist. In addition, macro placement and blockages must be defined before placement occurs to ensure a legalized GDS file. In power planning we create the ring which is connected to the pads which brings power around the edges of the chip. We also include power straps to bring power to the middle of the chip using higher metal layers which reduces IR drop and electro-migration problem.

    1. Importance of files in increasing priority order:

    floorplan.tcl - System default envrionment variables conifg.tcl sky130A_sky130_fd_sc_hd_config.tcl

    1. Floorplan envrionment variables or switches:

    FP_CORE_UTIL - floorplan core utilisation FP_ASPECT_RATIO - floorplan aspect ratio FP_CORE_MARGIN - Core to die margin area FP_IO_MODE - defines pin configurations (1 = equidistant/0 = not equidistant) FP_CORE_VMETAL - vertical metal layer FP_CORE_HMETAL - horizontal metal layer

  • Note: Usually, vertical metal layer and horizontal metal layer values will be 1 more than that specified in the file

  • Following command helps to run floorplan

% run_floorplan

image

  • Post the floorplan run, a .def file will have been created within the results/floorplan directory. We may review floorplan files by checking the floorplan.tcl. The system defaults will have been overriden by switches set in conifg.tcl and further overriden by switches set in sky130A_sky130_fd_sc_hd_config.tcl.

  • To view the floorplan: Magic is invoked after moving to the results/floorplan directory,then use the floowing command:

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

floorplan

image

Die area (post floor plan)

image

Core area (post floor plan)

image

7.7.5 Placement

Place the standard cells on the floorplane rows, aligned with sites defined in the technology lef file. Placement is done in two steps: Global and Detailed. In Global placement tries to find optimal position for all cells but they may be overlapping and not aligned to rows, detailed placement takes the global placement and legalizes all of the placements trying to adhere to what the global placement wants.

  • The next step in the OpenLANE ASIC flow is placement. The synthesized netlist is to be placed on the floorplan. Placement is perfomed in 2 stages:
  • Global Placement: It finds optimal position for all cells which may not be legal and cells may overlap. Optimization is done through reduction of half parameter wire length.
  • Detailed Placement: It alters the position of cells post global placement so as to legalise them.

run the following command to run the placement

% run_placement

image

  • Post placement: the design can be viewed on magic within results/placement directory. Run the follwing command in that directory:
magic -T /home/parallels/Desktop/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech lef read ../../tmp/merged.nom.lef def read iiitb_pwm_gen.def &

layout after placement

image

sky130_vsdinv after placement

image

7.7.6 CTS

  • Clock tree synteshsis is used to create the clock distribution network that is used to deliver the clock to all sequential elements. The main goal is to create a network with minimal skew across the chip. H-trees are a common network topology that is used to achieve this goal.

  • The purpose of building a clock tree is enable the clock input to reach every element and to ensure a zero clock skew. H-tree is a common methodology followed in CTS. Before attempting a CTS run in TritonCTS tool, if the slack was attempted to be reduced in previous run, the netlist may have gotten modified by cell replacement techniques. Therefore, the verilog file needs to be modified using the write_verilog command. Then, the synthesis, floorplan and placement is run again

  • Run the following command to perform CTS

% run_cts

Clock SKEW report

image

Setup timing report

image

Hold timing report

image

Total Negative Slack

image

Wrost Neagative Slack

image

Wrost Slack

image

Area report

image

Power Report

image

Slew Report

image

7.7.7 Routing

Implements the interconnect system between standard cells using the remaining available metal layers after CTS and PDN generation. The routing is performed on routing grids to ensure minimal DRC errors.

    1. OpenLANE uses the TritonRoute tool for routing. There are 2 stages of routing:
  • Global routing: Routing region is divided into rectangle grids which are represented as course 3D routes (Fastroute tool).
  • Detailed routing: Finer grids and routing guides used to implement physical wiring (TritonRoute tool).
  • Features of TritonRoute:
  • Honouring pre-processed route guides
  • Assumes that each net satisfies inter guide connectivity
  • Uses MILP based panel routing scheme
  • Intra-layer parallel and inter-layer sequential routing framework

Run the following command to run the routing

% run_routing

image

Do know in routing stage

  • run_routing - To start the routing
  • The options for routing can be set in the config.tcl file. The optimisations in routing can also be done by specifying the routing strategy to use different version of TritonRoute Engine. There is a trade0ff between the optimised route and the runtime for routing. The routing stage must have the CURRENT_DEF set to pdn.def. The two stages of routing are performed by the following engines: Global Route : Fast Route Detailed Route : Triton Route Fast Route generates the routing guides, whereas Triton Route uses the Global Route and then completes the routing with some strategies and optimisations for finding the best possible path connect the pins.
  • Layout in magic tool post routing: the design can be viewed on magic within results/routing directory. Run the follwing command in that directory:
magic -T /home/parallels/Desktop/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech lef read ../../tmp/merged.nom.lef def read iiitb_pwm_gen.def &

layout after Routing

image

image

7.8 Identifing custom made sky130_vsdinv

in tkcon type the follow command to check where sky130_vsdinv exist or not

% getcell sky130_vsdinv

image

image

Seven sky130_vsdinv cells present in design

sky130_vsdinv _ 138 _

sky130_vsdinv _ 158 _

sky130_vsdinv _ 167 _

sky130_vsdinv _ 169 _

sky130_vsdinv _ 170 _

sky130_vsdinv _ 171 _

sky130_vsdinv _ 172 _

image

image

8. Performance Calculation using OpenSTA

Static timing analysis (STA) is a method of validating the timing performance of a design by checking all possible paths for timing violations. STA breaks a design down into timing paths, calculates the signal propagation delay along each path, and checks for violations of timing constraints inside the design and at the input/output interface.

How does STA work? When performing timing analysis, STA first breaks down the design into timing paths. Each timing path consists of the following elements:

Startpoint The start of a timing path where data is launched by a clock edge or where the data must be available at a specific time. Every startpoint must be either an input port or a register clock pin.

Combinational logic network Elements that have no memory or internal state. Combinational logic can contain AND, OR, XOR, and inverter elements, but cannot contain flip-flops, latches, registers, or RAM.

Endpoint The end of a timing path where data is captured by a clock edge or where the data must be available at a specific time. Every endpoint must be either a register data input pin or an output port.

image

  • To run STA in Openlane and type sta to enter openSTA

image

  • Run the following commands
%	read_liberty -min /home/parallels/Desktop/OpenLane/pdks/sky130A/libs.ref/sky130_fd_sc_hd/lib/sky130_fd_sc_hd__ff_n40C_1v56.lib
%	read_liberty -max /home/parallels/Desktop/OpenLane/pdks/sky130A/libs.ref/sky130_fd_sc_hd/lib/sky130_fd_sc_hd__ff_n40C_1v56.lib
%	read_verilog /home/parallels/Desktop/OpenLane/pdks/sky130A/iiitb_pwm_gen.v
%	link_design iiitb_pwm_gen
%	read_sdc /home/parallels/Desktop/OpenLane/pdks/sky130A/iiitb_pwm_gen.sdc
%	set_propagated_clock [all_clocks]
%	report_checks

  • To report the particular path use the following command
%	report_checks -from _247_ -to _244_
%	report_check -from  _247_ -to _245_

image

Performance Caluculation:


                                                      1
Maximum Possible Operating Frequency = -----------------------------
					  Clock period - Setup Slack
					  
					          1
				      = ---------------------  
				            65ns - 61.36ns
				            
				      = 0.274725275 GHz

9. Parameters

9.1 Post synthesis Gate count for your design

Number of cells: 179 image

9.2 Area of design

Area=6586.0834 micrometre^2 image

9.3 Performance achieved

Performance = 0.274725275 GHz image

9.4 flip flop to standard cell ratio

flip-flop to standard cell ratio = 40/179 = 0.2235 image

9.5 total power consumed

Total power = 0.137mW image

10. Tapeout

Efabless Open MPW Program

image

The shuttle provides opportunities for designers to experiment and push the state-of-the-art without having to reconcile the risk associated with the cost of fabrication.

The shuttle program is open to anyone, provided that their project is fully open source and meets the other program requirements.

Costs for fabrication, packaging, evaluation boards and shipping are covered by Google for this program.

more at: https://efabless.com/open_shuttle_program

image

11. Contributors

  • Sanampudi Gopala Krishna Reddy
  • Kunal Ghosh

12. Acknowledgments

  • Kunal Ghosh, Director, VSD Corp. Pvt. Ltd.
  • Nickson Jose, SoC Physical Design Engineer, Intel.
  • Vinay Rayapati, Postgraduate Student, International Institute of Information Technology, Bangalore
  • Gogireddy Ravi Kiran Reddy, Postgraduate Student, International Institute of Information Technology, Bangalore

13. Contact Information

  • Sanampudi Gopala Krishna Reddy, Postgraduate Student, International Institute of Information Technology, Bangalore svgkr7@gmail.com
  • Kunal Ghosh, Director, VSD Corp. Pvt. Ltd. kunalghosh@gmail.com

14. References

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published