LogicToX01Z

block LogicToX01Z "Conversion to X01Z"
    import D = Modelica.Electrical.Digital;
    import T = Modelica.Electrical.Digital.Tables;

    D.Interfaces.DigitalInput x[n] annotation (Placement(transformation(extent = {
        {-60, -10}, 
        {-40, 10}})));
    D.Interfaces.DigitalOutput y[n] annotation (Placement(transformation(extent = {
        {40, -10}, 
        {60, 10}})));
    parameter Integer n(final min = 1, start = 1) "signal width";
algorithm
    for i in 1:n loop
        y[i] := T.X01ZTable[x[i]];
    end for;

    annotation (
        Documentation(
            info = "<html>\n<p>\nConversion of a nine valued digital input into a X01Z digital output without\nany delay according to IEEE 1164 To_X01Z function.\n</p>\n<p><strong>Conversion Table:</strong></p>\n<pre>\n input                  output\n 'U' (coded by 1)       'X'  (coded by 2)\n 'X' (coded by 2)       'X'  (coded by 2)\n '0' (coded by 3)       '0'  (coded by 3)\n '1' (coded by 4)       '1'  (coded by 4)\n 'Z' (coded by 5)       'Z'  (coded by 5)\n 'W' (coded by 6)       'X'  (coded by 2)\n 'L' (coded by 7)       '0'  (coded by 3)\n 'H' (coded by 8)       '1'  (coded by 4)\n '-' (coded by 9)       'X'  (coded by 2)\n</pre>\n<p>\nIf the signal width is greater than 1 this conversion is done for each signal.\n</p>\n</html>",
            revisions = "<html>\n<ul>\n<li><em>September 15, 2004</em>\n       by Christoph Clauss name converted from cvt_to_x01z into LogicToX01Z<br>\n       </li>\n<li><em>November 5, 2003</em>\n       by Christoph Clauss<br>\n       initially modelled.</li>\n</ul>\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {152, -100}, 
                        {-148, -40}},
                    lineColor = {0, 0, 255},
                    textString = "%name"), 
                Polygon(
                    points = {
                        {-40, -40}, 
                        {-40, 40}, 
                        {40, 40}, 
                        {-40, -40}},
                    lineColor = {127, 0, 127},
                    fillColor = {127, 0, 127},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-40, -40}, 
                        {40, -40}, 
                        {40, 40}, 
                        {-40, -40}},
                    lineColor = {127, 0, 127},
                    lineThickness = 0.5,
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {0, -20}, 
                        {40, -40}},
                    textString = "X01Z"), 
                Rectangle(
                    extent = {
                        {-40, 40}, 
                        {40, -40}},
                    lineThickness = 0.5)}));
end LogicToX01Z;