ALU is a processor unit which performs the task of addition, subtraction, multiplication, and division. In order to support CPU for its arithmatic and logical processes, ALU has AU (i.e) arithmatic unit and LU (i.e) Logical Unit. This paper deals with its analysis and functioning of this important unit of CPU using verilog.
An arithmatic logic unit is an important part of central processing unit and performs arithmatic and logic operations. It can take inputs as multiple bits through an input register. It is the fundamental building block of the central processing unit of a computer.The ALU is the mathematical brain of a computer. The first ALU was INTEL 74181 implemented as a 7400 series is a TTL integrated circuit that was released in 1970.[1]
This is a ALU model which receives two input operands ’A’ and ’B’ which are 8 bits long. The result is denoted by ’R’ which is also 8 bit long. The input signal ’Op’ is a 3 bit value which tells the ALU what operation has to be performed by the ALU. Since ’Op’ is 3 bits long we can have a maximum of 2 3 = 8operations.[2]
This ALU is capable of doing the following operations: Add Signed : R = A + B ( Treating A, B, and R as signed two’s complement integers.) Subtract Signed : R = A - B (Treating A, B, and R as signed two’s complement integers.) Bitwise AND : R(i) = A(i) AND B(i). Bitwise NOR : R(i) = A(i) NOR B(i). Bitwise OR : R(i) = A(i) OR B(i). Bitwise NAND : R(i) = A(i) NAND B(i). Bitwise XOR : R(i) = A(i) XOR B(i). Biwise NOT : R(i) = NOT A(i).
Icarus Verilog is an implementation of the Verilog hardware description language.
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
For Ubuntu Open your terminal and type the following to install iverilog and GTKWave
$ sudo apt-get update
$ sudo apt-get install iverilog gtkwave
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://https://github.com/aashish-tiwary/ALU
$ cd iiitb_ALU
$ iverilog iiitb_ALU.v iiitb_module_tb_alu.v
$ ./a.out
$ gtkwave ALU.vcd
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:
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.
more at https://yosyshq.net/yosys/ To install yosys follow the instructions in this github repository
note: Identify the .lib file path in cloned folder and change the path in highlighted text to indentified path
# read design
read_verilog iiitb_alu.v
# generic synthesis
synth -top iiitb_alu
# mapping to mycells.lib
dfflibmap -liberty /home/aashish/asic/lib/sky130_fd_sc_hd__tt_025C_1v80.lib
abc -liberty /home/aashish/asic/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_alu_synth.v
show
stat
Now, in the terminal of your verilog files folder, run the following commands: to synthesize
$ 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_alu_synth.v" file.
GATE LEVEL SIMULATION(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. Folllowing are the commands to run the GLS simulation:
iverilog -DFUNCTIONAL -DUNIT_DELAY=#1 primitives.v sky130_fd_sc_hd.v iiitb_alu_synth.v iiitb_alu_tb.v
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.
OpenLANE is an opensource tool or flow used for opensource tape-outs. The OpenLANE flow comprises a variety of tools such as Yosys, ABC, OpenSTA, Fault, OpenROAD app, Netgen and Magic which are used to harden chips and macros, i.e. generate final GDSII from the design RTL. The primary goal of OpenLANE is to produce clean GDSII with no human intervention. OpenLANE has been tuned to function for the Google-Skywater130 Opensource Process Design Kit.
SoC Design & OpenLANE
Components of opensource digital ASIC design The design of digital Application Specific Integrated Circuit (ASIC) requires three enablers or elements - Resistor Transistor Logic Intellectual Property (RTL IPs), Electronic Design Automation (EDA) Tools and Process Design Kit (PDK) data.
The ASIC flow objective is to convert RTL design to GDSII format used for final layout. The flow is essentially a software also known as automated PnR (Place & route).
This project is done in the course "Advanced Physical Design using OpenLANE/Sky130" by VLSI System Design Corporation. In this project a complete RTL to GDSII flow for PicoRV32a SoC is executed with Openlane using Skywater130nm PDK. Custom designed standard cells with Sky130 PDK are also used in the flow. Timing Optimisations are carried out. Slack violations are removed. DRC is verified.
OpenLANE ASIC Flow
From conception to product, the ASIC design flow is an iterative process that is not static for every design. The details of the flow may change depending on ECO’s, IP requirements, DFT insertion, and SDC constraints, however the base concepts still remain. The flow can be broken down into 11 steps:
Architectural Design – A system engineer will provide the VLSI engineer with specifications for the system that are determined through physical constraints. The VLSI engineer will be required to design a circuit that meets these constraints at a microarchitecture modeling level.
RTL Design/Behavioral Modeling – RTL design and behavioral modeling are performed with a hardware description language (HDL). EDA tools will use the HDL to perform mapping of higher-level components to the transistor level needed for physical implementation. HDL modeling is normally performed using either Verilog or VHDL. One of two design methods may be employed while creating the HDL of a microarchitecture:
a. RTL Design – Stands for Register Transfer Level. It provides an abstraction of the digital circuit using:
* i. Combinational logic
* ii. Registers
* iii. Modules (IP’s or Soft Macros)
b. Behavioral Modeling – Allows the microarchitecture modeling to be performed with behavior-based modeling in HDL. This method bridges the gap between C and HDL allowing HDL design to be performed
RTL Verification - Behavioral verification of design
DFT Insertion - Design-for-Test Circuit Insertion
Logic 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
Sandard Cells – Standard cells are fixed height and a multiple of unit size width. This width is an integer multiple of the SITE size or the PR boundary. Each standard cell comes with SPICE, HDL, liberty, layout (detailed and abstract) files used by different tools at different stages in the RTL2GDS flow.
Post-Synthesis STA Analysis: Performs setup analysis on different path groups.
Floorplanning – 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.
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.
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.
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.
Opensource EDA tools OpenLANE utilises a variety of opensource tools in the execution of the ASIC flow:
OpenLANE design stages
OpenLANE Files The openLANE file structure looks something like this:
$ sudo apt install -y build-essential python3 python3-venv python3-pip
$ sudo apt-get remove docker docker-engine docker.io containerd runc (removes older version of docker if installed)
$ sudo apt-get update
$ sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
$ apt-cache madison docker-ce (copy the version string you want to install)
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io docker-compose-plugin (paste the version string copies in place of <VERSION_STRING>)
$ sudo docker run hello-world (If the docker is successfully installed u will get a success message here)
$ git clone https://github.com/The-OpenROAD-Project/OpenLane.git
$ cd OpenLane/
$ make
$ make test
For Magic to be installed and work properly the following softwares have to be installed first:
$ sudo apt-get install csh
$ sudo apt-get install xorg
$ sudo apt-get install xorg openbox
$ sudo apt-get install gcc
$ sudo apt-get install build-essential
$ sudo apt-get install freeglut3-dev
$ sudo apt-get install tcl-dev tk-dev
After all the softwares are installed, run the following commands for installing magic:
$ cd magic
$ ./configure
$ make
$ make install
$ sudo apt-get install klayout
$ sudo apt-get install ngspice
Open Terminal in the folder you want to create the custom inverter cell.
$ git clone https://github.com/nickson-jose/vsdstdcelldesign.git
$ cd vsdstdcelldesign
$ cp ./libs/sky130A.tech sky130A.tech
$ magic -T sky130A.tech sky130_inv.mag &
The above layout will open. The design can be verified and various layers can be seen and examined by selecting the area of examination and type what in the tcl window. To extract Spice netlist, Type the following commands in tcl window.
% extract all
% ext2spice cthresh 0 rthresh 0
% ext2spice
cthresh 0 rthresh 0
is used to extract parasitic capacitances from the cell.
The spice netlist has to be edited to add the libraries we are using, The final spice netlist should look like the following:
* SPICE3 file created from sky130_inv.ext - technology: sky130A
342
343
.option scale=10000u
344
345
.subckt sky130_inv A Y VPWR VGND
346
M1000 Y A VPWR VPWR pshort w=37 l=23
347
+ ad=1443 pd=152 as=1517 ps=156
348
M1001 Y A VGND VGND nshort w=35 l=23
349
+ ad=1435 pd=152 as=1365 ps=148
350
C0 VPWR A 0.07fF
351
C1 VPWR Y 0.11fF
352
C2 Y A 0.05fF
353
C3 Y VGND 0.24fF
354
C4 VPWR VGND 0.59fF
355
.ends
Open the terminal in the directory where ngspice is stored and type the following command, ngspice console will open: $ ngspice sky130_inv.spice
Now you can plot the graphs for the designed inverter model. -> plot y vs time a
Four timing parameters are used to characterize the inverter standard cell:
Rise time = (2.23843 - 2.17935) = 59.08ps
Fall time = (4.09291 - 4.05004) = 42.87ps
Cell rise delay = (2.20636 - 2.15) = 56.36ps
Cell fall delay = (4.07479 - 4.05) = 24.79ps
To get a grid and to ensure the ports are placed correctly we can use
% grid 0.46um 0.34um 0.23um 0.17um
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_alu
$ cd iiitb_alu
$ mkdir src
$ touch config.json
$ cd src
$ touch iiitb_alu.v
The iiitb_alu.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.
{
"DESIGN_NAME": "iiitb_alu",
"VERILOG_FILES": "dir::src/iiitb_alu.v",
"CLOCK_PORT": "clk",
"CLOCK_NET": "clk",
"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_alu/src/*"
}
Save all the changes made above and Navigate to the openlane folder in terminal and give the following command : $ sudo make mount
After entering the openlane container give the following command:
$ ./flow.tcl -interactive
This command will take you into the tcl console. In the tcl console type the following commands:
% package require openlane 0.9
prep -design iiitb_freqdiv
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
% run_synthesis
Details of the gates used
Flop Ratio = Ratio of total number of flip flops / Total number of cells present in the design = 8/145 = 0.05517
The sky130_vsdinv should also reflect in your netlist after synthesis
% run_floorplan
Navigate to results->floorplan and type the Magic command in terminal to open the floorplan
$ magic -T /home/aashish/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech read ../../tmp/merged.nom.lef def read iiitb_alu.def &
All the cells are placed in the left corner of the floorplan
run_placement
Navigate to results->placement and type the Magic command in terminal to open the placement view
$ magic -T /home/himanshu/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech read lef ../../tmp/merged.max.lef def read iiitb_alu.def &
Placement View
sky130_vsdinv in the placement view :
The sky130_vsdinv should also reflect in your netlist after placement
% run_cts
% run_routing
Navigate to results->routing and type the Magic command in terminal to open the routing view
$ magic -T /home/himanshu/OpenLane/pdks/sky130A/libs.tech/magic/sky130A.tech read lef ../../tmp/merged.nom.lef def read iiitb_alu.def &
Routing View
sky130_vsdinv in the routing view :
The sky130_vsdinv should reflect in your netlist after routing
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_alu
All the steps will be automated and all the files will be generated.
Navigate to results->signoff and type the Magic command in terminal to open the routing view
$ klayout iiitb_alu.mag
iiitb_alu
├── config.jason
├── runs
│ ├── RUN_2022.09.01_11.03.54
│ │ ├── config.tcl
│ │ ├── logs
│ │ │ ├── cts
│ │ │ ├── cvc
│ │ │ ├── floorplan
│ │ │ ├── klayout
│ │ │ ├── magic
│ │ │ ├── placement
│ │ │ ├── routing
│ │ │ └── synthesis
│ │ ├── reports
│ │ │ ├── cts
│ │ │ ├── cvc
│ │ │ ├── floorplan
│ │ │ ├── klayout
│ │ │ ├── magic
│ │ │ ├── placement
│ │ │ ├── routing
│ │ │ └── synthesis
│ │ ├── results
│ │ │ ├── cts
│ │ │ ├── cvc
│ │ │ ├── floorplan
│ │ │ ├── klayout
| | | ├── signoff
│ │ │ ├── magic
│ │ │ ├── placement
│ │ │ ├── routing
│ │ │ └── synthesis
│ │ └── tmp
│ │ ├── cts
│ │ ├── cvc
│ │ ├── floorplan
│ │ ├── klayout
│ │ ├── magic
│ │ ├── placement
│ │ ├── routing
│ │ └── synthesis
├── src
├── iiitb_alu.v
├── sky130_fd_sc_hd__fast.lib
├── sky130_fd_sc_hd__slow.lib
├── sky130_fd_sc_hd__typical.lib
├── sky130_vsdinv.lef
Kunal Ghosh, Director, VSD Corp. Pvt. Ltd.
Aashish Tiwary, Postgraduate Student, International Institute of Information Technology, Bangalore aashish.tiwary@iiitb.ac.in Kunal Ghosh, Director, VSD Corp. Pvt. Ltd. kunalghosh@gmail.com
[1] https://www.geeksforgeeks.org/introduction-of-alu-and-data-path/, some content was taken from here.
[2] https://verilogcodes.blogspot.com/2015/10/verilog-code-for-simple-alu. verilog code was taken from here.
The alu unit is being designed for handling the arithmetic and logical processes of the processor.
processor
sky130A