🔌
nand2tetris
  • Introduction
  • Combinational Chips
    • Nand Gate
    • Not Gate
    • And Gate
    • Or Gate
    • Xor Gate
    • Multiplexor Chip
    • Demultiplexor Chip
    • Not16 Chip
    • And16 Chip
    • Or16 Chip
    • Mux16 Chip
    • Or8Way Chip
    • Mux4Way16 Chip
    • Mux8Way16 Chip
    • DMux4Way Chip
    • DMux8Way Chip
    • Half Adder Chip
    • Full Adder Chip
    • Add16 Chip
    • Inc16 Chip
    • Half Subtractor Chip
    • Full Subtractor Chip
    • Subtract16 Chip
    • Dec16 Chip
    • Arithmetic Chip
    • ALU
  • Misc
    • Int2Bool
    • Bool2Int
    • Arrayto16
Powered by GitBook
On this page
  • Or Gate
  • Implementation of Or Gate in HDL
  • Implementation of Or Gate in Java™
  1. Combinational Chips

Or Gate

Abstraction and Implementation of Or Gate in Hardware Design Language and Java™.

PreviousAnd GateNextXor Gate

Last updated 3 years ago

Or Gate

The Or function returns 1 (true) when either of the inputs are 1 (true).

Abstraction of Or Gate - Representation and Truth Table

Implementation of Or Gate in HDL

Or Gate can be implemented in two ways:

  • Or Gate can be implemented by connecting negation of first input and negation of second input to the either inputs of Nand Gate.

  • It can also be implemented by connecting first input to both inputs of first Nand Gate and second input to both inputs of second Nand Gate, and outputs of both to the either inputs of third Nand Gate.

CHIP Or {
    IN a, b;
    OUT out;

    PARTS:
    Not(in=a, out=nota);
    Not(in=b, out=notb);
    Nand(a=nota, b=notb, out=out);
}

Implementation of Or Gate in Java™

Similar to the Implementation in HDL

package CombChips;

class Or_Gate extends Not_Gate {

    protected static int Or(int a, int b) {
        return Nand(Not(a), Not(b));
    }
}
Implementation of Or Gate from Nand Gates