🔌
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
  • Or8Way (8-way Or) Chip
  • Implementation of Or8Way Chip in HDL
  • Implementation of Or8Way Chip in Java™
  1. Combinational Chips

Or8Way Chip

Abstraction and Implementation of Or8Way Chip in Hardware Design Language and Java™.

Or8Way (8-way Or) Chip

An 8-way Or gate outputs 1 when at least one bit of its 16-bit input is 1.

Unlike n-bit input logic gates, n-way logic gates use the same output iteratively over the boolean operation, which means, it uses the previous output as input for the next similar boolean operation.

Chip name: Or8Way
Inputs: in[8]
Outputs: out
Function: out=Or(in[0],in[1],...,in[7]).

Implementation of Or8Way Chip in HDL

The function in the above abstraction can help in the implementation of Or8Way Chip.

CHIP Or8Way {
    IN in[8];
    OUT out;

    PARTS:
    Or(a=in[0], b=in[1], out=o1);
    Or(a=o1, b=in[2], out=o2);
    Or(a=o2, b=in[3], out=o3);
    Or(a=o3, b=in[4], out=o4);
    Or(a=o4, b=in[5], out=o5);
    Or(a=o5, b=in[6], out=o6);
    Or(a=o6, b=in[7], out=out);
}

Implementation of Or8Way Chip in Java™

Similar to the Implementation in HDL

package CombChips;

import Misc.Convert;

class Or8Way_Gate extends Or_Gate {

    protected static int Or8Way(int[] in) {
        
        int[] arr_in = Convert.Arrayto16(in);

        int out = Or(arr_in[0], arr_in[1]);
        for (int i = 2; i < arr_in.length; ++i) {
            int temp= Or(out, arr_in[i]);
            out = temp;
        }
        
        return out;
    }
}
PreviousMux16 ChipNextMux4Way16 Chip

Last updated 3 years ago