Skip to content

Physical Design of a 4 bit bidirectional counter implemented with skywater 130 pdk

Notifications You must be signed in to change notification settings

isahilmahajan/iiitb_4bbc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iiitb_4bbc --> 4 Bit Bidirectional Counter

Description

Bidirectional counters, also known as Up/Down counters, are capable of counting in either direction through any given count sequence and they can be reversed at any point within their count sequence by using an additional control input as shown in Fig 1.

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

Block Diagram of Bidirectional Counter

IMG_20220811_135442 -Fig. 1

Truth Table of Bidirectional Counter

IMG_20220811_135338

IMG_20220811_135412

Application of Bidirectional Counter

Bidirectional counter has various applications

  • Up Counter
  • Down Counter
  • Analog to Digital converter
  • Self-reversing counter
  • Clock Divider circuit
  • Counting the time allotted for special process or event by the scheduler

Bidirectional Counter - Verilog Implementation

The digital circuit takes clock, UporDown and reset as input. It operates as 4-bit up counter when UporDown=1 and as 4-bit down counter when UporDown=0. The port description of the Bidirectional counter is shown in Table below.

PORT NAME PORT TYPE DESCRIPTION
clk input Clock Input
UporDown input Specifies the mode of operation (Up / Down)
reset input Resets the counter to 0
count[3:0] output 4-bit counter output

About iverilog

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

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

Installing iverilog and GTKWave

For Ubuntu

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

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

Functional Simulation

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/isahilmahajan/iiitb_4bbc
$   cd iiitb_4bbc
$   iverilog iiitb_4bbc.v iiitb_4bbc_tb.v
$   ./a.out
$   gtkwave updown.vcd

Functional Simulation

pre

Synthesis

The software used to run gate level synthesis is 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. Yosys can be adapted to perform any synthesis job by combining the existing passes (algorithms) using synthesis scripts and adding additional passes as needed by extending the Yosys C++ code base. [^5]

git clone https://github.com/YosysHQ/yosys.git
make
sudo make install make test

The commands to run synthesis in yosys are given below. First create an yosys script yosys_run.sh and paste the below commands.

read_liberty -lib lib/sky130_fd_sc_hd__tt_025C_1v80.lib
read_verilog iiitb_4bbc.v
synth -top iiitb_4bbc	
dfflibmap -liberty /home/sahil/iiitb_4bbc/lib/sky130_fd_sc_hd__tt_025C_1v80.lib
abc -liberty /home/sahil/iiitb_4bbc/lib/sky130_fd_sc_hd__tt_025C_1v80.lib
clean
flatten
write_verilog iiitb_4bbc_synth.v
stat
show

Then, open terminal in the folder iiitb_gc and type the below command.

yosys -s yosys_run.sh

On running the yosys script, we get the following output:

Screenshot from 2022-08-16 19-43-49

Screenshot from 2022-08-17 23-48-09

Gate Level Simulation GLS

GLS stands for gate level simulation. When we write the RTL code, we test it by giving it some stimulus through the testbench and check it for the desired specifications. Similarly, we run the netlist as the design under test (dut) with the same testbench. Gate level simulation is done to verify the logical correctness of the design after synthesis. Also, it ensures the timing of the design.
Commands to run the GLS are given below.

iverilog -DFUNCTIONAL -DUNIT_DELAY=#0 iiitb_4bbc_synth.v iiitb_4bbc_tb.v iiitb_4bbc/verilog_model/primitives.v /iiitb_4bbc/verilog_model/sky130_fd_sc_hd.v -iiitb_4bbc 
./iiitb_4bbc
gtkwave iiitb_4bbc.vcd

post

Layout

Preparation

The layout is generated using OpenLane. To run a custom design on openlane, Navigate to the openlane folder and run the following commands:

$ cd designs

$ mkdir iiitb_4bbc

$ cd iiitb_4bbc

$ mkdir src

