Skip to content

NorGate

Jaime Redondo edited this page Jan 3, 2021 · 2 revisions

NorGate

Class for the NOR gate.

Hierarchy

  • BaseGate

    NorGate

Constructor

new NorGate(input: Input): NorGate

Parameters

Name Type Default Description
input Input none The gate's input.

Returns

NorGate - The gate object.

Properties

input

The gate's input.
Type: Input


output

The gate's output.
Type: Output


truthTable

The gate's truth table.
Type: TruthTable

Methods

static create(input: Input): BaseGate

Create an instance of the gate.

Parameters

Name Type Default Description
input Input none The gate's input.

Returns

BaseGate - The gate object.


static getTruthTable(inputs?: number = 2): TruthTable

Get the gate's truth table for the specified number of inputs.

Parameters

Name Type Default Description
inputs number 2 The number of inputs for the truth table.

Returns

TruthTable - The truth table.

Example

const { NorGate } = require("@jaimermxd/logic-gates");

var gate = NorGate.create([false, true]);

console.log(gate.input); // [ false, true ]
console.log(gate.output); // false
console.log(gate.truthTable);

/*
[
  [ false, false, true ],
  [ false, true, false ],
  [ true, false, false ],
  [ true, true, false ]
]
*/

var table = NorGate.getTruthTable(3);

console.log(table);

/*
[
  [ false, false, false, true ],
  [ false, false, true, false ],
  [ false, true, false, false ],
  [ false, true, true, false ],
  [ true, false, false, false ],
  [ true, false, true, false ],
  [ true, true, false, false ],
  [ true, true, true, false ]
]
*/

Clone this wiki locally