block Table "Digital Tabular Source"
import D = Modelica.Electrical.Digital;
import L = Modelica.Electrical.Digital.Interfaces.Logic;
parameter D.Interfaces.Logic x[:] = {L.'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 annotation (Placement(transformation(extent = {
{90, -10},
{110, 10}})));
algorithm
if initial() then
assert(0 < n, "Invalid size of table (n < 1)");
for i in 1:n loop
end for;
end if;
y := y0;
for i in 1:n loop
if t[i] <= time then
y := x[i];
end if;
end for;
annotation (
Documentation(
info = "<html>\n<p>\nThe table source output signal <em>y</em> steps to the values of the <em>x</em> table at the corresponding\ntimepoints in the <em>t</em> table.<br>The initial value is specified by <em>y0</em>.\n</p>\n<p>\nTo specify the logic value parameters, the integer code has to be used.\n</p>\n<p><strong>Code Table</strong></p>\n<table border=1 cellspacing=0 cellpadding=2>\n <tr><td><strong>Logic value</strong></td>\n <td><strong>Integer code</strong></td>\n <td><strong>Meaning</strong></td>\n </tr>\n\n <tr><td>'U'</td> <td>1</td> <td>Uninitialized</td></tr>\n <tr><td>'X'</td> <td>2</td> <td>Forcing Unknown</td></tr>\n <tr><td>'0'</td> <td>3</td> <td>Forcing 0</td></tr>\n <tr><td>'1'</td> <td>4</td> <td>Forcing 1</td></tr>\n <tr><td>'Z'</td> <td>5</td> <td>High Impedance</td></tr>\n <tr><td>'W'</td> <td>6</td> <td>Weak Unknown</td></tr>\n <tr><td>'L'</td> <td>7</td> <td>Weak 0</td></tr>\n <tr><td>'H'</td> <td>8</td> <td>Weak 1</td></tr>\n <tr><td>'-'</td> <td>9</td> <td>Do not care</td></tr>\n</table>\n<p>\nIf the logic values are imported by<br><strong>import L = Digital.Interfaces.Logic;</strong><br>\nthey can be used to specify the parameter, e.g., <strong>L.'0'</strong> for forcing 0.\n</p>\n</html>",
revisions = "<html>\n<dl>\n<dt><em>August 20, 2003</em></dt>\n<dd>by Teresa Schlegel initially modelled.</dd>\n</dl>\n</html>"),
Icon(
coordinateSystem(
preserveAspectRatio = true,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Rectangle(
extent = {
{-50, 100},
{50, -100}},
lineThickness = 0.5,
fillColor = {213, 255, 170},
fillPattern = FillPattern.Solid),
Text(
extent = {
{152, -160},
{-148, -100}},
lineColor = {0, 0, 255},
textString = "%name"),
Line(
points = {
{50, 0},
{90, 0}},
color = {127, 0, 127}),
Rectangle(
extent = {
{-30, 80},
{32, 70}},
fillColor = {215, 215, 215},
fillPattern = FillPattern.Solid),
Rectangle(
extent = {
{-30, 70},
{32, 40}},
fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid),
Line(points = {
{0, 80},
{0, 40}}),
Line(points = {
{-30, 60},
{32, 60}}),
Line(points = {
{-30, 50},
{32, 50}})}));
end Table;