Combinatorial Logic
This block implements a standard truth table for modeling programming array, digital circuit and any other boolean expressions.
The user must specify a matrix that defines all the possible block outputs in the Truth Table field. In consequence, the number of rows must be a power of two. Each row of the matrix contains a logic combination of input elements.
Setting the parameter Truth Table defines the number of inputs and outputs in the following way :
This block can be activated by an implicit input event or it can inherit the clock from the regular input (parameter Accepts Inherited Events).
The block supports the following types :
The easiest example to consider is the OR example.In this case we have two inputs and only one output. The truth table for this example is :
input 1 input 2 output 0 0 0 0 1 1 1 0 1 1 1 1 and the Truth Table parameter is writing :
[0;1;1;1]
This example shows the use of LOGIC bloc as a demultiplexer. The goal is to send the true constant input on one of the four outputs according to the state of the two selection inputs: * `a`* and * `b`*. The truth table is the following:
Constant a b Q0 Q1 Q2 Q3 0 X X 0 0 0 0 1 0 0 1 0 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 0 0 1 where * `X`* stands for “indifferent”.
To set this table in the Truth Table parameter, we can simply write:
[`zeros`_(4,4) ; `eye`_(4,4)]
The following figure shows the resulting outputs * `Q 0 `* à * `Q 3 `* during the simulation when the selection inputs * `a`* and * `b`* are generated by a binary counter. `Open this example in Xcos`_