Copyright DB Netz AG, licensed under CC-BY SA 3.0 DE (see full text in CC-BY-SA-3.0-DE)
Method for definition of truth tables
Overview
A truth table is typically used to specify the input/output relationship of combinational i.e. memoryless boolean logic. They use typically binary data and show in tabular format combinations of input values and the resulting output value. It is possible that multiple output values are defined. Sometimes a part of the input values is declared as "don't care" by a "X". Then these values are not taken in account for a combination. Some of the inputs might belong to a precondition where in this case this inputs shall be marked accordingly. It is also possible that an output is used as input as well. All inputs and the output i.e. high (1) or low (0) are assumed to have a value continuously in time and the output remains stable until a change in any of the inputs occurs. Any such change may cause the output to change value. During the transition of the output from low to high or inversely from high to low is indeterminate. Truth tables may be accompanied by duration constraints specifying the maximum allowable delay from input change to stable output transition.
More more detailed speaking a truth table associates k Boolean inputs to a single Boolean output: A number of 2^k possible values expressed as binary strings of length k with equivalent decimal values ranging from 0 to 2^k -1 are mapped to 2^k corresponding (single bit) output values.
For purposes of efficiency, the Boolean output may be expressed as a boolean expression using boolean algebra where the general form of the input/output relationship is y=f(x1, x2, ... xk). Such a boolean expression can be derived from rows of the truth table to build e.g. a disjuntive or conjunctive normal form as well as a simplified variant of it afterwards. For the notation of such a boolean expression see also Method for definition of behavioural constraints.
Applicablity
Truth tables are appropiate for behaviour definition of functions which output depends on a combination of values of the inputs (in case of truth tables, exclusively binary values).
Examples
The following simple truth table shows the common XOR operator in the following example where k equals 2.
A (x1) | B (x2) | A XOR B (f(x1, x2) = x1 xor x2)) |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Taking "SysC65.2: Warn trackside person of approaching train units" as an example this leads to the following truth table. By looking to all possible combinations more detailled requirements can be derived as on system analysis level. Row #3 is the case as described by the system capability.
row | input (precondition: warning area defined) | input (precondition: warning activated) | input (train arrives) | output (warning activated) |
---|---|---|---|---|
#1 | 0 | X | X | 0 |
#2 | 1 | 0 | 0 | 0 |
#3 | 1 | 0 | 1 | 1 |
#4 | 1 | 1 | X | 1 |