$ touch config.json

$ cd src

$ touch iiitb_4bbc.v

The iiitb_freqdiv.v file should contain the verilog RTL code you have used and got the post synthesis simulation for.

Copy sky130_fd_sc_hd__fast.lib, sky130_fd_sc_hd__slow.lib, sky130_fd_sc_hd__typical.lib and sky130_vsdinv.lef files to src folder in your design.

The final src folder should look like this:


The contents of the config.json are as follows. this can be modified specifically for your design as and when required.

As mentioned by kunal sir dont use defined DIE_AREA and FP_SIZING : absolute, use FP_SIZING : relative

{
    "DESIGN_NAME": "iiitb_4bbc",
    "VERILOG_FILES": "dir::src/iiitb_4bbc.v",
    "CLOCK_PORT": "clkin",
    "CLOCK_NET": "clkin",
    "GLB_RESIZER_TIMING_OPTIMIZATIONS": true,
    "CLOCK_PERIOD": 10,
    "PL_TARGET_DENSITY": 0.7,
    "FP_SIZING" : "relative",
    "pdk::sky130*": {
        "FP_CORE_UTIL": 30,
        "scl::sky130_fd_sc_hd": {
            "FP_CORE_UTIL": 20
        }
    },
    
    "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::../iiitb_4bbc/src/*"


}

Save all the changes made above and Navigate to the openlane folder in terminal and give the following command :

$ make mount (if this command doesnot go through prefix it with sudo)

sm-make mount

After entering the openlane container give the following command:

$ ./flow.tcl -interactive

tcl

This command will take you into the tcl console. In the tcl console type the following commands:

% package require openlane 0.9

openlane 0 9

% prep -design iiitb_freqdiv

design prep

The following commands are to merge external the lef files to the merged.nom.lef. In our case sky130_vsdiat is getting merged to the lef file

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

set_lfs

Synthesis

% run_synthesis

run_synthesis

Floorplan


% run_floorplan

floorplan

Floorplan Reports

Navigate to results->floorplan and type the Magic command in terminal to open the floorplan

$ magic -T /home/himanshu/Sahil/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech read ../../tmp/merged.nom.lef def read iiitb_4bbc.def &

Floorplan view

Screenshot from 2022-09-01 14-44-12

Placement

% run_placement

placement

Placement Reports

Navigate to results->placement and type the Magic command in terminal to open the placement view

$ magic -T /home/himanshu/Sahil/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech read ../../tmp/merged.max.lef def read iiitb_4bbc.def &

Placement View

Screenshot from 2022-09-01 14-43-39


sky130_vsdinv in the placement view :

vsdinv



Clock Tree Synthesis

% run_cts

21

Routing

% run_routing

22

Routing Reports

Navigate to results->routing and type the Magic command in terminal to open the routing view

$ magic -T /home/himanshu/Sahil/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech read ../../tmp/merged.nom.lef def read iiitb_4bbc.def &

Routing View

Screenshot from 2022-09-01 14-42-58

Viewing Layout in KLayout

klayout

NOTE

We can also run the whole flow at once instead of step by step process by giving the following command in openlane container

$ ./flow.tcl -design iiitb_4bbc


non-interactive command
All the steps will be automated and all the files will be generated.

Post Layout Results

1. gate count

flop_ratio

Gate count = 24

2. Area

box_4

Area = 2486.293 um^2

3. Performance

timing_commands timing

performance = 1/(clock period-slack = 1/(10-7.16)ps =352.112GHz)

4. Flop/standard cell

flop_ratio_2

Flop ratio = 6/24 = 0.25

5. Power Performance

power Total Power = 87.6 uW

Author

  • Sahil Mahajan

Contributors

  • Kunal Ghosh
  • Siddhant Nayak

Acknowledgments

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

Contact Information

References

About

Physical Design of a 4 bit bidirectional counter implemented with skywater 130 pdk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published