Skip to main content

Verilog Parameters: Making Modules Reusable & Configurable

· loading · loading · ·
Hardware Design Verilog Parameters Reusable Design Configurable Modules RTL Design Hardware Description Language
Hardware Design
Axolot Logic
Author
Axolot Logic
Digital Design Engineer
Table of Contents
Verilog HDL Series - This article is part of a series.
Part 12: This Article

🎛️ Parameters in Verilog
#

Parameters are compile-time constants used to make modules configurable and reusable.

✅ Define Inside Module:
#

module counter #(parameter WIDTH = 8) (
  input clk,
  output [WIDTH-1:0] out
);

✅ Override During Instantiation:
#

counter #(.WIDTH(16)) u_counter (
  .clk(clk),
  .out(data)
);

🔒 Local Parameters
#

Use localparam to define constants that cannot be overridden during module instantiation.

module timer;
  localparam TIMEOUT_CYCLES = 100;
endmodule

Useful for internal constants derived from other parameters or used for fixed values.

Key Points:

  • Parameters are not variables — they cannot change at runtime.
  • Often used to set data widths, address sizes, etc.

module tb_parameter_demo;

    wire clk;
    wire [15:0] data;

    counter #(.WIDTH(16)) u_counter (
        .clk(clk),
        .out(data)
    );

endmodule

module counter #(parameter WIDTH = 8) (
    input clk,
    output [WIDTH-1:0] out
);
    assign out = {WIDTH{1'b0}};  // Dummy constant output for demo
endmodule

Verilog HDL Series - This article is part of a series.
Part 12: This Article

Related

Verilog Assignments: Procedural vs. Continuous Explained
· loading · loading
Hardware Design Verilog Assignments Continuous Assignment Procedural Assignment RTL Design Hardware Description Language
Hardware Design
Verilog Namespaces: Understanding Scope and Modularity
· loading · loading
Hardware Design Verilog Namespace Verilog Scope Modularity RTL Design Hardware Description Language
Hardware Design
Introduction to Verilog: Basics for Digital Design
·753 words·4 mins· loading · loading
Hardware Design Verilog FPGA ASIC RTL Design Hardware Description Language
Hardware Design
Hardware Design Abstraction Levels in Verilog
·238 words·2 mins· loading · loading
Hardware Design Hardware Abstraction RTL Design Gate Level Transistor Level Digital Design
Hardware Design
Verilog Blocking vs. Non-Blocking Assignments
· loading · loading
Hardware Design Verilog Assignments Blocking Assignment NonBlocking Assignment RTL Design Sequential Logic
Hardware Design
Verilog Compiler Directives & Macros: Conditional Compilation & Code Reuse
· loading · loading
Hardware Design Verilog Directives Verilog Macros Conditional Compilation Code Reuse Hardware Description Language
Hardware Design