FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches

A general logics object.

+ Collaboration diagram for Logic:

It is assumed that the size of all ports are equal. The number of input ports and the size of the ports are decided by input parameters. This function supports the logical operations "and", "or" or "xor" (exclusive "or"). With more than two inputs, "xor" is odd parity: the output is true when an odd number of the inputs are non-zero.

Author
Karl-Johan Reite
Date
16.04.2007 KJR: Initial version.
20.07.2011 KGA: Ported to FhSim 2.0.
25.07.2011 KGA: Added documentation.

Example configuration excerpt

<Lib
LibName = "fhsim_base"
SimObject = "Math/Logic"
Name = "A"
Type = "xor"
PortWidth = "1"
NumInput = "2"
/>
...
<Connection
A.In1 = "1"
A.In2 = "0"
/>

Input Ports

Name Width Description
In1 .. In<NumInput> <PortWidth> The input signal. Numbering starts at 1.

Output Ports

Name Width Description
Out <PortWidth> The result of the logical operation on the input.

Configuration parameters

Name Width Description
PortWidth The number of elements in the input and output ports
Type 1 The logic operation applied to the input: "or" , "and" or "xor". Required.
NumInput 1

The number of input ports

Initial conditions

This SimObject contains no initial conditions.

Full example file

<Contents>
<OBJECTS>
<Lib
LibName="base"
SimObject="Math/Logic"
Name="A"
Type="OR"
/>
<Lib
LibName="base"
SimObject="Math/Logic"
Name="B"
Type="AND"
/>
<Lib
LibName="base"
SimObject="Math/Logic"
Name="C"
Type="XOR"
/>
</OBJECTS>
<INTERCONNECTIONS>
<Connection
A.In1="0"
A.In2="1"
B.In1="1"
B.In2="1"
C.In1="1"
C.In2="1"
/>
</INTERCONNECTIONS>
<INITIALIZATION>
<InitialCondition
/>
</INITIALIZATION>
<SIMULATION>
<Timing TStart="0" TEnd="2.0"/>
<Integrator Method="RK45_i" NumCores="1" LogStates="1" UseRSSNorm="0">
<StepControl StepMax="0.002" StepMin="0.00000001" AbsTol="1e-3" RelTol="1e-3"/>
</Integrator>
</SIMULATION>
<OBSERVERS>
<FileOutput TOutput="0, 1, 30" Select="objects:all"/>
</OBSERVERS>
</Contents>

This SimObject is referred to as Math/Logic