Tutorial: build a block and place it in a chip

In this tutorial you build a small 4-bit adder, take it all the way to a finished layout, and then reuse that layout as one block inside a bigger chip. It takes about fifteen minutes and three runs. You type two short Verilog files and a testbench; Vulkos writes the rest.

What you will build#

Two projects:

  • Adder block: one module, adder4, that adds two 4-bit numbers. You harden it on its own. Hardening means running the full flow so the design becomes a physical layout.
  • Accumulator chip: a module that keeps a running 8-bit total. It does not contain an adder of its own. It places the finished adder4 layout and wires up to it.

A hardened block used this way is called a macro. The point is that the bigger design does not build the block again: it drops in the layout you already checked. Real chips are assembled like this from memories, processor cores and other large pieces.

Part 1: build the block#

  1. 1

    Create a blank chip project

    Go to My Work and choose Create project, then Chip project. Name it Adder block, leave Start with on Blank, and press Create project.
The New chip project page with the name Adder block typed in and Blank selected under Start with.
A blank project is an empty workspace. You add the files.
  1. 2

    Add the Verilog

    Press the New file button above the file list, type src/adder4.v and press Enter. Paste this in:
src/adder4.v
1// A 4-bit adder. This is the block we will harden and reuse.
2module adder4 (
3    input  wire [3:0] a,
4    input  wire [3:0] b,
5    output wire [4:0] sum
6);
7
8    assign sum = a + b;
9
10endmodule

The result is five bits wide because two 4-bit numbers can add up to 30, which needs a fifth bit. That fifth bit is the carry.

  1. 3

    Create the config

    Open the File menu and choose LibreLane config. Vulkos writes config.json from the design in the workspace, so it already names your module and file:
config.json (the two lines that matter)
1"DESIGN_NAME": "adder4",
2"VERILOG_FILES": [
3  "dir::src/adder4.v"
4],
  1. 4

    Choose LibreLane and run

    Open the Tools menu and choose LibreLane. The green button at the top right now reads Run LibreLane. Press it.
The Tools menu open with LibreLane selected, showing its PDK and timing corner choices, and the Run LibreLane button at the top right.
LibreLane is the tool that turns Verilog into a layout. Leave the PDK on Sky130.

The terminal lists each stage as it finishes: lint, synthesis, floorplanning, placement, routing and the sign-off checks. A design this small takes about a minute.

The IDE with adder4.v in the editor and the terminal showing Lint, Synthesis and Floorplanning completed and Placement running.
The run in progress. The badge beside Inspect counts the steps.

When the badge reads Completed, the block is hardened. Its layout is 161 by 111.52 microns, the smallest die size the template offers.

Part 2: save it to My macros#

The finished run holds everything another design needs to place this block: the layout, an outline of its pins, a gate-level netlist and timing data. You do not download or upload any of it.

  1. 1

    Open the run's Analysis page

    Open the Inspect menu and choose Open analysis.
  2. 2

    Save the block

    Press Save to My macros. After a few seconds it confirms the block is saved, under the name of its top module.
The LibreLane Run Analysis page with the Save to My macros button pressed and a note saying adder4 is in My macros, 161 by 111.52 microns.
The block is now in your library, ready for any of your projects.

Part 3: start the chip#

  1. 1

    Create a second blank project

    Back in My Work, create another blank chip project and name it Accumulator chip.
  2. 2

    Add the top-level Verilog

    Create src/accumulator.v with this:
