Mastering OR Gate Verilog: A Comprehensive Guide

Michael Aug 03, 2026
the diagram shows how to read and write an electronic circuit for each component in this program
the diagram shows how to read and write an electronic circuit for each component in this program

In the dynamic world of digital circuit design, the OR gate stands as a fundamental building block, vital for creating complex logic systems. Verilog, a popular hardware description language, enables engineers to describe the behavior of these gates with remarkable precision. This article explores the OR gate in Verilog, delving into its functionality, various OR gate representations, and essential examples.

the diagram shows how to read and write an electronic circuit for each component in this program
the diagram shows how to read and write an electronic circuit for each component in this program

Before we dive into Verilog, let's briefly recall the OR gate's logic. An OR gate outputs a 1 if one or both of its inputs are 1s. Otherwise, it outputs a 0. Now, let's translate this logic into Verilog.

logic gates
logic gates

OR Gate in Verilog

The OR gate in Verilog can be represented using various methods, each with its unique implementation style and benefits. Let's explore two primary representations: gate-level description and behavioral description.

GitHub - adam-maj/tiny-gpu: A minimal GPU design in Verilog to learn how GPUs work from the ground up
GitHub - adam-maj/tiny-gpu: A minimal GPU design in Verilog to learn how GPUs work from the ground up

NOTE: For SEO optimization, include relevant keywords like 'Verilog OR gate', 'OR gate implementation', 'two-input OR gate in Verilog', and their synonyms throughout the article.

Gate-Level Description

OR LOGIC GATE
OR LOGIC GATE

The gate-level description mimics the physical circuit and offers ample control over individual gate delays. Here's a simple representation of a two-input OR gate:

module OR_GATE_2INPUT (input A, B, output Y);
   OR #10 (Q, A, B, Y); // Delayed OR gate with an imaginary 10 time unit delay
endmodule

In this module, #10 denotes a delay of 10 time units. You can adjust this value to emulate various delay scenarios.

Behavioral Description

an electrical circuit diagram with the symbols for different types of electronic devices and their functions
an electrical circuit diagram with the symbols for different types of electronic devices and their functions

For larger, complex designs, behavioral descriptions provide concise and maintainable code. They abstract away the lower-level details, focusing instead on function and behavior.

Here's a two-input OR gate using the always block for combinational logic:

module OR_GATE_2INPUT_BEHAVIORAL (input A, B, output reg Y);
   always @ (A or B) begin
      Y = A | B; // Vertical bar '|' represents OR operation
   end
endmodule

The always @ (A or B) sensitivity list ensures the output updates whenever there's a change in A or B inputs, reflecting the OR gate's combinational nature.

an image of a pink umbrella with the word or gate on it and green letters
an image of a pink umbrella with the word or gate on it and green letters

OR Gate Examples

To solidify our understanding, let's explore a few OR gate examples that illustrate its versatile use cases in Verilog.

Designing a NAND gate using Elbert S7 FPGA Board and Vivado design suite 2024.1 (Hardware) | Numato Lab Help Center
Designing a NAND gate using Elbert S7 FPGA Board and Vivado design suite 2024.1 (Hardware) | Numato Lab Help Center
XNOR Gate Digital Logic Symbol Stock Vector
XNOR Gate Digital Logic Symbol Stock Vector
Getting Started With FPGAs: Digital Circuit Design, Verilog, And VHDL For Beginners - Aadhu.com
Getting Started With FPGAs: Digital Circuit Design, Verilog, And VHDL For Beginners - Aadhu.com
Myth: Hardware Description Languages (HDLs) are just like C or Python
Myth: Hardware Description Languages (HDLs) are just like C or Python
two different types of waveforms are shown in the diagram, and one is labeled
two different types of waveforms are shown in the diagram, and one is labeled
Digital Logic: With an Introduction to Verilog and FPGA-Based Design
Digital Logic: With an Introduction to Verilog and FPGA-Based Design
Logic NOT Gate - Digital Inverter Logic Gate - Electrical Technology
Logic NOT Gate - Digital Inverter Logic Gate - Electrical Technology
Verilog CPU Design: How a Nibble-Oriented Processor Powers This DIY Scientific Calculator
Verilog CPU Design: How a Nibble-Oriented Processor Powers This DIY Scientific Calculator
Learn Verilog and VHDL From Scratch: A Complete Beginner’s Guide to Digital Logic Design, FPGA Programming, and Hardware Description Languages
Learn Verilog and VHDL From Scratch: A Complete Beginner’s Guide to Digital Logic Design, FPGA Programming, and Hardware Description Languages
Modelling of universal gates on Verilog
Modelling of universal gates on Verilog

Three-Input OR Gate

Expanding our OR gate to accommodate three inputs is a breeze in Verilog. Here's a three-input OR gate using both gate-level and behavioral descriptions:

// Gate-level
module OR_GATE_3INPUT (input A, B, C, output Y);
   OR (Q, A, B, C, Y); // No delay for this simple example
endmodule

// Behavioral
module OR_GATE_3INPUT_BEHAVIORAL (input A, B, C, output reg Y);
   always @ (A or B or C) begin
      Y = A | B | C; // Multiple inputs OR operation
   end
endmodule

OR Gate with Multi-level Outputs

Certain designs might require multiple outputs from a single OR gate. Verilog easily accommodates this with vector outputs. Here's an example with two-bit output vectors:

module OR_GATE_MULTILEVEL (input A, B, output reg [1:0] Y);
   always @ (A or B) begin
      Y = {A | B, A | ~B}; // Use of Verilog's concatenation operator '{}'
   end
endmodule

In this example, Y[0] is the result of A OR B, while Y[1] is A OR the inverse of B (~B).

That concludes our comprehensive exploration of the OR gate in Verilog. Now that you're equipped with gate-level, behavioral, and multi-output representations, you're ready to harness the power of OR gates in your next Verilog project.

As you venture forth, consider utilizing Verilog's wide range of tools and features to optimize your designs, enhance performance, and ensure robust functionality. Happy circuit designing!