block BooleanToLogic "Boolean to Logic converter"
import L = Modelica.Electrical.Digital.Interfaces.Logic;
Modelica.Blocks.Interfaces.BooleanInput x[n] annotation (Placement(transformation(extent = {
{-60, -10},
{-40, 10}})));
parameter Integer n(final min = 1, start = 1) "signal width";
Modelica.Electrical.Digital.Interfaces.DigitalOutput y[n] annotation (Placement(transformation(extent = {
{40, -10},
{60, 10}})));
equation
for i in 1:n loop
y[i] = if x[i] then L.'1' else L.'0';
end for;
annotation (
Documentation(
info = "<html>\n<p>\nConversion of a Boolean input into a digital output without any delay according to:\n</p>\n<pre>\n input output\n true '1' (coded by 4)\n false '0' (coded by 3)\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 colors changed<br>\n </li>\n<li><em>November 4, 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 = {
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 = {255, 0, 255},
fillColor = {255, 0, 255},
fillPattern = FillPattern.Solid),
Text(
extent = {
{152, -100},
{-148, -40}},
lineColor = {0, 0, 255},
textString = "%name"),
Rectangle(
extent = {
{-40, 40},
{40, -40}},
lineThickness = 0.5)}));
end BooleanToLogic;