๐Ÿ“˜ Project ยท learning-1

4-Bit Counter โ€” Full PDA

A simple synchronous counter taken through the complete VLSI flow: simulation โ†’ coverage โ†’ Yosys synthesis โ†’ OpenROAD floorplan, placement & routing.

Verilog Yosys OpenROAD Icarus Verilog
๐Ÿ“
RTL
Mycounter.v
๐Ÿ”ฌ
Simulate
iverilog
โš™๏ธ
Synthesize
Yosys
๐Ÿ—๏ธ
PDA
OpenROAD
โœ…
Layout
DEF + GDS
01

Design Entry โ€” Mycounter.v

A 4-bit synchronous up-counter with reset

๐Ÿ“„ Mycounter.vVerilog
module Mycounter (
    input clk,
    input rst,
    output reg [3:0] out
);

    always @(posedge clk) begin
        if (rst)
            out <= 4'b0000;
        else
            out <= out + 1;
    end

endmodule
๐Ÿ’ก
Simple by design. This 15-line counter is the perfect first project โ€” small enough to understand every gate in the synthesized netlist, yet complete enough to run through all PDA stages.
02

Simulation โ€” Verify the Counter

Compile & run with Icarus Verilog, view waveforms with GTKWave

๐Ÿ“„ Testbench.vVerilog
module Testbench;
    reg clk, rst;
    wire [3:0] out;

    Mycounter uut (.clk(clk), .rst(rst), .out(out));

    initial begin clk = 0; forever #5 clk = ~clk; end

    initial begin
        $dumpfile("count.vcd");
        $dumpvars(0, Testbench);
        rst = 1; #20; rst = 0; #200;
        $finish;
    end

    initial $monitor("Time=%t | rst=%b | out=%d", $time, rst, out);
endmodule
๐Ÿ–ฅ๏ธ Terminal
# Compile RTL + testbench
$ iverilog -o Mycounter Mycounter.v Testbench.v

# Run simulation
$ vvp Mycounter

# View waveforms
$ gtkwave count.vcd
03

Synthesis โ€” RTL to Gates (Yosys)

Map behavioral Verilog to Nangate45 standard cells

๐Ÿ“„ yosys_run.tclTcl
# 1. Read source
read_verilog Mycounter.v

# 2. Synthesis
synth -top Mycounter

# 3. Map to Nangate45 library
dfflibmap -liberty Nangate45_typ.lib
abc -liberty Nangate45_typ.lib

# 4. Clean and Write
clean
write_verilog Mycounter_synth.v

# 5. Reports
stat -liberty Nangate45_typ.lib
๐Ÿ–ฅ๏ธ Terminal
$ yosys -s yosys_run.tcl

Synthesis Results

14
Total Cells
4
Flip-Flops
27
Area (ยตmยฒ)
7
Cell Types
Cell Count Role
DFF_X1 4 D Flip-Flops (4-bit counter register)
INV_X1 1 Inverter
NOR2_X1 4 2-input NOR gates
XNOR2_X1 1 2-input XNOR gate
NAND3_X1 1 3-input NAND gate
AND2_X1 1 2-input AND gate
AOI21_X1 1 AND-OR-Invert complex gate

Files Generated

File Origin Purpose
Mycounter_synth.v ๐Ÿค– Yosys Gate-level netlist โ†’ input to OpenROAD
Mycounter_synth.png ๐Ÿค– Yosys Circuit schematic visualization
04

Physical Design (OpenROAD)

Floorplan โ†’ Place โ†’ CTS โ†’ Route โ†’ Layout

๐Ÿ“„ Mycounter.sdcSDC
# 10ns clock = 100 MHz
create_clock -name clk -period 10.0 [get_ports clk]

PDA Flow Stages

1
Read Design Load liberty, LEF, synthesized netlist, SDC constraints
2
Floorplan Die: 11ร—11 ยตm โ€” Core: 7.7ร—7.7 ยตm (2ยตm margins)
3
Tapcells Insert substrate/well contacts for latch-up prevention
4
Placement Global placement (density 0.5) โ†’ detailed legalization
5
Clock Tree Synthesis Balanced clock distribution using BUF_X4 buffers
6
Routing Global route โ†’ detailed route on metal layers
7
Reports & Output Timing, area, power โ†’ write Mycounter.def + Mycounter.gds
๐Ÿ–ฅ๏ธ Terminal
$ openroad openroad_run.tcl

๐Ÿ“ Complete File Map

File Origin Stage Purpose
Mycounter.v โœ๏ธ Written Design Synthesizable RTL
Testbench.v โœ๏ธ Written Simulate Testbench
yosys_run.tcl โœ๏ธ Written Synthesize Yosys script
Mycounter.sdc โœ๏ธ Written PDA Timing constraints
openroad_run.tcl โœ๏ธ Written PDA OpenROAD script
Mycounter_synth.v ๐Ÿค– Yosys Synthesize Gate-level netlist
Mycounter_synth.png ๐Ÿค– Yosys Synthesize Circuit schematic
Mycounter.def ๐Ÿค– OpenROAD PDA Final layout (DEF)
count.vcd ๐Ÿค– iverilog Simulate Waveform dump

Commands Cheat Sheet

# 1. Simulate
$ iverilog -o Mycounter Mycounter.v Testbench.v && vvp Mycounter

# 2. Synthesize
$ yosys -s yosys_run.tcl

# 3. Physical Design
$ openroad openroad_run.tcl