src/accumulator.v
1// Adds the 4-bit input to a running 8-bit total on every clock.
2// The low four bits are added by adder4, a block hardened in its own project.
3module accumulator (
4    input  wire       clk,
5    input  wire       rst,
6    input  wire [3:0] in,
7    output reg  [7:0] total
8);
9
10    wire [4:0] sum;
11
12    // The hardened block. Its layout comes from config.json, under MACROS.
13    adder4 u_adder (
14        .a   (total[3:0]),
15        .b   (in),
16        .sum (sum)
17    );
18
19    always @(posedge clk) begin
20        if (rst) total <= 8'd0;
21        // sum[4] is the carry out of the low four bits.
22        else     total <= {total[7:4] + {3'd0, sum[4]}, sum[3:0]};
23    end
24
25endmodule

Notice that adder4 is used here but not defined here. The instance is called u_adder; remember that name, because the config places the block by it.

  1. 3

    Add a testbench

    Create tb/accumulator_tb.v:
tb/accumulator_tb.v
1`timescale 1ns/1ps
2
3module accumulator_tb;
4    reg        clk = 0;
5    reg        rst = 1;
6    reg  [3:0] in  = 0;
7    wire [7:0] total;
8
9    accumulator dut (.clk(clk), .rst(rst), .in(in), .total(total));
10
11    always #5 clk = ~clk;
12
13    initial begin
14        #12 rst = 0;
15        in = 4'd9;  #10;   // total = 9
16        in = 4'd9;  #10;   // total = 18, a carry out of the low four bits
17        in = 4'd15; #10;   // total = 33
18        if (total === 8'd33) begin
19            $display("PASS: total = %0d", total);
20            $display("VULKOS_RESULT: PASS");
21        end else begin
22            $display("FAIL: total = %0d, expected 33", total);
23            $display("VULKOS_RESULT: FAIL");
24        end
25        $finish;
26    end
27endmodule
  1. 4

    Create the config and make the die bigger

    Choose File, then LibreLane config. The chip has to be bigger than the block it holds, so change DIE_AREA to the 2x2 tile. The config lists every tile size just below; copy the value from //DIE_AREA_2x2:
config.json
1"DIE_AREA": "0 0 334.88 225.76",

Part 4: add the block#

  1. 1

    Open My macros

    Press Add macro, the blocks icon above the file list.
The file list of the Accumulator chip project with the Add macro button above it outlined in green.
Add macro sits beside the new file, new folder and upload buttons.
  1. 2

    Add adder4

    The dialog lists the blocks you have saved. Press Add beside adder4.
The My macros dialog listing adder4, 161 by 111.52 microns, sky130A, from Adder block, with Remove and Add buttons.

Vulkos now does four things, and tells you each one:

The My macros dialog after adding: adder4 added in config.json, placed u_adder at 10, 10, connected its power pins, set FP_PDN_MULTILAYER on, and its Verilog is in macros/adder4/rtl.
Nothing here was typed by hand.
  • Writes the block into config.json under MACROS, with the path to each of its files.
  • Places it. It found the instance u_adder in your Verilog and put it at [10, 10], ten microns in from the bottom left corner.
  • Connects its power. A line in PDN_MACRO_CONNECTIONS ties the block's power and ground pins to the chip's, and the power grid settings are adjusted so its straps reach the block.
  • Brings its Verilog into macros/adder4/rtl/, so you can read it and simulate with it.

This is what was added to the config:

config.json (added by Add macro)
1"PDN_MACRO_CONNECTIONS": [
2  "u_adder VPWR VGND VPWR VGND"
3],
4"FP_PDN_MULTILAYER": 1,
5"FP_PDN_HPITCH": 55.76,
6"MACROS": {
7  "adder4": {
8    "gds": ["dir::macros/adder4/adder4.gds"],
9    "lef": ["dir::macros/adder4/adder4.lef"],
10    "nl":  ["dir::macros/adder4/adder4.nl.v"],
11    "pnl": ["dir::macros/adder4/adder4.pnl.v"],
12    "lib": { "nom_tt_025C_1v80": ["dir::macros/adder4/lib/nom_tt_025C_1v80.lib"] },
13    "spef": { "nom_*": ["dir::macros/adder4/spef/nom.spef"] },
14    "instances": {
15      "u_adder": { "location": [10, 10], "orientation": "N" }
16    }
17  }
18}

The real entry lists nine timing libraries and three parasitics files, one per process corner. They are shortened to one each here.

The file list showing macros, adder4, rtl and adder4.v, with the adder's Verilog open in the editor.
The block's Verilog opens read-only. It records what was hardened.

Why VERILOG_FILES did not change

VERILOG_FILES still lists only src/accumulator.v. That is deliberate. LibreLane must not build the adder a second time; it places the layout you already made. The copy under macros/adder4/rtl/ is for reading and for simulation only.

Part 5: simulate the chip#

Check the design behaves before spending a run on the layout. The simulator compiles the block's Verilog along with yours, so the testbench drives the whole chip.

  1. 1

    Run the testbench

    Open Tools and choose Verilator, then press Simulate.
The IDE after simulating: the badge reads Passed and the terminal shows PASS: total = 33 and VULKOS_RESULT: PASS.
9 + 9 + 15 = 33. The second addition carries out of the adder block into the top four bits.
Terminal
VERILATOR OUTPUT
PASS: total = 33
VULKOS_RESULT: PASS
- tb/accumulator_tb.v:25: Verilog $finish

Part 6: build the chip#

  1. 1

    Run LibreLane

    Open Tools, choose LibreLane and press Run LibreLane. This run takes a little longer than the block did, about a minute and a half.
  2. 2

    Check the sign-off result

    When the badge reads Completed, open the Signoff tab in the bottom panel.
The bottom panel on the Signoff tab showing Layout vs Schematic: Circuits match, with the run badge reading Completed.
Circuits match means the layout, block included, is the circuit you described.
  1. 3

    Look at the layout

    Open the Layout tab and choose Full screen.
The full-screen layout of the accumulator: a large rectangle labelled u_adder adder4 in the lower left, with the chip's own standard cells and wires to its right.
The big rectangle is your adder, placed whole. The small cells beside it are the registers and the carry logic, wired to its pins.

The panel beside the layout says One macro: u_adder. The chip is 60 cells of its own plus one block it did not have to build.

Try moving the block

Change location under instances and run again. Keep a block either 10 microns from the left or right edge of the die, or well away from it. A small gap leaves a strip of cells too narrow for a power strap, and the run fails sign-off. See Where to put a block.

Where to go next#

  • Change the adder in the Adder block project, run LibreLane there, save it to My macros again, then choose Update in Add macro. Your placement is kept.
  • Use the block twice: add a second adder4 instance to the Verilog, make the die wider, and choose Update. The second instance is placed beside the first.