The sources are not taken from Standard Logic. They were added since they turned out to be quite useful, since such sources are often needed. For a better optical overview the colour green was chosen for the sources.
Extends from Modelica.Icons.SourcesPackage (Icon for packages containing sources).
Name | Description |
---|---|
Set | Digital Set Source |
Step | Digital Step Source |
Table | Digital Tabular Source |
Pulse | Digital Pulse Source |
Clock | Digital Clock Source |
Sets a nine valued digital signal, which is specified by the setval parameter.
To specify setval, the integer code has to be used.
Code Table
Logic value | Integer code | Meaning |
'U' | 1 | Uninitialized |
'X' | 2 | Forcing Unknown |
'0' | 3 | Forcing 0 |
'1' | 4 | Forcing 1 |
'Z' | 5 | High Impedance |
'W' | 6 | Weak Unknown |
'L' | 7 | Weak 0 |
'H' | 8 | Weak 1 |
'-' | 9 | Don't care |
If the logic values are imported by
import L = Digital.Interfaces.Logic;
they can be used to specify the parameter, e.g., L.'0' for forcing 0.
Type | Name | Default | Description |
---|---|---|---|
Logic | x | Logic value to be set |
Type | Name | Description |
---|---|---|
output DigitalOutput | y |
block Set "Digital Set Source" import D = Modelica.Electrical.Digital; import L = Modelica.Electrical.Digital.Interfaces.Logic; parameter D.Interfaces.Logic x(start=L.'1') "Logic value to be set";D.Interfaces.DigitalOutput y; algorithm y := x;end Set;
The step source output signal steps from the value before to the value after at the time stepTime.
To specify the logic value parameters, the integer code has to be used.
Code Table
Logic value | Integer code | Meaning |
'U' | 1 | Uninitialized |
'X' | 2 | Forcing Unknown |
'0' | 3 | Forcing 0 |
'1' | 4 | Forcing 1 |
'Z' | 5 | High Impedance |
'W' | 6 | Weak Unknown |
'L' | 7 | Weak 0 |
'H' | 8 | Weak 1 |
'-' | 9 | Don't care |
If the logic values are imported by
import L = Digital.Interfaces.Logic;
they can be used to specify the parameter, e.g., L.'0' for forcing 0.
Type | Name | Default | Description |
---|---|---|---|
Logic | before | Logic value before step | |
Logic | after | Logic value after step | |
Real | stepTime | step time |
Type | Name | Description |
---|---|---|
output DigitalOutput | y |
block Step "Digital Step Source" import D = Modelica.Electrical.Digital; import L = Modelica.Electrical.Digital.Interfaces.Logic; parameter D.Interfaces.Logic before(start=L.'0') "Logic value before step"; parameter D.Interfaces.Logic after(start=L.'1') "Logic value after step"; parameter Real stepTime(start=1) "step time";D.Interfaces.DigitalOutput y; algorithm // assert(before >= L.min and before <= L.max, "Parameter is no logic value"); // assert(after >= L.min and after <= L.max, "Parameter is no logic value"); when initial() then y := before; end when; if time >= stepTime then y := after; else y := before; end if;end Step;
The table source output signal y steps to the values of the x table at the corresponding
timepoints in the t table.
The initial value is specified by y0.
To specify the logic value parameters, the integer code has to be used.
Code Table
Logic value | Integer code | Meaning |
'U' | 1 | Uninitialized |
'X' | 2 | Forcing Unknown |
'0' | 3 | Forcing 0 |
'1' | 4 | Forcing 1 |
'Z' | 5 | High Impedance |
'W' | 6 | Weak Unknown |
'L' | 7 | Weak 0 |
'H' | 8 | Weak 1 |
'-' | 9 | Don't care |
If the logic values are imported by
import L = Digital.Interfaces.Logic;
they can be used to specify the parameter, e.g., L.'0' for forcing 0.
Type | Name | Default | Description |
---|---|---|---|
Logic | x[:] | {1} | vector of values |
Real | t[size(x, 1)] | {1} | vector of corresponding time points |
Logic | y0 | L.'U' | initial output value |
Type | Name | Description |
---|---|---|
output DigitalOutput | y |
block Table "Digital Tabular Source" import D = Modelica.Electrical.Digital; import L = Modelica.Electrical.Digital.Interfaces.Logic; parameter D.Interfaces.Logic x[:]={1} "vector of values"; parameter Real t[size(x, 1)]={1} "vector of corresponding time points"; parameter D.Interfaces.Logic y0=L.'U' "initial output value"; final parameter Integer n=size(x, 1) "table size";D.Interfaces.DigitalOutput y; algorithm if initial() then // assert(y0 >= L.min and y0 <= L.max, "Parameter y0 is not of type Logic"); assert(n > 0, "Invalid size of table (n < 1)"); for i in 1:n loop // assert(x[i] >= L.min and x[i] <= L.max, "Table element is not of type Logic"); end for; end if; y := y0; for i in 1:n loop if time >= t[i] then y := x[i]; end if; end for;end Table;
The pulse source forms pulses between the quiet value and the pulse value. The pulse length width is specified in percent of the period length period. The number of periods is specified by nperiod. If nperiod is less than zero, the number of periods is unlimited.
To specify the logic value parameters, the integer code has to be used.
Code Table
Logic value | Integer code | Meaning |
'U' | 1 | Uninitialized |
'X' | 2 | Forcing Unknown |
'0' | 3 | Forcing 0 |
'1' | 4 | Forcing 1 |
'Z' | 5 | High Impedance |
'W' | 6 | Weak Unknown |
'L' | 7 | Weak 0 |
'H' | 8 | Weak 1 |
'-' | 9 | Don't care |
If the logic values are imported by
import L = Digital.Interfaces.Logic;
they can be used to specify the parameter, e.g., L.'0' for forcing 0.
Type | Name | Default | Description |
---|---|---|---|
Real | width | Widths of pulses in % of periods | |
Time | period | Time for one period [s] | |
Time | startTime | Output = quiet for time < startTime [s] | |
Logic | pulse | pulsed value | |
Logic | quiet | quiet value | |
Integer | nperiod | Number of periods (< 0 means infinite number of periods) |
Type | Name | Description |
---|---|---|
output DigitalOutput | y |
model Pulse "Digital Pulse Source" import D = Modelica.Electrical.Digital; import L = Modelica.Electrical.Digital.Interfaces.Logic; parameter Real width( final min=Modelica.Constants.small, final max=100, start=50) "Widths of pulses in % of periods"; parameter Modelica.SIunits.Time period(final min=Modelica.Constants.small, start=1) "Time for one period"; parameter Modelica.SIunits.Time startTime(start=0) "Output = quiet for time < startTime"; parameter D.Interfaces.Logic pulse(start=L.'0') "pulsed value"; parameter D.Interfaces.Logic quiet(start=L.'1') "quiet value"; Modelica.SIunits.Time T0(final start=startTime) "Start time of current period"; parameter Integer nperiod(start=-1) "Number of periods (< 0 means infinite number of periods)"; Integer np(start=0, fixed=true);D.Interfaces.DigitalOutput y; protected Boolean sampling; equation sampling = nperiod <> 0 and (nperiod >= pre(np) or nperiod < 0); when sampling and sample(startTime, period) then T0 = time; np = if nperiod > 0 then pre(np) + 1 else pre(np); end when; if sampling then y = if time < startTime or time >= T0 + ((width*period)/100) then quiet else pulse; else y = quiet; end if;end Pulse;
The clock source forms pulses between the '0' value (forcing 0) and the '1' value (forcing 1). The pulse length width is specified in percent of the period length period. The number of periods is unlimited. The first pulse starts at startTime.
The clock source is a special but often used variant of the pulse source.
Type | Name | Default | Description |
---|---|---|---|
Time | startTime | Output = offset for time < startTime [s] | |
Time | period | Time for one period [s] | |
Real | width | Width of pulses in % of period |
Type | Name | Description |
---|---|---|
output DigitalOutput | y | Connector of Digital output signal |
model Clock "Digital Clock Source" import D = Modelica.Electrical.Digital; import L = Modelica.Electrical.Digital.Interfaces.Logic; parameter Modelica.SIunits.Time startTime(start=0) "Output = offset for time < startTime"; parameter Modelica.SIunits.Time period( final min=Modelica.Constants.small, start=1) "Time for one period"; parameter Real width( final min=Modelica.Constants.small, final max=100, start=50) "Width of pulses in % of period";D.Interfaces.DigitalOutput y "Connector of Digital output signal"; protected Modelica.SIunits.Time t_i(final start=startTime) "Start time of current period"; Modelica.SIunits.Time t_width=period*width/100; algorithm when sample(startTime, period) then t_i := time; end when; y := if (not time>=startTime) or time >= t_i + t_width then L.'0' else L.'1';end Clock;