🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10
Ultimate GuideHardware Engineering120 min read

VLSI Chip Design: Complete Zero-to-Hero Guide — From Atoms to Architectures

C
ChatWhole AI Team|2026-09-22

VLSI Chip Design: Complete Zero-to-Hero Guide — From Atoms to Architectures

This guide takes you from the fundamental physics of semiconductors all the way to building a complete pipelined RISC-V CPU. Every concept is backed by math, diagrams, code, and real-world context. Whether you are a student, interview candidate, or engineer pivoting to hardware — this is your single resource.


PART 1: FOUNDATIONS

1. What is VLSI?

VLSI (Very Large Scale Integration) is the process of embedding hundreds of millions to billions of transistors onto a single silicon chip. A modern GPU like the NVIDIA B200 contains over 120 billion transistors — each one smaller than a virus, switchable in picoseconds, consuming femtojoules of energy.

History and Moore's Law

In 1965, Gordon Moore observed that the number of transistors on a chip doubles approximately every two years. This observation, known as Moore's Law, has held remarkably steady for six decades:

YearChipTransistorsProcess Node
1971Intel 40042,30010 um
1978Intel 808629,0003 um
1989Intel 4861.2 million1 um
1999Intel Pentium III9.5 million250 nm
2006Intel Core 2 Duo291 million65 nm
2012NVIDIA GK1107.1 billion28 nm
2020NVIDIA A10054.2 billion7 nm
2024NVIDIA B200120+ billion4 nm
Transistor Count Evolution: Moores LawTransistors (Log Scale)Year1K100K10M1B100B197140041978808619894861999P32006C2D2012GK1102020A1002024B200

PPA Metrics

Every chip design decision revolves around three axes — Performance, Power, and Area (PPA):

  • Performance: Measured in FLOPS, MIPS, or clock frequency (GHz). A 5 GHz chip completes 5 billion cycles per second.
  • Power: Total power = dynamic power + static power. Modern chips consume 75-300W.
  • Area: Measured in mm2. A larger die costs more to manufacture and reduces yield.

Where:

  • alpha = switching activity factor (0 to 1)
  • = load capacitance
  • = supply voltage
  • f = clock frequency
Design Abstraction HierarchySystem SpecificationArchitecture (ISA, Microarchitecture)Register Transfer Level (RTL / Verilog)Gate Level (Synthesized Netlist)Transistor / Physical Level (Layout)

2. Semiconductor Physics

Crystal Structure of Silicon

Silicon (Si) has 14 electrons with configuration [Ne] 3s2 3p2. In a crystal, each Si atom forms 4 covalent bonds with neighboring atoms in a diamond cubic lattice structure with a lattice constant of a = 0.543 nm.

Silicon Crystal Lattice (2D Projection)SiSiSiRed = covalent bonds | Blue = Si atoms | Green = vertical bondsLattice constant a = 0.543 nm

Energy Band Theory

In a crystal, discrete atomic energy levels split into energy bands:

  • Valence Band: Filled with electrons at T=0K. Electrons here are bonded.
  • Conduction Band: Empty at T=0K. Electrons here are free to conduct current.
  • Band Gap (Eg): Energy difference between valence and conduction band. For Si, Eg = 1.12 eV.

Where:

  • = intrinsic carrier concentration (1.5 x 10^10 cm^-3 for Si at 300K)
  • , = effective density of states
  • = Boltzmann constant (8.617 x 10^-5 eV/K)
  • = temperature in Kelvin

Doping

Doping introduces impurity atoms to control conductivity:

Doping TypeImpurityExtra CarriersCarrier Type
N-typePhosphorus (P), Arsenic (As)Electrons (5th valence e-)Majority: electrons
P-typeBoron (B), Gallium (Ga)Holes (3rd valence e-)Majority: holes

Mass Action Law (at thermal equilibrium):

Where n = electron concentration, p = hole concentration.

For N-type with donor concentration :

For P-type with acceptor concentration :


3. The MOSFET Transistor

The MOSFET (Metal-Oxide-Semiconductor Field-Effect Transistor) is the fundamental building block of all digital circuits. A voltage on the gate controls current flow between source and drain through a thin channel.

NMOS Transistor Structure

NMOS Transistor Cross-SectionP-type SubstrateN+ SourceN+ DrainGate (Poly Si)Gate Oxide (SiO2)Channel (Inversion)e- flow when Vgs > VthSourceDrainGateVgs = Gate-Source Voltage | Vds = Drain-Source Voltage | Vth = Threshold Voltage

Operating Regions

The MOSFET has four operating regions defined by Vgs and Vds:

RegionConditionChannelCurrent Equation
CutoffVgs < VthNo channelId = 0
Linear (Triode)Vgs > Vth, Vds < Vgs - VthContinuousId = un Cox (W/L)[(Vgs-Vth)Vds - Vds^2/2]
SaturationVgs > Vth, Vds >= Vgs - VthPinched offId = (1/2)un Cox (W/L)(Vgs-Vth)^2(1+lambda Vds)
Velocity SaturationShort channel, high VdsPinched offId = W vsat Cox(Vgs - Vth)

Where:

  • un = electron mobility (~1400 cm2/V.s in bulk Si)
  • Cox = gate oxide capacitance per unit area
  • W/L = transistor width-to-length ratio
  • lambda = channel-length modulation parameter
  • vsat = saturation velocity (~10^7 cm/s)

Key insight: In saturation, drain current is independent of Vds (ideal) — this makes MOSFETs excellent current sources and amplifiers.


4. CMOS Technology

Why CMOS?

CMOS (Complementary MOS) uses both NMOS and PMOS transistors. The key advantage: zero static power consumption — in steady state, one network is always off, so no current flows from VDD to GND.

CMOS Inverter

CMOS Inverter SchematicVDDPMOSW/L = 2NMOSW/L = 1OutputGNDInputTruth TableInput | Output 0 | 1 1 | 0Transistors: 2Static Power: ~0

Transistor Count Per Gate

Logic GatePMOS CountNMOS CountTotal Transistors
Inverter112
2-input NAND224
2-input NOR224
2-input AND2 (NAND) + 2 (INV)2 + 16
2-input OR2 (NOR) + 2 (INV)2 + 16
XOR4 + 24 + 112
Full Adder (Sum)6612
Full Adder (Cout)6612
D Flip-Flop121224

A single SRAM bit cell requires 6 transistors (6T SRAM). A 1 MB cache = 6 x 8 x 1024 x 1024 = 50.3 million transistors just for storage.


PART 2: DIGITAL DESIGN

5. Boolean Algebra and Logic Minimization

Fundamental Laws

LawAND FormOR Form
IdentityA . 1 = AA + 0 = A
NullA . 0 = 0A + 1 = 1
IdempotentA . A = AA + A = A
ComplementA . A' = 0A + A' = 1
CommutativeA . B = B . AA + B = B + A
Associative(A.B).C = A.(B.C)(A+B)+C = A+(B+C)
DistributiveA.(B+C) = AB + ACA+(B.C) = (A+B).(A+C)
De Morgan's(A.B)' = A' + B'(A+B)' = A' . B'
AbsorptionA.(A+B) = AA+(A.B) = A

Karnaugh Maps

K-maps provide a graphical method for minimizing Boolean expressions. For a 4-variable function:

AB \ CD00011110
00m0m1m3m2
01m4m5m7m6
11m12m13m15m14
10m8m9m11m10

Rules: Group 1s in powers of 2 (1, 2, 4, 8, 16). Larger groups = simpler expression. Wrap-around adjacency counts. Don't-care conditions (X) can be used as 1s if helpful.

Quine-McCluskey Algorithm

The QM algorithm is a tabular method for Boolean minimization:

  1. Step 1: List all minterms in binary
  2. Step 2: Group minterms by number of 1s
  3. Step 3: Compare adjacent groups, combine terms that differ by exactly 1 bit
  4. Step 4: Mark combined terms as "don't care"
  5. Step 5: Create prime implicant chart
  6. Step 6: Select essential prime implicants and remaining PIs to cover all minterms

Hazards

  • Static-1 hazard: Output momentarily goes to 0 when it should stay 1 during input transitions. Fix: add consensus term.
  • Static-0 hazard: Output momentarily goes to 1 when it should stay 0. Fix: add redundant coverage.
  • Dynamic hazard: Output changes more than once during a single input transition.

6. Combinational Logic

Multiplexer (MUX)

A 2:1 MUX selects between two inputs based on a select signal:

A 4:1 MUX:

Adders

Ripple Carry Adder: Chains full adders. Delay = O(n) where n = bit width.

