Verilog(.v)와 SystemVerilog(.sv) 파일이란 무엇인가요?

Verilog(.v)와 SystemVerilog(.sv) 파일이란 무엇인가요?
Photo by Ilya Pavlov / Unsplash

Verilog(.v)와 SystemVerilog(.sv)는 반도체 설계에서 가장 널리 사용되는 HDL(Hardware Description Language) 파일입니다. RTL 설계부터 gate-level netlist까지, 설계 flow 전반에서 사용됩니다. 이 글에서는 두 파일의 구조, 문법, 그리고 RTL-to-GDS flow에서의 역할을 정리합니다.

참고로! RTL 설계할 때 본인의 팀이 어떤 Verilog를 사용하는지 알아야합니다. 예를들어 IEEE1491-2001 Style을 사용하는지 이런것들입니다.

Verilog(.v)의 기본 구조

Verilog 파일은 module 단위로 구성됩니다. 하나의 .v 파일에 하나 또는 여러 module을 정의할 수 있으며, 각 module은 port 선언, wire/reg 선언, logic 기술로 구성됩니다.

// simple_adder.v
module simple_adder (
    input  wire [7:0] a,
    input  wire [7:0] b,
    input  wire       cin,
    output wire [7:0] sum,
    output wire       cout
);

    assign {cout, sum} = a + b + cin;

endmodule

이 예제는 8-bit adder를 기술합니다. inputoutput으로 port 방향을 선언하고, assign으로 combinational logic을 기술합니다. RTL 설계에서는 이런 module들을 계층적으로 인스턴스화하여 전체 SoC를 구성합니다.

RTL Verilog vs Gate-Level Netlist Verilog

같은 .v 확장자를 사용하지만, RTL Verilog와 gate-level netlist는 내용이 크게 다릅니다.

RTL Verilog는 설계자가 작성한 동작 수준의 기술입니다:

// RTL 수준
always @(posedge clk or negedge rst_n) begin
    if (!rst_n)
        q <= 8'b0;
    else if (en)
        q <= d;
end

Gate-level netlist은 synthesis 후 standard cell로 매핑된 결과입니다:

// Gate-level netlist (synthesis 출력)
module top (clk, rst_n, en, d, q);
    input clk, rst_n, en;
    input [7:0] d;
    output [7:0] q;

    wire n1, n2, n3;

    DFFRNQ_X1 q_reg_0_ (.D(n1), .CK(clk), .RN(rst_n), .Q(q[0]));
    DFFRNQ_X1 q_reg_1_ (.D(n2), .CK(clk), .RN(rst_n), .Q(q[1]));
    // ... 나머지 flip-flop들

    MUX2_X1 U1 (.A(q[0]), .B(d[0]), .S(en), .Y(n1));
    MUX2_X1 U2 (.A(q[1]), .B(d[1]), .S(en), .Y(n2));
    // ... 나머지 MUX들
endmodule

Gate-level netlist에서는 always block 대신 실제 cell 인스턴스(DFFRNQ_X1, MUX2_X1 등)가 사용됩니다. Cell 이름은 technology library에 정의된 standard cell에 대응합니다. Synthesis tool이 RTL을 이 형태로 변환하며, 이후 P&R tool이 이 netlist를 입력으로 받아 물리적 배치와 routing을 수행합니다.

SystemVerilog(.sv)의 확장 기능

SystemVerilog는 Verilog를 확장한 언어로, 설계와 검증 모두에 사용됩니다. RTL 설계에서 유용한 확장 기능을 살펴봅니다.

// counter.sv
module counter #(
    parameter int WIDTH = 8
) (
    input  logic             clk,
    input  logic             rst_n,
    input  logic             en,
    output logic [WIDTH-1:0] count
);

    always_ff @(posedge clk or negedge rst_n) begin
        if (!rst_n)
            count <= '0;
        else if (en)
            count <= count + 1'b1;
    end

endmodule

주요 차이점은 다음과 같습니다. logic 타입은 wire와 reg를 통합합니다. always_ff는 flip-flop을 명시적으로 기술하며, synthesis tool이 의도를 더 정확히 파악합니다. always_comb은 combinational logic 전용입니다. parameter int로 타입이 있는 parameter를 선언합니다.

파일 구성 규칙

실무에서 Verilog/SystemVerilog 파일을 구성하는 일반적인 규칙이 있습니다. 하나의 파일에 하나의 module을 정의합니다. 파일 이름과 module 이름을 일치시킵니다(예: alu.vmodule alu). Include file(.vh, .svh)에 공통 define과 parameter를 정의합니다. Filelist(.f)로 컴파일 순서를 관리합니다.

// filelist.f 예제
-v ./rtl/common/defines.vh
./rtl/top/soc_top.sv
./rtl/cpu/cpu_core.sv
./rtl/cpu/alu.sv
./rtl/mem/mem_ctrl.sv

RTL-to-GDS Flow에서의 역할

Verilog/SystemVerilog 파일은 flow의 시작점이자 여러 단계의 입출력입니다. RTL(.v/.sv) → Synthesis → gate-level netlist(.v) → P&R → 최종 netlist(.v)로 이어집니다. 각 단계에서 netlist가 변형되지만 모두 Verilog format을 사용합니다. Formal verification(LEC)은 이 단계별 .v 파일들을 비교하여 기능적 동등성을 검증합니다.

정리

Verilog(.v)는 RTL 설계부터 gate-level netlist까지 사용되는 핵심 파일입니다. SystemVerilog(.sv)는 logic 타입, always_ff/always_comb 등 설계 편의 기능을 추가합니다. 같은 확장자라도 RTL과 netlist는 추상화 수준이 다르며, flow의 각 단계를 연결하는 공통 format 역할을 합니다.

Enjoyed this article?

Get deep-dive semiconductor analysis and career insights delivered weekly. Free forever — no paywall, no upsell. Funded by sponsorships with a strict editorial firewall (Editorial Standards).

Work with me

Consulting · Collaboration · Support

Paid 1:1 technical consulting, speaker invitations, collaboration proposals, or just want to say thanks — all welcome.

View options →
VLSI Korea Free forever · No paywall · Weekly semiconductor insights from practicing engineers
Support