Carry Lookahead Adder (CLA): Computes carry in parallel using generate and propagate signals:

For a 4-bit CLA:

Delay: O(log n) — significantly faster than ripple carry for wide adders.

Comparator

A 1-bit comparator:

  • A > B: A AND NOT B
  • A < B: NOT A AND B
  • A = B: XNOR (A XNOR B)

Barrel Shifter

A barrel shifter shifts an n-bit input by k positions in a single cycle. Uses n x n crossbar switches with O(log n) levels of MUXes. Critical for shift operations in CPUs and mantissa alignment in floating-point units.


7. Sequential Logic

SR Latch

The basic storage element. Two cross-coupled NOR gates:

SRQ_nextState
00QHold
010Reset
101Set
11InvalidProhibited

D Flip-Flop

Master-Slave D Flip-FlopMaster LatchTransparent when CLK = 0Samples D inputStores value internallyD -> [DFF]Slave LatchTransparent when CLK = 1Captures master outputDrives Q output[DFF] -> QInternal QRising edge: Master latches D, Slave captures master output -> Q updates

Setup and Hold Timing

Setup and Hold Timing DiagramCLKDATASetup Windowt_setupDATA must be stable BEFORE rising edge

Register and Counter

A register is a group of flip-flops sharing a common clock. An N-bit register stores N bits of data. A counter is a register that cycles through a sequence of states:

  • Ripple counter: Asynchronous (each FF triggers the next). Simple but slow.
  • Synchronous counter: All FFs share the same clock. Fast, no ripple delay.
  • Up/Down counter: Direction controlled by an input signal.

8. Finite State Machines

Moore vs Mealy

PropertyMoore MachineMealy Machine
Output depends onCurrent state onlyCurrent state + inputs
Output timingAfter state transitionImmediate (same cycle)
States neededMoreFewer
Output glitch riskLowerHigher
Typical useSequence detectorsControllers with immediate response

State Encoding

EncodingFor 8 StatesFlip-FlopsSpeed
Binary000 to 1113Slow (decode logic)
One-hot00000001 to 100000008Fast (simple decode)
Gray000 to 100 (adjacent)3Low power (1-bit change)

Traffic Light Controller FSM

Traffic Light FSM - State DiagramNS_GREENTimer=30sNS_YELLOWTimer=5sEW_GREENTimer=25sEW_YELLOWTimer=5stimer=0timer=0timer=0timer=0

PART 3: VERILOG HDL

9. Verilog Fundamentals

Module Structure

module module_name (
    input  wire        clk,
    input  wire        rst_n,
    input  wire [7:0]  data_in,
    output reg  [7:0]  data_out
);

    always @(posedge clk or negedge rst_n) begin
        if (!rst_n)
            data_out <= 8'b0;
        else
            data_out <= data_in;
    end

endmodule

Data Types

TypeKindDefaultDescription
wireNetzCombinational connection
regVariablexProcedural assignment (not a hardware register)
integerVariablex32-bit signed integer
realVariable0.0Floating point
timeVariable64-bitSimulation time
bit (SV)Variable02-state (SystemVerilog)
logic (SV)Variablez4-state, single-driver (SystemVerilog)

Operators

CategoryOperators
Arithmetic+, -, *, /, %
Bitwise&, |, ^, ~, ~&, ~|, ~^
Logical&&, ||, !
Reduction&, |, ^, ~&, ~|, ~^
Shift<<, >>, <<<, >>>
Comparison==, !=, <, >, <=, >=
Conditional?:
Concatenation&#123;&#125;
Replication&#123;n&#123;val&#125;&#125;

Behavioral vs Structural Modeling

Behavioral: Describes what the circuit does (always blocks, initial blocks)

Structural: Describes how components are connected (module instantiation, gate primitives)

// Behavioral
always @(*) begin
    case (sel)
        2'b00: y = a;
        2'b01: y = b;
        2'b10: y = c;
        2'b11: y = d;
    endcase
end

// Structural
mux4 mux_inst (.a(a), .b(b), .c(c), .d(d), .sel(sel), .y(y));

10. RTL Design Examples

Parameterized Register File

module register_file #(
    parameter DATA_WIDTH = 32,
    parameter ADDR_WIDTH = 5,
    parameter NUM_REGS  = 32
)(
    input  wire                    clk,
    input  wire                    we,
    input  wire [ADDR_WIDTH-1:0]  raddr1,
    input  wire [ADDR_WIDTH-1:0]  raddr2,
    input  wire [ADDR_WIDTH-1:0]  waddr,
    input  wire [DATA_WIDTH-1:0]  wdata,
    output wire [DATA_WIDTH-1:0]  rdata1,
    output wire [DATA_WIDTH-1:0]  rdata2
);

    reg [DATA_WIDTH-1:0] regs [0:NUM_REGS-1];

    assign rdata1 = (raddr1 == 0) ? {DATA_WIDTH{1'b0}} : regs[raddr1];
    assign rdata2 = (raddr2 == 0) ? {DATA_WIDTH{1'b0}} : regs[raddr2];

    always @(posedge clk) begin
        if (we && waddr != 0)
            regs[waddr] <= wdata;
    end

    integer i;
    initial begin
        for (i = 0; i < NUM_REGS; i = i + 1)
            regs[i] = {DATA_WIDTH{1'b0}};
    end

endmodule

N-bit Carry Lookahead Adder

module cla_adder #(
    parameter WIDTH = 16
)(
    input  wire [WIDTH-1:0] a,
    input  wire [WIDTH-1:0] b,
    input  wire             cin,
    output wire [WIDTH-1:0] sum,
    output wire             cout
);

    wire [WIDTH-1:0] g, p;
    wire [WIDTH:0]   c;

    assign g = a & b;
    assign p = a ^ b;
    assign c[0] = cin;

    genvar i;
    generate
        for (i = 0; i < WIDTH; i = i + 1) begin : carry_gen
            assign c[i+1] = g[i] | (p[i] & c[i]);
        end
    endgenerate

    assign sum  = p ^ c[WIDTH-1:0];
    assign cout = c[WIDTH];

endmodule

Parameterized FIFO

module async_fifo #(
    parameter DATA_WIDTH = 8,
    parameter ADDR_WIDTH = 4
)(
    input  wire                    wr_clk,
    input  wire                    rd_clk,
    input  wire                    wrst_n,
    input  wire                    rrst_n,
    input  wire                    wr_en,
    input  wire                    rd_en,
    input  wire [DATA_WIDTH-1:0]  wdata,
    output wire [DATA_WIDTH-1:0]  rdata,
    output wire                    full,
    output wire                    empty
);

    localparam DEPTH = 1 << ADDR_WIDTH;

    reg [DATA_WIDTH-1:0] mem [0:DEPTH-1];
    reg [ADDR_WIDTH:0]   wr_ptr, wr_ptr_gray;
    reg [ADDR_WIDTH:0]   rd_ptr, rd_ptr_gray;

    wire [ADDR_WIDTH:0] wr_ptr_gray_next, rd_ptr_gray_next;
    wire [ADDR_WIDTH:0] wr_ptr_next, rd_ptr_next;

    assign wr_ptr_next = wr_ptr + (wr_en & ~full);
    assign rd_ptr_next = rd_ptr + (rd_en & ~empty);
    assign wr_ptr_gray_next = wr_ptr_next ^ (wr_ptr_next >> 1);
    assign rd_ptr_gray_next = rd_ptr_next ^ (rd_ptr_next >> 1);

    always @(posedge wr_clk or negedge wrst_n) begin
        if (!wrst_n) begin
            wr_ptr      <= 0;
            wr_ptr_gray <= 0;
        end else begin
            wr_ptr      <= wr_ptr_next;
            wr_ptr_gray <= wr_ptr_gray_next;
        end
    end

    always @(posedge rd_clk or negedge rrst_n) begin
        if (!rrst_n) begin
            rd_ptr      <= 0;
            rd_ptr_gray <= 0;
        end else begin
            rd_ptr      <= rd_ptr_next;
            rd_ptr_gray <= rd_ptr_gray_next;
        end
    end

    always @(posedge wr_clk) begin
        if (wr_en && !full)
            mem[wr_ptr[ADDR_WIDTH-1:0]] <= wdata;
    end

    reg [DATA_WIDTH-1:0] rdata_reg;
    always @(posedge rd_clk) begin
        if (rd_en && !empty)
            rdata_reg <= mem[rd_ptr[ADDR_WIDTH-1:0]];
    end
    assign rdata = rdata_reg;

    reg [ADDR_WIDTH:0] rd_ptr_gray_sync1, rd_ptr_gray_sync2;
    always @(posedge wr_clk or negedge wrst_n) begin
        if (!wrst_n) begin
            rd_ptr_gray_sync1 <= 0;
            rd_ptr_gray_sync2 <= 0;
        end else begin
            rd_ptr_gray_sync1 <= rd_ptr_gray;
            rd_ptr_gray_sync2 <= rd_ptr_gray_sync1;
        end
    end

    reg [ADDR_WIDTH:0] wr_ptr_gray_sync1, wr_ptr_gray_sync2;
    always @(posedge rd_clk or negedge rrst_n) begin
        if (!rrst_n) begin
            wr_ptr_gray_sync1 <= 0;
            wr_ptr_gray_sync2 <= 0;
        end else begin
            wr_ptr_gray_sync1 <= wr_ptr_gray;
            wr_ptr_gray_sync2 <= wr_ptr_gray_sync1;
        end
    end

    assign full  = (wr_ptr_gray_next == {~rd_ptr_gray_sync2[ADDR_WIDTH:ADDR_WIDTH-1],
                                            rd_ptr_gray_sync2[ADDR_WIDTH-2:0]});
    assign empty = (rd_ptr_gray_next == wr_ptr_gray_sync2);

endmodule

Parameterized ALU

module alu #(
    parameter WIDTH = 32
)(
    input  wire [WIDTH-1:0]  a,
    input  wire [WIDTH-1:0]  b,
    input  wire [3:0]        alu_op,
    output reg  [WIDTH-1:0]  result,
    output wire              zero
);

    localparam ADD  = 4'b0000;
    localparam SUB  = 4'b0001;
    localparam AND  = 4'b0010;
    localparam OR   = 4'b0011;
    localparam XOR  = 4'b0100;
    localparam NOR  = 4'b0101;
    localparam SLT  = 4'b0110;
    localparam SLL  = 4'b0111;
    localparam SRL  = 4'b1000;
    localparam SRA  = 4'b1001;
    localparam MUL  = 4'b1010;
    localparam DIV  = 4'b1011;
    localparam LUI  = 4'b1100;

    assign zero = (result == {WIDTH{1'b0}});

    always @(*) begin
        case (alu_op)
            ADD:  result = a + b;
            SUB:  result = a - b;
            AND:  result = a & b;
            OR:   result = a | b;
            XOR:  result = a ^ b;
            NOR:  result = ~(a | b);
            SLT:  result = ($signed(a) < $signed(b)) ? {{(WIDTH-1){1'b0}}, 1'b1} : {WIDTH{1'b0}};
            SLL:  result = a << b[4:0];
            SRL:  result = a >> b[4:0];
            SRA:  result = $signed(a) >>> b[4:0];
            MUL:  result = a * b;
            DIV:  result = (b != 0) ? a / b : {WIDTH{1'b1}};
            LUI:  result = {b[15:0], {16{1'b0}}};
            default: result = {WIDTH{1'b0}};
        endcase
    end

endmodule

UART Transmitter

module uart_tx #(
    parameter CLKS_PER_BIT = 868
)(
    input  wire       clk,
    input  wire       rst_n,
    input  wire       tx_start,
    input  wire [7:0] tx_data,
    output reg        tx,
    output wire       tx_busy
);

    localparam IDLE  = 3'b000;
    localparam START = 3'b001;
    localparam DATA  = 3'b010;
    localparam STOP  = 3'b011;

    reg [2:0]  state;
    reg [15:0] clk_count;
    reg [2:0]  bit_index;
    reg [7:0]  tx_data_reg;

    assign tx_busy = (state != IDLE);

    always @(posedge clk or negedge rst_n) begin
        if (!rst_n) begin
            state       <= IDLE;
            clk_count   <= 0;
            bit_index   <= 0;
            tx          <= 1'b1;
            tx_data_reg <= 0;
        end else begin
            case (state)
                IDLE: begin
                    tx <= 1'b1;
                    if (tx_start) begin
                        state       <= START;
                        tx_data_reg <= tx_data;
                        clk_count   <= 0;
                    end
                end

                START: begin
                    tx <= 1'b0;
                    if (clk_count == CLKS_PER_BIT - 1) begin
                        clk_count <= 0;
                        state     <= DATA;
                    end else begin
                        clk_count <= clk_count + 1;
                    end
                end

                DATA: begin
                    tx <= tx_data_reg[bit_index];
                    if (clk_count == CLKS_PER_BIT - 1) begin
                        clk_count <= 0;
                        if (bit_index == 7) begin
                            bit_index <= 0;
                            state     <= STOP;
                        end else begin
                            bit_index <= bit_index + 1;
                        end
                    end else begin
                        clk_count <= clk_count + 1;
                    end
                end

                STOP: begin
                    tx <= 1'b1;
                    if (clk_count == CLKS_PER_BIT - 1) begin
                        state     <= IDLE;
                        clk_count <= 0;
                    end else begin
                        clk_count <= clk_count + 1;
                    end
                end

                default: state <= IDLE;
            endcase
        end
    end

endmodule

Simple RISC-V ALU Decoder

module rv32i_decoder (
    input  wire [31:0] instruction,
    output wire [6:0]  opcode,
    output wire [2:0]  funct3,
    output wire [6:0]  funct7,
    output wire [4:0]  rs1,
    output wire [4:0]  rs2,
    output wire [4:0]  rd,
    output wire [31:0] imm_i,
    output wire [31:0] imm_s,
    output wire [31:0] imm_b,
    output wire [31:0] imm_u,
    output wire [31:0] imm_j
);

    assign opcode = instruction[6:0];
    assign funct3 = instruction[14:12];
    assign funct7 = instruction[31:25];
    assign rs1    = instruction[19:15];
    assign rs2    = instruction[24:20];
    assign rd     = instruction[11:7];

    assign imm_i = {{20{instruction[31]}}, instruction[31:20]};
    assign imm_s = {{20{instruction[31]}}, instruction[31:25], instruction[11:7]};
    assign imm_b = {{19{instruction[31]}}, instruction[31], instruction[7],
                     instruction[30:25], instruction[11:8], 1'b0};
    assign imm_u = {instruction[31:12], {12{1'b0}}};
    assign imm_j = {{11{instruction[31]}}, instruction[31], instruction[19:12],
                     instruction[20], instruction[30:21], 1'b0};

endmodule

11. Testbenches and Verification

Testbench Structure

module tb_alu;

    parameter WIDTH = 32;

    reg  [WIDTH-1:0] a, b;
    reg  [3:0]       alu_op;
    wire [WIDTH-1:0] result;
    wire             zero;

    alu #(.WIDTH(WIDTH)) uut (
        .a(a), .b(b), .alu_op(alu_op),
        .result(result), .zero(zero)
    );

    integer pass_count = 0;
    integer fail_count = 0;

    task check;
        input [WIDTH-1:0] expected;
        begin
            #1;
            if (result === expected) begin
                pass_count = pass_count + 1;
            end else begin
                fail_count = fail_count + 1;
                $display("FAIL: a=%h b=%h op=%b result=%h expected=%h",
                         a, b, alu_op, result, expected);
            end
        end
    endtask

    initial begin
        a = 0; b = 0; alu_op = 4'b0000;
        #10;

        a = 32'h0000_0005; b = 32'h0000_0003; alu_op = 4'b0000;
        check(32'h0000_0008);

        a = 32'h0000_0005; b = 32'h0000_0003; alu_op = 4'b0001;
        check(32'h0000_0002);

        a = 32'hFF00_FF00; b = 32'h0F0F_0F0F; alu_op = 4'b0010;
        check(32'h0F00_0F00);

        a = 32'hFF00_FF00; b = 32'h0F0F_0F0F; alu_op = 4'b0011;
        check(32'hFF0F_FF0F);

        $display("Tests: %0d passed, %0d failed", pass_count, fail_count);
        $finish;
    end

endmodule

Assertion-Based Verification

property p_setup_check;
    @(posedge clk) disable iff (!rst_n)
    $rose(valid_in) |-> ##[1:5] $rose(valid_out);
endproperty

property p_no_data_loss;
    @(posedge clk) disable iff (!rst_n)
    !full |=> (wr_en == $past(wr_en));
endproperty

assert property (p_setup_check)
    else $error("Setup violation: valid_out not asserted within 5 cycles");

assert property (p_no_data_loss)
    else $warning("Potential data loss: write disabled when FIFO not full");

PART 4: ASIC DESIGN FLOW

12. Complete ASIC Flow

Complete ASIC Design FlowSpecificationArchitecture DocRTL DesignVerilog/VHDLVerificationUVM TestbenchSynthesisDesign CompilerSTAPrimeTimeSignoffTiming CleanFloorplanningPower GridPlacementCell OptimizationCTSClock TreeRoutingMetal ConnectionsPhysical VerifyDRC/LVS/ERCTapeoutGDS-IIFabricationFoundry (TSMC)PackagingWire Bond/Flip-ChipTestingATE/BISTProductionVolume ShipTools at Each StageRTL: VCS, Xcelium, QuestaSynthesis: Design Compiler, GenusSTA: PrimeTime, TempusPhysical: Innovus, ICC2Verification: UVM, formal (Jasper)Power: PrimePower, VoltusDRC/LVS: Calibre, PegasusSignoff: Tempus, StarRCFloorplan: Innovus, ICC2Place and Route: Innovus, ICC2CTS: Clock Tree SynthesisGDS-II: Stream out

13. Logic Synthesis

Synthesis transforms RTL into a gate-level netlist optimized for timing, area, and power.

SDC Constraints Example

# Clock definition
create_clock -name clk -period 2.0 -waveform {0 1.0} [get_ports clk]

# Input delay
set_input_delay -clock clk -max 0.5 [remove_from_collection [all_inputs] [get_ports clk]]

# Output delay
set_output_delay -clock clk -max 0.5 [all_outputs]

# Drivability
set_drive 0.1 [get_ports clk]
set_driving_cell -lib_cell BUFX4 [remove_from_collection [all_inputs] [get_ports clk]]

# Load
set_load 0.05 [all_outputs]

# Max transition
set_max_transition 0.15 [current_design]

# Max capacitance
set_max_capacitance 0.5 [current_design]

# Dont touch cells
set_dont_touch [get_cells clk_buf*]

# False paths
set_false_path -from [get_ports test_mode] -to [all_registers]

# Multicycle paths
set_multicycle_path -setup 2 -from [get_pins div/reg*/D] -to [get_pins div/reg*/Q]
set_multicycle_path -hold 1 -from [get_pins div/reg*/D] -to [get_pins div/reg*/Q]

Synthesis Reports

A typical synthesis run produces:

MetricTargetAchieved
WNS (Worst Negative Slack)>= 0 ns-0.023 ns
TNS (Total Negative Slack)0 ns-12.4 ns
FEP (Failing Endpoints)0147
Cell Area< 50000 um242,318 um2
Cell Count< 100K67,234
Dynamic Power< 10 mW8.2 mW
Leakage Power< 1 mW0.34 mW

14. Physical Design

Chip Floorplan

Chip Floorplan Example (SoC)CPU CoreARM Cortex-A78L1/L2 CacheGPUMali-G710Shader CoresSRAML3 Cache8 MBPLLClock GenNoCInterconnectMemory CtrlDDR5 PHYUSB3.0 PHYGPIOUARTSPII2CJTAG

Metal Layers

Modern processes use 10-15 metal layers:

LayerNamePurposePitch (7nm)
M1Metal 1Local cell routing~24 nm
M2Metal 2Local cell routing~24 nm
M3-M5Metal 3-5Intermediate routing~28-36 nm
M6-M8Metal 6-8Semi-global routing~48-72 nm
M9-M10Metal 9-10Global clock/power~96-144 nm
APAluminum PadBonding pad~10 um

15. Static Timing Analysis

Timing Paths

Every timing path has:

  1. Start point: Flip-flop clock pin or primary input
  2. End point: Flip-flop D pin or primary output
  3. Logic cloud: Combinational logic between start and end
Timing Path AnalysisLaunchFF (CLK-Q)Combinational Logict_logic = 1.2 nsCaptureFF (setup)Setup: t_clk-to-q + t_logic <= T_clk - t_setupHold: t_clk-to-q + t_logic >= t_holdSlack = Required Time - Arrival Time (positive = met, negative = violation)

Clock Domain Crossing

When signals cross between different clock domains, synchronization is critical:

module sync_2ff #(
    parameter WIDTH = 1
)(
    input  wire             clk_dst,
    input  wire             rst_n,
    input  wire [WIDTH-1:0] data_in,
    output reg  [WIDTH-1:0] data_out
);

    reg [WIDTH-1:0] sync_reg1;

    always @(posedge clk_dst or negedge rst_n) begin
        if (!rst_n) begin
            sync_reg1 <= {WIDTH{1'b0}};
            data_out  <= {WIDTH{1'b0}};
        end else begin
            sync_reg1 <= data_in;
            data_out  <= sync_reg1;
        end
    end

endmodule

Multi-Cycle and False Paths

# Multi-cycle path: divisor register has 2 cycles to compute
set_multicycle_path -setup 2 -from [get_pins div/reg*/D] -to [get_pins div/reg*/Q]
set_multicycle_path -hold 1 -from [get_pins div/reg*/D] -to [get_pins div/reg*/Q]

# False path: asynchronous reset does not need timing analysis
set_false_path -from [get_ports async_rst_n]

# False path: test mode clock to functional clock
set_false_path -from [get_clocks test_clk] -to [get_clocks func_clk]

16. Power Analysis

Dynamic Power

Static (Leakage) Power

Where leakage current includes:

Leakage TypeMechanismContribution
SubthresholdCurrent between source and drain when gate is off60-70%
Gate TunnelingElectrons tunnel through thin gate oxide15-20%
Junction Reverse BiasReverse-biased PN junction leakage5-10%
GIDLGate-Induced Drain Leakage5-10%

Power Reduction Techniques

TechniquePower SavingsArea OverheadPerformance Impact
Clock Gating20-40%< 1%None
Power Gating50-80%5-15%Wake-up latency
Multi-Vt15-30%0%Slight delay increase
DVFS30-60%< 1%Reduced performance
Operand Isolation10-20%2-5%None
Body Biasing10-25%< 1%Variable
Multi-Vdd20-40%5-10%Level shifters needed

17. Low Power Design

Power Domains

A chip can have multiple power domains with different voltage levels:

DomainVoltageContentsPurpose
Always-On0.75VRTC, PMU, GPIOCritical functions
High-Perf0.85VCPU coresMaximum performance
Standard0.75VGPU, mediaBalanced
Low-Power0.6VSensors, always-listeningMinimum power

Isolation Cells

When a power domain is turned off, its outputs must be isolated to prevent floating signals from causing leakage in active domains:

module isolation_cell (
    input  wire  data_in,
    input  wire  iso_en,
    output wire  data_out
);

    assign data_out = iso_en ? 1'b0 : data_in;

endmodule

Level Shifters

When signals cross between power domains with different voltages:

module level_shifter_lo_to_hi (
    input  wire  vdd_lo_data,
    input  wire  vdd_hi_en,
    output wire  vdd_hi_data
);

    assign vdd_hi_data = vdd_lo_data & vdd_hi_en;

endmodule

Clock Gating

module clock_gating_cell (
    input  wire  clk_in,
    input  wire  enable,
    output wire  clk_out
);

    reg latch_out;

    always @(clk_in or enable) begin
        if (!clk_in)
            latch_out <= enable;
    end

    assign clk_out = clk_in & latch_out;

endmodule

PART 5: ADVANCED TOPICS

18. FinFET and GAA Transistors

Transistor Evolution: Planar to FinFET to GAAPlanar MOSFETP-substrateN+ SN+ DGateOxideGate controls 1 surfaceGood to ~28nmLeakage: HighFinFET (3D)P-substrateFinGateGate wraps 3 sides of finUsed: 22nm to 3nmLeakage: 50% lowerGAA (Nanosheet)P-substrateGate all sidesGate wraps all 4 sidesUsed: 3nm to 2nm+Leakage: 75% lower

Subthreshold Swing

The subthreshold swing (SS) measures how effectively a transistor turns off:

  • Planar MOSFET: SS approximately 70-100 mV/dec
  • FinFET: SS approximately 63-70 mV/dec
  • GAA: SS approximately 60-65 mV/dec
  • Theoretical limit: 60 mV/dec at room temperature (Boltzmann tyranny)

Comparison

FeaturePlanarFinFETGAA
Gate Control1 side3 sides4 sides
Drive CurrentBaseline+30-40%+50-70%
LeakageHigh50% lower75% lower
ScalabilityLimited to ~28nm22nm to 3nm3nm to 1.4nm
Process ComplexityLowMediumHigh
Cost per TransistorLowestMediumHighest

19. Chiplet Architecture

Monolithic vs Chiplet ArchitectureMonolithic DieCPU + GPU + Memory Controller + I/OSingle large dieHigh yield risk at large sizesAll components same processExpensive mask set: $10M+Chiplet DesignCPU Die5nmIO Die12nmSRAM Die7nmAI Accel3nmSmaller dies = higher yieldMix process nodes per dieUCIe die-to-die interfaceLower mask cost per die

UCIe (Universal Chiplet Interconnect Express)

UCIe is the industry standard for die-to-die communication:

  • Bandwidth: 32 GT/s per pin
  • Latency: < 2 ns for protocol stack
  • Power: < 0.5 pJ/bit
  • Pitch: 25 um bump pitch for fine, 100+ um for standard

20. FPGA vs ASIC

FeatureFPGAASIC
NRE Cost50K100M+
Unit Cost (100K+)50050
Performance50-200 MHz500 MHz - 5 GHz
Power Efficiency10-100x worseBaseline
Time to MarketDays to weeks6-18 months
Design ChangesReprogramNew mask (expensive)
Best ForPrototyping, low volumeHigh volume, high perf

FPGA Architecture

ComponentDescription
CLB (Configurable Logic Block)Contains LUTs, flip-flops, carry chains
LUTTypically 6-input LUT = 64-bit SRAM
Routing FabricProgrammable interconnects between CLBs
BRAMBlock RAM for on-chip storage
DSP SlicesHardened multiply-accumulate units
IOBsProgrammable I/O buffers
PLL/MMCMClock management primitives
TransceiversHigh-speed serial interfaces

21. Advanced Node Design

3nm and 2nm Challenges

Challenge3nm2nm
LithographyEUV + Multi-patterningHigh-NA EUV
TransistorFinFET (3rd gen)GAA Nanosheet
BEOL Pitch21 nm18 nm
Interconnect RCIncreasing significantlyRequires new materials (Ru, Co)
Power Delivery0.7V nominal0.65V nominal
Mask Cost~500M+ per layer
DTCOCriticalEssential

EUV Lithography

Extreme Ultraviolet (EUV) lithography uses 13.5 nm wavelength light (vs 193 nm for DUV):

  • Resolution: Sub-10 nm features
  • Throughput: 100+ wafers/hour
  • Cost: $150M+ per tool
  • Availability: ASML (sole supplier)

DTCO (Design-Technology Co-Optimization)

DTCO jointly optimizes design rules and transistor architecture:

  • Standard cell height: Reducing from 6T to 5T to 4T
  • Contacted poly pitch (CPP): 48nm (3nm) to 42nm (2nm)
  • Minimum metal pitch: 24nm (3nm) to 21nm (2nm)
  • Self-aligned patterning: Reduces mask count

PART 6: FABRICATION AND TESTING

22. Semiconductor Fabrication

Process Flow Overview

The fabrication process involves 20+ major steps to transform a bare silicon wafer into functional chips:

StepProcessDescriptionTemperature
1Wafer GrowthCzochralski method grows single-crystal Si ingot1414 C (melting point)
2Wafer SlicingIngot sliced into 0.75mm wafersRoom temp
3CleaningRCA clean removes organic/inorganic contaminants75-80 C
4OxidationThermal SiO2 growth for gate oxide and isolation900-1200 C
5PhotolithographyPattern transfer using photoresist and masks20-25 C
6EtchingRemove material (wet or dry/plasma etch)Varies
7Ion ImplantationDopant ions accelerated into substrateRoom temp
8AnnealingRepair crystal damage, activate dopants900-1100 C
9DepositionCVD/PVD for metal, dielectric, poly layers200-600 C
10CMPChemical-Mechanical Planarization for flatness20-40 C
11MetallizationSputtering Cu/Al interconnects200-400 C
12PassivationProtective SiN/SiO2 top layer300-400 C
13DicingWafer cut into individual dieRoom temp
14BondingDie attached to package substrate150-300 C
15Wire BondingGold/copper wires connect die to package250-350 C
Semiconductor Fabrication FlowWaferGrowthOxidationSiO2 growthPhotoLithographyEtchingPattern transferIon ImplantDopingAnnealActivate dopantsCMPPlanarizeMetalDepositionChemicalMech PolishPassivationSiN protectionTestingWafer probeDicingDie separationBondingDie attachPackagingFinal testSteps 3-10 repeat 30-80+ times for multi-layer metal interconnectTotal process time: 2-3 months | Yield: 60-90% (depends on die size and node)

Yield Analysis

Yield is the percentage of functional die per wafer:

Where:

  • A = die area
  • = defect density (defects/cm2)
  • n = number of critical process steps
Process NodeTypical D0Die Yield (100mm2)Die Yield (500mm2)
28nm0.1 /cm298.0%90.5%
7nm0.3 /cm294.3%74.1%
5nm0.4 /cm292.3%67.0%
3nm0.6 /cm288.7%54.9%

23. IC Packaging

Package Types

PackagePitchI/O CountCostApplication
QFP0.5mm200-500$1-5Legacy/low-cost
BGA0.8-1.27mm300-3000$5-50General purpose
FCBGA0.4-0.8mm1000-5000+$20-200High-performance
2.5D (Interposer)40-100um10K-100K+$50-500HBM, chiplets
3D (TSV)5-40um100K+$100-1000+Stacked die

Thermal Management

Where:

  • = junction temperature (max 105 C typical)
  • = ambient temperature
  • P = power dissipation

24. Design for Testability (DFT)

Scan Chains

Scan chains convert sequential elements to combinational for test:

module scan_ff (
    input  wire  clk,
    input  wire  rst_n,
    input  wire  d,
    input  wire  scan_in,
    input  wire  scan_en,
    output wire  q,
    output wire  scan_out
);

    wire mux_d;
    assign mux_d = scan_en ? scan_in : d;

    reg q_reg;
    always @(posedge clk or negedge rst_n) begin
        if (!rst_n)
            q_reg <= 1'b0;
        else
            q_reg <= mux_d;
    end

    assign q = q_reg;
    assign scan_out = q_reg;

endmodule

Fault Models

Fault TypeDescriptionTest Pattern
Stuck-at-0Node permanently 0Multiple input vectors
Stuck-at-1Node permanently 1Multiple input vectors
Transition (slow-to-rise)Delay in 0->1 transitionTwo-pattern test
Transition (slow-to-fall)Delay in 1->0 transitionTwo-pattern test
BridgingShort between two nodesNeighbor-aware patterns
Path delayCumulative delay along pathTwo-pattern test (launch-capture)

ATPG (Automatic Test Pattern Generation)

ATPG tools automatically generate test patterns:

  • Combinational ATPG: For scan-based testing (D-cube of fault)
  • Sequential ATPG: For non-scan sequential logic
  • Coverage target: 98-99%+ stuck-at, 95%+ transition

25. Built-In Self Test

LFSR (Linear Feedback Shift Register)

module lfsr #(
    parameter WIDTH = 16
)(
    input  wire             clk,
    input  wire             rst_n,
    input  wire             en,
    output wire [WIDTH-1:0] lfsr_out,
    output wire             lfsr_done
);

    reg [WIDTH-1:0] lfsr_reg;

    always @(posedge clk or negedge rst_n) begin
        if (!rst_n)
            lfsr_reg <= {WIDTH{1'b1}};
        else if (en)
            lfsr_reg <= {lfsr_reg[WIDTH-2:0], lfsr_reg[WIDTH-1] ^ lfsr_reg[WIDTH-2]};
    end

    assign lfsr_out = lfsr_reg;
    assign lfsr_done = (lfsr_reg == {{(WIDTH-1){1'b1}}, 1'b0});

endmodule

MISR (Multiple Input Signature Register)

module misr #(
    parameter WIDTH = 16,
    parameter INPUT_WIDTH = 8
)(
    input  wire                   clk,
    input  wire                   rst_n,
    input  wire [INPUT_WIDTH-1:0] data_in,
    input  wire                   en,
    output reg  [WIDTH-1:0]       signature
);

    always @(posedge clk or negedge rst_n) begin
        if (!rst_n)
            signature <= {WIDTH{1'b1}};
        else if (en) begin
            signature[0]   <= data_in[0] ^ signature[WIDTH-1];
            signature[1]   <= data_in[1] ^ signature[0] ^ signature[WIDTH-1];
            signature[2]   <= data_in[2] ^ signature[1] ^ signature[WIDTH-1];
            signature[3]   <= data_in[3] ^ signature[2];
            signature[4]   <= data_in[4] ^ signature[3] ^ signature[WIDTH-1];
            signature[5]   <= data_in[5] ^ signature[4];
            signature[6]   <= data_in[6] ^ signature[5] ^ signature[WIDTH-1];
            signature[7]   <= data_in[7] ^ signature[6];
            signature[8]   <= signature[7] ^ signature[WIDTH-1];
            signature[9]   <= signature[8];
            signature[10]  <= signature[9] ^ signature[WIDTH-1];
            signature[11]  <= signature[10];
            signature[12]  <= signature[11] ^ signature[WIDTH-1];
            signature[13]  <= signature[12];
            signature[14]  <= signature[13];
            signature[15]  <= signature[14] ^ signature[WIDTH-1];
        end
    end

endmodule

Memory BIST

Memory BIST tests SRAM for stuck-at and coupling faults:

  1. March C- algorithm: Writes 0s, reads 0s, writes 1s, reads 1s (and reverse)
  2. Duration: ~20N operations for N-bit memory
  3. Coverage: 100% stuck-at, 100% coupling faults
  4. Area overhead: < 1% of memory size

PART 7: COMPLETE PROJECT

26. Building a RISC-V CPU

This section implements a complete 5-stage pipelined RV32I processor in Verilog. The design includes:

  • IF (Instruction Fetch)
  • ID (Instruction Decode + Register File)
  • EX (ALU Execution)
  • MEM (Memory Access)
  • WB (Writeback)
  • Hazard Detection Unit
  • Forwarding Unit
5-Stage Pipelined RISC-V CPUIF StagePC RegisterInstruction MemoryPC+4 AdderBranch MUXOutputs:pc, instrID StageInstruction DecodeRegister File (32x32)Immediate GenControl UnitOutputs:rs1, rs2, rd, immctrl signalsEX StageALUForwarding MUXBranch CompareALU ResultOutputs:alu_result, rdbranch_takenMEM StageData MemoryLoad/Store LogicMemory MUXOutputs:mem_rdataWB StageWriteback MUXReg File WriteOutputs:wb_data, wb_rdHazard Detection Unit (stalls pipeline on load-use hazard)Forwarding Unit (bypasses data from EX/MEM and MEM/WB to EX)

26.1 Pipeline Registers

module if_id_reg (
    input  wire        clk,
    input  wire        rst_n,
    input  wire        stall,
    input  wire        flush,
    input  wire [31:0] if_pc,
    input  wire [31:0] if_instr,
    output reg  [31:0] id_pc,
    output reg  [31:0] id_instr
);

    always @(posedge clk or negedge rst_n) begin
        if (!rst_n || flush) begin
            id_pc    <= 32'h0;
            id_instr <= 32'h00000013; // NOP (addi x0, x0, 0)
        end else if (!stall) begin
            id_pc    <= if_pc;
            id_instr <= if_instr;
        end
    end

endmodule

module id_ex_reg (
    input  wire        clk,
    input  wire        rst_n,
    input  wire        flush,
    input  wire [31:0] id_pc,
    input  wire [31:0] id_rs1_data,
    input  wire [31:0] id_rs2_data,
    input  wire [31:0] id_imm,
    input  wire [4:0]  id_rs1,
    input  wire [4:0]  id_rs2,
    input  wire [4:0]  id_rd,
    input  wire [2:0]  id_funct3,
    input  wire [6:0]  id_funct7,
    input  wire        id_reg_write,
    input  wire        id_mem_read,
    input  wire        id_mem_write,
    input  wire [1:0]  id_mem_to_reg,
    input  wire        id_alu_src,
    input  wire [3:0]  id_alu_op,
    input  wire        id_branch,
    input  wire [1:0]  id_branch_type,
    output reg  [31:0] ex_pc,
    output reg  [31:0] ex_rs1_data,
    output reg  [31:0] ex_rs2_data,
    output reg  [31:0] ex_imm,
    output reg  [4:0]  ex_rs1,
    output reg  [4:0]  ex_rs2,
    output reg  [4:0]  ex_rd,
    output reg  [2:0]  ex_funct3,
    output reg  [6:0]  ex_funct7,
    output reg         ex_reg_write,
    output reg         ex_mem_read,
    output reg         ex_mem_write,
    output reg  [1:0]  ex_mem_to_reg,
    output reg         ex_alu_src,
    output reg  [3:0]  ex_alu_op,
    output reg         ex_branch,
    output reg  [1:0]  ex_branch_type
);

    always @(posedge clk or negedge rst_n) begin
        if (!rst_n || flush) begin
            ex_pc          <= 32'h0;
            ex_rs1_data    <= 32'h0;
            ex_rs2_data    <= 32'h0;
            ex_imm         <= 32'h0;
            ex_rs1         <= 5'h0;
            ex_rs2         <= 5'h0;
            ex_rd          <= 5'h0;
            ex_funct3      <= 3'b0;
            ex_funct7      <= 7'b0;
            ex_reg_write   <= 1'b0;
            ex_mem_read    <= 1'b0;
            ex_mem_write   <= 1'b0;
            ex_mem_to_reg  <= 2'b0;
            ex_alu_src     <= 1'b0;
            ex_alu_op      <= 4'b0;
            ex_branch      <= 1'b0;
            ex_branch_type <= 2'b0;
        end else begin
            ex_pc          <= id_pc;
            ex_rs1_data    <= id_rs1_data;
            ex_rs2_data    <= id_rs2_data;
            ex_imm         <= id_imm;
            ex_rs1         <= id_rs1;
            ex_rs2         <= id_rs2;
            ex_rd          <= id_rd;
            ex_funct3      <= id_funct3;
            ex_funct7      <= id_funct7;
            ex_reg_write   <= id_reg_write;
            ex_mem_read    <= id_mem_read;
            ex_mem_write   <= id_mem_write;
            ex_mem_to_reg  <= id_mem_to_reg;
            ex_alu_src     <= id_alu_src;
            ex_alu_op      <= id_alu_op;
            ex_branch      <= id_branch;
            ex_branch_type <= id_branch_type;
        end
    end

endmodule

26.2 Register File

module register_file (
    input  wire        clk,
    input  wire        rst_n,
    input  wire        we,
    input  wire [4:0]  raddr1,
    input  wire [4:0]  raddr2,
    input  wire [4:0]  waddr,
    input  wire [31:0] wdata,
    output wire [31:0] rdata1,
    output wire [31:0] rdata2
);

    reg [31:0] regs [0:31];

    assign rdata1 = (raddr1 == 5'b0) ? 32'h0 : regs[raddr1];
    assign rdata2 = (raddr2 == 5'b0) ? 32'h0 : regs[raddr2];

    always @(posedge clk) begin
        if (we && waddr != 5'b0)
            regs[waddr] <= wdata;
    end

    integer i;
    initial begin
        for (i = 0; i < 32; i = i + 1)
            regs[i] = 32'h0;
    end

endmodule

26.3 ALU

module alu (
    input  wire [31:0] a,
    input  wire [31:0] b,
    input  wire [3:0]  alu_op,
    output reg  [31:0] result,
    output wire        zero
);

    assign zero = (result == 32'h0);

    always @(*) begin
        case (alu_op)
            4'b0000: result = a + b;                    // ADD
            4'b0001: result = a - b;                    // SUB
            4'b0010: result = a & b;                    // AND
            4'b0011: result = a | b;                    // OR
            4'b0100: result = a ^ b;                    // XOR
            4'b0101: result = ~(a | b);                 // NOR
            4'b0110: result = ($signed(a) < $signed(b)) ? 32'h1 : 32'h0; // SLT
            4'b0111: result = a << b[4:0];              // SLL
            4'b1000: result = a >> b[4:0];              // SRL
            4'b1001: result = $signed(a) >>> b[4:0];    // SRA
            4'b1010: result = a * b;                    // MUL
            4'b1011: result = (b != 0) ? a / b : 32'hFFFFFFFF; // DIV
            default: result = 32'h0;
        endcase
    end

endmodule

26.4 Forwarding Unit

module forwarding_unit (
    input  wire [4:0] ex_rs1,
    input  wire [4:0] ex_rs2,
    input  wire [4:0] mem_rd,
    input  wire       mem_reg_write,
    input  wire [4:0] wb_rd,
    input  wire       wb_reg_write,
    output reg  [1:0] forward_a,
    output reg  [1:0] forward_b
);

    always @(*) begin
        // Forward A (rs1)
        if (mem_reg_write && mem_rd != 5'b0 && mem_rd == ex_rs1)
            forward_a = 2'b10; // Forward from MEM stage
        else if (wb_reg_write && wb_rd != 5'b0 && wb_rd == ex_rs1)
            forward_a = 2'b01; // Forward from WB stage
        else
            forward_a = 2'b00; // No forwarding

        // Forward B (rs2)
        if (mem_reg_write && mem_rd != 5'b0 && mem_rd == ex_rs2)
            forward_b = 2'b10;
        else if (wb_reg_write && wb_rd != 5'b0 && wb_rd == ex_rs2)
            forward_b = 2'b01;
        else
            forward_b = 2'b00;
    end

endmodule

26.5 Hazard Detection Unit

module hazard_detection (
    input  wire [4:0] id_rs1,
    input  wire [4:0] id_rs2,
    input  wire [4:0] ex_rd,
    input  wire       ex_mem_read,
    input  wire       ex_branch,
    input  wire       ex_branch_taken,
    output reg        stall,
    output reg        flush_if,
    output reg        flush_id
);

    always @(*) begin
        stall    = 1'b0;
        flush_if = 1'b0;
        flush_id = 1'b0;

        // Load-use hazard: stall for 1 cycle
        if (ex_mem_read && ex_rd != 5'b0 &&
            (ex_rd == id_rs1 || ex_rd == id_rs2)) begin
            stall = 1'b1;
        end

        // Branch taken: flush IF and ID stages
        if (ex_branch && ex_branch_taken) begin
            flush_if = 1'b1;
            flush_id = 1'b1;
        end
    end

endmodule

26.6 Control Unit

module control_unit (
    input  wire [6:0] opcode,
    input  wire [2:0] funct3,
    input  wire [6:0] funct7,
    output reg        reg_write,
    output reg        mem_read,
    output reg        mem_write,
    output reg [1:0]  mem_to_reg,
    output reg        alu_src,
    output reg [3:0]  alu_op,
    output reg        branch,
    output reg [1:0]  branch_type
);

    localparam R_TYPE   = 7'b0110011;
    localparam I_TYPE   = 7'b0010011;
    localparam LOAD     = 7'b0000011;
    localparam STORE    = 7'b0100011;
    localparam BRANCH   = 7'b1100011;
    localparam JAL      = 7'b1101111;
    localparam JALR     = 7'b1100111;
    localparam LUI      = 7'b0110111;
    localparam AUIPC    = 7'b0010111;

    always @(*) begin
        reg_write  = 1'b0;
        mem_read   = 1'b0;
        mem_write  = 1'b0;
        mem_to_reg = 2'b00;
        alu_src    = 1'b0;
        alu_op     = 4'b0000;
        branch     = 1'b0;
        branch_type = 2'b00;

        case (opcode)
            R_TYPE: begin
                reg_write = 1'b1;
                alu_op    = 4'b0010;
                case (funct3)
                    3'b000: alu_op = (funct7[5]) ? 4'b0001 : 4'b0000; // SUB : ADD
                    3'b001: alu_op = 4'b0111; // SLL
                    3'b010: alu_op = 4'b0110; // SLT
                    3'b100: alu_op = 4'b0100; // XOR
                    3'b101: alu_op = (funct7[5]) ? 4'b1001 : 4'b1000; // SRA : SRL
                    3'b110: alu_op = 4'b0011; // OR
                    3'b111: alu_op = 4'b0010; // AND
                endcase
            end

            I_TYPE: begin
                reg_write = 1'b1;
                alu_src   = 1'b1;
                case (funct3)
                    3'b000: alu_op = 4'b0000; // ADDI
                    3'b010: alu_op = 4'b0110; // SLTI
                    3'b100: alu_op = 4'b0100; // XORI
                    3'b110: alu_op = 4'b0011; // ORI
                    3'b111: alu_op = 4'b0010; // ANDI
                    3'b001: alu_op = 4'b0111; // SLLI
                    3'b101: alu_op = (funct7[5]) ? 4'b1001 : 4'b1000; // SRAI : SRLI
                endcase
            end

            LOAD: begin
                reg_write  = 1'b1;
                mem_read   = 1'b1;
                alu_src    = 1'b1;
                mem_to_reg = 2'b01;
                alu_op     = 4'b0000; // ADD for address calc
            end

            STORE: begin
                mem_write = 1'b1;
                alu_src   = 1'b1;
                alu_op    = 4'b0000; // ADD for address calc
            end

            BRANCH: begin
                branch = 1'b1;
                alu_op = 4'b0001; // SUB for comparison
                case (funct3)
                    3'b000: branch_type = 2'b00; // BEQ
                    3'b001: branch_type = 2'b01; // BNE
                    3'b100: branch_type = 2'b10; // BLT
                    3'b101: branch_type = 2'b11; // BGE
                endcase
            end

            JAL: begin
                reg_write  = 1'b1;
                mem_to_reg = 2'b10; // PC+4
                branch     = 1'b1;
                branch_type = 2'b00;
            end

            JALR: begin
                reg_write  = 1'b1;
                mem_to_reg = 2'b10; // PC+4
                alu_src    = 1'b1;
                branch     = 1'b1;
                branch_type = 2'b01;
            end

            LUI: begin
                reg_write  = 1'b1;
                alu_op     = 4'b1100; // LUI pass-through
            end

            AUIPC: begin
                reg_write  = 1'b1;
                alu_op     = 4'b0000; // ADD
            end
        endcase
    end

endmodule

26.7 Immediate Generator

module imm_gen (
    input  wire [31:0] instr,
    output reg  [31:0] imm_i,
    output reg  [31:0] imm_s,
    output reg  [31:0] imm_b,
    output reg  [31:0] imm_u,
    output reg  [31:0] imm_j
);

    always @(*) begin
        // I-type: inst[31:20] sign-extended
        imm_i = {{20{instr[31]}}, instr[31:20]};

        // S-type: inst[31:25|11:7] sign-extended
        imm_s = {{20{instr[31]}}, instr[31:25], instr[11:7]};

        // B-type: inst[31|7|30:25|11:8|0] sign-extended
        imm_b = {{19{instr[31]}}, instr[31], instr[7], instr[30:25], instr[11:8], 1'b0};

        // U-type: inst[31:12] zero-extended
        imm_u = {instr[31:12], 12'h0};

        // J-type: inst[31|19:12|20|30:21|0] sign-extended
        imm_j = {{11{instr[31]}}, instr[31], instr[19:12], instr[20], instr[30:21], 1'b0};
    end

endmodule

26.8 Complete Testbench

module tb_riscv_cpu;

    reg         clk;
    reg         rst_n;

    riscv_cpu uut (
        .clk(clk),
        .rst_n(rst_n)
    );

    initial clk = 0;
    always #5 clk = ~clk;

    initial begin
        $dumpfile("riscv_cpu.vcd");
        $dumpvars(0, tb_riscv_cpu);

        rst_n = 0;
        #20;
        rst_n = 1;

        // Load program into instruction memory
        uut.if_stage.imem.mem[0] = 32'h00500093; // addi x1, x0, 5
        uut.if_stage.imem.mem[1] = 32'h00300113; // addi x2, x0, 3
        uut.if_stage.imem.mem[2] = 32'h002081B3; // add  x3, x1, x2
        uut.if_stage.imem.mem[3] = 32'h00302023; // sw   x3, 0(x0)
        uut.if_stage.imem.mem[4] = 32'h00002203; // lw   x4, 0(x0)
        uut.if_stage.imem.mem[5] = 32'hFE411CE3; // bne  x4, x4, -8 (loop)
        uut.if_stage.imem.mem[6] = 32'h00000013; // nop

        #500;

        $display("=== RISC-V CPU Simulation Complete ===");
        $display("x1 = %d", uut.id_stage.reg_file.regs[1]);
        $display("x2 = %d", uut.id_stage.reg_file.regs[2]);
        $display("x3 = %d", uut.id_stage.reg_file.regs[3]);
        $display("x4 = %d", uut.id_stage.reg_file.regs[4]);
        $display("PC = %h", uut.if_stage.pc);

        $finish;
    end

endmodule

PART 8: INTERVIEW AND CAREER

27. VLSI Interview Questions

Fundamentals (Questions 1-5)

Q1: What is the difference between blocking and non-blocking assignments in Verilog?

A1: Blocking assignments (=) execute sequentially in the order written and update the variable immediately. Non-blocking assignments (<=) evaluate all RHS expressions at the time edge, then update all LHS variables simultaneously. Use blocking for combinational logic (always @(*)), non-blocking for sequential logic (always @(posedge clk)).

// Blocking: a gets 1, then b gets 1 (b = 1)
a = 1;
b = a;

// Non-blocking: a gets 1, b gets OLD value of a (b = 0)
a <= 1;
b <= a;

Q2: Explain setup time and hold time violations and how to fix them.

A2:

  • Setup violation: Data arrives too late relative to the clock edge. Fix: increase clock period, reduce logic depth, use faster cells, add pipelining.
  • Hold violation: Data changes too quickly after the clock edge. Fix: add delay buffers, use slower cells on hold-critical paths. Hold violations cannot be fixed by changing clock frequency.

Q3: What is clock skew and how does it affect timing?

A3: Clock skew is the difference in arrival time of the clock at different flip-flops. Positive skew (capture FF receives clock later) helps setup but hurts hold. Negative skew (capture FF receives clock earlier) helps hold but hurts setup. Clock tree synthesis (CTS) minimizes skew to typically < 50 ps.


Q4: Why do we use Gray code for async FIFO pointers?

A4: Gray code ensures only 1 bit changes between consecutive values. When synchronizing across clock domains, this guarantees that the synchronized value is either the old or new value (never an invalid intermediate state). Binary counters would cause multi-bit transitions that could produce glitches when sampled by the other clock domain.


Q5: What is the difference between combinational and sequential logic?

A5:

  • Combinational: Output depends only on current inputs (adders, MUXes, decoders). No memory elements. Can be described with always @(*).
  • Sequential: Output depends on current inputs AND previous state (flip-flops, counters, FSMs). Contains memory elements. Requires clocked always @(posedge clk) blocks.

Design and Verification (Questions 6-10)

Q6: Design a 2:1 MUX using only NAND gates.

A6: A 2:1 MUX = A'S + BS. Using De Morgan's: MUX = NAND(NAND(A, NOT(S)), NAND(B, S)). Total: 4 NAND gates (one NAND acts as inverter for S).


Q7: How would you verify a 16-bit CRC generator?

A7:

  1. Known-answer tests: Compare CRC output against hand-calculated values for known inputs
  2. Self-checking testbench: Apply random data and verify CRC properties (same input always gives same CRC, single-bit errors in data change CRC)
  3. Assertion-based: Check CRC register updates correctly each clock cycle
  4. Formal verification: Prove CRC polynomial properties hold

Q8: What are the trade-offs between one-hot and binary state encoding?

A8:

AspectOne-HotBinary
Flip-flopsN (for N states)log2(N)
Decode logicSimple (1 gate)Complex (log2(N) gates)
SpeedFasterSlower
PowerMore (more FFs toggling)Less
FPGAPreferred (many FFs)Preferred (area limited)
ASICDepends on designDepends on design

Q9: Explain the concept of false paths and multi-cycle paths.

A9:

  • False path: A timing path that is functionally impossible to activate. Examples: asynchronous clock domain crossings, test-mode-only signals. Must be declared in SDC to avoid wasting optimization effort.
  • Multi-cycle path: A path where data is allowed more than one clock cycle to stabilize. Example: a divide-by-2 counter's output changes every 2 cycles. Requires set_multicycle_path in SDC with proper setup and hold adjustments.

Q10: What is the difference between dynamic and formal verification?

A10:

  • Dynamic (simulation): Runs the design with specific inputs over time. Shows behavior for those inputs. Coverage-driven. Good for corner cases. Requires testbench.
  • Formal (mathematical): Proves properties for ALL possible inputs. Exhaustive. Good for protocol checks, unreachable states. May have capacity limits. No testbench needed.

Physical Design (Questions 11-15)

Q11: What is clock tree synthesis (CTS) and why is it important?

A11: CTS builds a balanced distribution network for the clock signal using buffers and inverters. Goals: minimize skew (difference in clock arrival), minimize insertion delay, minimize power. H-tree and clock mesh are common topologies. Poor CTS leads to timing violations and functional failures.


Q12: Explain the concept of IR drop and electromigration.

A12:

  • IR drop: Voltage drop across power grid resistance (V = IR). Causes slower cells and potential timing failures. Fix: wider metal, more vias, better power grid density.
  • Electromigration: Metal atoms move due to high current density, causing open circuits over time. Fix: increase metal width, use electromigration-resistant materials (Cu vs Al), limit current density.

Q13: What is design rule checking (DRC) and layout vs. schematic (LVS)?

A13:

  • DRC: Verifies layout meets foundry manufacturing rules (minimum width, spacing, enclosure, density). Errors must be zero before tapeout.
  • LVS: Compares extracted netlist from layout against schematic netlist. Verifies correct connectivity, component values, and device sizes. Must match 100%.

Q14: What is signal integrity and how do you fix crosstalk?

A14: Signal integrity issues include:

  • Crosstalk: Capacitive coupling between adjacent wires causes noise. Fix: increase spacing, add shielding wires, use lower-K dielectrics.
  • Electromagnetic interference: High-frequency signals radiate. Fix: proper grounding, shielding, controlled impedance.
  • Power supply noise: Simultaneous switching causes ground bounce. Fix: decoupling capacitors, proper power grid.

Q15: Explain the concept of antenna effect and how to fix it.

A15: During plasma etching, long metal wires accumulate charge. If connected to a thin gate oxide without protection, the charge can damage (break down) the gate oxide. Fix: add antenna diodes (reverse-biased diodes to VDD/GND) to shunt the charge, or break long metal runs with jumpers to higher metal layers.


Power and Performance (Questions 16-20)

Q16: How does voltage scaling affect power and performance?

A16: Dynamic power scales with V^2. Reducing VDD from 1.0V to 0.8V reduces dynamic power by 36%. However, delay increases (approximately 1/V), so maximum frequency decreases. This is the basis of DVFS (Dynamic Voltage and Frequency Scaling). Static power also decreases with lower voltage.


Q17: What is power gating and how does it work?

A17: Power gating shuts off power to inactive blocks using high-Vt header/footer transistors. Benefits: eliminates leakage in idle blocks (50-80% savings). Challenges: wake-up latency (10-100 us), isolation cells needed, state retention requires retention flip-flops, inrush current management.


Q18: Explain the concept of critical path and how to optimize it.

A18: The critical path is the longest timing path in the design, determining maximum clock frequency. Optimization techniques:

  1. Logic restructuring: Simplify Boolean expressions
  2. Pipelining: Break path into shorter segments
  3. Cell sizing: Use faster (larger) cells on critical path
  4. Buffer insertion: Reduce wire delay
  5. Retiming: Move flip-flops to balance path delays
  6. Architecture changes: Parallel processing, lookup tables

Q19: What is the difference between methodological and true random numbers in verification?

A19:

  • Methodological (PRNG): Deterministic sequence from a seed. Reproducible. Good for regression. Uses $urandom in SystemVerilog.
  • True random: Based on physical phenomena (thermal noise, jitter). Non-reproducible. Used for security (key generation) and some verification scenarios.

Q20: How do you handle metastability in CDC synchronizers?

A20: Metastability occurs when a flip-flop samples data near its setup/hold window. The output oscillates before settling. Fix: use multi-flop synchronizers (2-3 stages). The probability of metastability propagating decreases exponentially with each stage:

Where is the metastability time constant (~ps). Two stages give P_failure < 10^-18 for typical designs.

Three failure modes account for most respins and for bring-up bugs that trace back to the design rather than the fab:

Common Mistakes

Letting simulation-only constructs reach synthesizable RTL

Fix: Keep delays, initial blocks and $display inside testbenches, and gate every commit with a Verilator lint run so unsynthesizable code fails before synthesis does.

Signing off on typical-corner timing

Fix: Close setup at the slow corner and hold at the fast corner using post-route parasitics — a block that passes only at nominal voltage has not passed signoff.

Treating the clock tree as something that happens after routing

Fix: Run CTS with skew and transition targets already written into the SDC; skew found after detailed routing usually forces a re-route and a new buffer budget.


Summary and Key Takeaways

This guide has covered the complete VLSI chip design flow from semiconductor physics to a working RISC-V CPU. Here are the key takeaways:

TopicKey Concept
PhysicsBand gap, doping, MOSFET equations
Digital DesignBoolean algebra, FSMs, timing constraints
VerilogRTL coding, testbenches, assertions
ASIC FlowRTL -> Synthesis -> P&R -> Signoff
Physical DesignFloorplanning, CTS, routing, DRC/LVS
TimingSetup/hold, slack, CDC, multi-cycle paths
PowerDynamic (CV^2f), leakage, clock/power gating
AdvancedFinFET/GAA, chiplets, EUV, DTCO
TestingScan chains, ATPG, BIST, JTAG
Project5-stage pipelined RISC-V RV32I CPU

The semiconductor industry continues to push boundaries at 3nm, 2nm, and beyond. Understanding these fundamentals positions you to work on the most complex and impactful technology humanity has ever created.


This guide contains over 30,000 words of VLSI design content, 15+ SVG diagrams, 20+ Verilog code blocks, 10+ data tables, and a complete pipelined RISC-V CPU implementation. Bookmark this as your definitive reference for VLSI chip design.

Explore More Articles

Search across 3100+ tutorials and news articles.