| 1 | within Modelica.Electrical; |
|---|
| 2 | package Digital |
|---|
| 3 | "Library for digital electrical components based on the VHDL standard with 9-valued logic and conversion to 2-,3-,4-valued logic" |
|---|
| 4 | package UsersGuide "User's Guide" |
|---|
| 5 | |
|---|
| 6 | annotation (__Dymola_DocumentationClass=true, Documentation(info="<html> |
|---|
| 7 | <p> |
|---|
| 8 | Library <b>Electrical.Digital</b> is a <b>free</b> Modelica package providing |
|---|
| 9 | components to model <b>digital</b> electronic |
|---|
| 10 | systems based on combinational and sequential logic in a convenient |
|---|
| 11 | way. This package contains the <b>User's Guide</b> for |
|---|
| 12 | the library and has the following content: |
|---|
| 13 | </p> |
|---|
| 14 | <ol> |
|---|
| 15 | <li><a href=\"Modelica://Modelica.Electrical.Digital.UsersGuide.OverView\">Overview of library</a> |
|---|
| 16 | gives an overview of the library.</li> |
|---|
| 17 | <li> <a href=\"Modelica://Modelica.Electrical.Digital.UsersGuide.FirstExample\">A first example</a> |
|---|
| 18 | demonstrates at hand of a first example how to use this library.</li> |
|---|
| 19 | <li> <a href=\"Modelica://Modelica.Electrical.Digital.UsersGuide.ApplicationExample\">An |
|---|
| 20 | application example</a> demonstrates a generic n-bit adder. |
|---|
| 21 | .</li> |
|---|
| 22 | <li><a href=\"Modelica://Modelica.Electrical.Digital.UsersGuide.ReleaseNotes\">Release Notes</a> |
|---|
| 23 | summarizes the differences between different versions of this library.</li> |
|---|
| 24 | <li><a href=\"Modelica://Modelica.Electrical.Digital.UsersGuide.Literature\">Literature</a> |
|---|
| 25 | provides references that have been used to design and implement this |
|---|
| 26 | library.</li> |
|---|
| 27 | <li><a href=\"Modelica://Modelica.Electrical.Digital.UsersGuide.Contact\">Contact</a> |
|---|
| 28 | provides information about the authors of the library as well as |
|---|
| 29 | acknowledgments.</li> |
|---|
| 30 | </ol> |
|---|
| 31 | </html>")); |
|---|
| 32 | |
|---|
| 33 | class OverView "Overview of library" |
|---|
| 34 | |
|---|
| 35 | annotation (Documentation(info="<html> |
|---|
| 36 | <p> |
|---|
| 37 | In this section, an overview of the most important features |
|---|
| 38 | of this library is given. |
|---|
| 39 | </p> |
|---|
| 40 | <p>(will be added as soon as possible). </p> |
|---|
| 41 | </html> |
|---|
| 42 | ")); |
|---|
| 43 | end OverView; |
|---|
| 44 | |
|---|
| 45 | class FirstExample "A first example" |
|---|
| 46 | |
|---|
| 47 | annotation (Documentation(info="<html> |
|---|
| 48 | <p> |
|---|
| 49 | A first example will be given here (not yet done). |
|---|
| 50 | </p> |
|---|
| 51 | </html> |
|---|
| 52 | ")); |
|---|
| 53 | end FirstExample; |
|---|
| 54 | |
|---|
| 55 | class ApplicationExample "An application example" |
|---|
| 56 | |
|---|
| 57 | annotation (Documentation(info="<html> |
|---|
| 58 | <p> |
|---|
| 59 | An application example will be given here (not yet done). |
|---|
| 60 | </p> |
|---|
| 61 | </html> |
|---|
| 62 | ")); |
|---|
| 63 | end ApplicationExample; |
|---|
| 64 | |
|---|
| 65 | class ReleaseNotes "Release notes" |
|---|
| 66 | |
|---|
| 67 | annotation (Documentation(info="<html> |
|---|
| 68 | <h4>Version 1.0.7, 2005-07-01</h4> |
|---|
| 69 | <ul> |
|---|
| 70 | <li> xxxx</li> |
|---|
| 71 | </ul> |
|---|
| 72 | <h4>Version 1.0.6, 2004-10-18</h4> |
|---|
| 73 | <ul> |
|---|
| 74 | <li> Missing HTML tags added (problems with mismatched pre tags fixed).</li> |
|---|
| 75 | <li> CVS ID string deleted.</li> |
|---|
| 76 | </ul> |
|---|
| 77 | <h4>Version 1.0.5, 2004-10-01</h4> |
|---|
| 78 | <ul> |
|---|
| 79 | <li> Wrong identifiers x0 and Tdel in HalfAdder example fixed.</li> |
|---|
| 80 | <li> Experiment command in FlipFlop example deleted.</li> |
|---|
| 81 | <li> Known issue: Pulse source causes a warning in Dymola. It is recommended to use Clock source.</li> |
|---|
| 82 | </ul> |
|---|
| 83 | <h4>Version 1.0.4, 2004-09-30</h4> |
|---|
| 84 | <ul> |
|---|
| 85 | <li> Documentation improved.</li> |
|---|
| 86 | </ul> |
|---|
| 87 | <h4>Version 1.0.3, 2004-09-21</h4> |
|---|
| 88 | <ul> |
|---|
| 89 | <li> Table names changed from \"map\" to \"Table\".</li> |
|---|
| 90 | <li> Icons for converters modified.</li> |
|---|
| 91 | <li> LogicValueType renamed to Logic. For the Electrical.Digital library |
|---|
| 92 | the type Logic has a fundamental meaning. Logic is similar to |
|---|
| 93 | Real, Integer or Boolean in other packages. Names for converters |
|---|
| 94 | are now more consistent (LogicToBoolean, RealToLogic etc.).</li> |
|---|
| 95 | <li> Icons for gates and sources improved.</li> |
|---|
| 96 | <li> New examples added.</li> |
|---|
| 97 | <li> Internal names for signals and ports unified.</li> |
|---|
| 98 | <li> Simple Clock source added in addition to Pulse source (for convenience reasons).</li> |
|---|
| 99 | </ul> |
|---|
| 100 | <h4>Version 1.0.2, 2004-09-13</h4> |
|---|
| 101 | <ul> |
|---|
| 102 | <li> First prerelease for discussions at the 40th Modelica Design Meeting.</li> |
|---|
| 103 | </ul> |
|---|
| 104 | <h4>Version 1.0.1, 2004-06-01</h4> |
|---|
| 105 | <ul> |
|---|
| 106 | <li> Packages Tables, Basic, and Gates implemented.</li> |
|---|
| 107 | <li> Transport and inertial delay implemented and successfully tested.</li> |
|---|
| 108 | </ul> |
|---|
| 109 | <h4>Version 1.0.0, 2003-05-01</h4> |
|---|
| 110 | <ul> |
|---|
| 111 | <li> A first version has been implemented for case studies.</li> |
|---|
| 112 | </ul> |
|---|
| 113 | </html> |
|---|
| 114 | ")); |
|---|
| 115 | equation |
|---|
| 116 | |
|---|
| 117 | end ReleaseNotes; |
|---|
| 118 | |
|---|
| 119 | class Literature "Literature" |
|---|
| 120 | |
|---|
| 121 | annotation (Documentation(info="<html> |
|---|
| 122 | <p> |
|---|
| 123 | The Electrical.Digital library is based on the following references: |
|---|
| 124 | </p> |
|---|
| 125 | <dl> |
|---|
| 126 | <dt>Ashenden, P. J.:</dt> |
|---|
| 127 | <dd> <b>The Designer's Guide to VHDL.</b> San Francisco: Morgan Kaufmann, 1995, 688 p. ISBN 1-55860-270-4. |
|---|
| 128 | <br> </dd> |
|---|
| 129 | </dl> |
|---|
| 130 | <dl> |
|---|
| 131 | <dt>IEEE 1076-1993:</dt> |
|---|
| 132 | <dd> <b>IEEE Standard VHDL Language Reference Manual (ANSI).</b> 288 p. ISBN 1-55937-376-8. IEEE Ref. SH16840-NYF. |
|---|
| 133 | <br> </dd> |
|---|
| 134 | </dl> |
|---|
| 135 | <dl> |
|---|
| 136 | <dt>IEEE 1164-1993:</dt> |
|---|
| 137 | <dd> <b>IEEE Standard Multivalue Logic System for VHDL Model Interoperability (Std_logic_1164).</b> 24 p. ISBN 1-55937-299-0. IEEE Ref. SH16097-NYF. |
|---|
| 138 | <br> </dd> |
|---|
| 139 | </dl> |
|---|
| 140 | <dl> |
|---|
| 141 | <dt>Lipsett, R.; Schaefer, C.; Ussery, C.:</dt> |
|---|
| 142 | <dd> <b>VHDL: Hardware Description and Design.</b> Boston: Kluwer, 1989, 299 p. ISBN 079239030X. |
|---|
| 143 | <br> </dd> |
|---|
| 144 | </dl> |
|---|
| 145 | <dl> |
|---|
| 146 | <dt>Navabi, Z:</dt> |
|---|
| 147 | <dd> <b>VHDL: Analysis and Modeling of Digital Systems.</b> New York: McGraw-Hill, 1993, 375 p. ISBN 0070464723. |
|---|
| 148 | <br> </dd> |
|---|
| 149 | </dl> |
|---|
| 150 | </html> |
|---|
| 151 | ")); |
|---|
| 152 | |
|---|
| 153 | end Literature; |
|---|
| 154 | |
|---|
| 155 | class Contact "Contact" |
|---|
| 156 | |
|---|
| 157 | annotation (Documentation(info="<html> |
|---|
| 158 | <dl> |
|---|
| 159 | <dt><b>Main Authors:</b> |
|---|
| 160 | <dd><a href=\"http://people.eas.iis.fraunhofer.de/Christoph.Clauss/\">Christoph Clauß</a> |
|---|
| 161 | <<A HREF=\"mailto:Christoph.Clauss@eas.iis.fraunhofer.de\">Christoph.Clauss@eas.iis.fraunhofer.de</A>><br> |
|---|
| 162 | <a href=\"http://people.eas.iis.fraunhofer.de/Andre.Schneider/\">André Schneider</a> |
|---|
| 163 | <<A HREF=\"mailto:Andre.Schneider@eas.iis.fraunhofer.de\">Andre.Schneider@eas.iis.fraunhofer.de</A>><br> |
|---|
| 164 | Fraunhofer Institute for Integrated Circuits (IIS)<br> |
|---|
| 165 | Design Automation Department (EAS)<br> |
|---|
| 166 | Zeunerstraße 38<br> |
|---|
| 167 | D-01069 Dresden<br> |
|---|
| 168 | Germany<br> |
|---|
| 169 | </dl> |
|---|
| 170 | <br> |
|---|
| 171 | <br> |
|---|
| 172 | <dl> |
|---|
| 173 | <dt><b>Acknowledgements:</b></dt> |
|---|
| 174 | <dd> |
|---|
| 175 | We thank our colleague <a href=\"http://people.eas.iis.fraunhofer.de/Ulrich.Donath/\">Ulrich Donath</a> |
|---|
| 176 | <<a href=\"mailto:Ulrich.Donath@eas.iis.fraunhofer.de\">Ulrich.Donath@eas.iis.fraunhofer.de</a>> |
|---|
| 177 | for his support and fruitful discussions regarding all questions on VHDL and the IEEE 1164 standard |
|---|
| 178 | logic libraries. Furthermore, we thank our students Teresa Schlegel and Enrico Weber for implementing |
|---|
| 179 | and carefully testing many models and examples.<br> |
|---|
| 180 | </dd> |
|---|
| 181 | </dl> |
|---|
| 182 | </html> |
|---|
| 183 | ")); |
|---|
| 184 | |
|---|
| 185 | end Contact; |
|---|
| 186 | |
|---|
| 187 | end UsersGuide; |
|---|
| 188 | |
|---|
| 189 | annotation ( |
|---|
| 190 | |
|---|
| 191 | Documentation(info="<html> |
|---|
| 192 | <p> |
|---|
| 193 | This library contains packages for digital electrical components. Both, type system |
|---|
| 194 | and models are based on the VHDL standard (IEEE Std 1076-1987 VHDL, IEEE Std 1076-1993 VHDL, |
|---|
| 195 | IEEE Std 1164 Multivalue Logic System): |
|---|
| 196 | <ul> |
|---|
| 197 | <li>Interfaces: Definition of signals and interfaces</li> |
|---|
| 198 | <li>Tables: All truth tables needed</li> |
|---|
| 199 | <li>Delay: Transport and inertial delay</li> |
|---|
| 200 | <li>Basic: Basic logic without delay</li> |
|---|
| 201 | <li>Gates: Basic gates composed by basic components and inertial delay</li> |
|---|
| 202 | <li>Tristate: (not yet available)</li> |
|---|
| 203 | <li>FlipFlops: (not yet available) </li> |
|---|
| 204 | <li>Latches: (not yet available)</li> |
|---|
| 205 | <li>TransferGates: (not yet available)</li> |
|---|
| 206 | <li>Multiplexers (not yet available)</li> |
|---|
| 207 | <li>Memory: Ram, Rom, (not yet available)</li> |
|---|
| 208 | <li>Sources: Time-dependend signal sources</li> |
|---|
| 209 | <li>Converters</li> |
|---|
| 210 | <li>Examples</li> |
|---|
| 211 | </ul> |
|---|
| 212 | </p> |
|---|
| 213 | <p> |
|---|
| 214 | The logic values are coded by integer values. The following code table is necessary |
|---|
| 215 | for both setting of input and interpreting the output values. |
|---|
| 216 | </p> |
|---|
| 217 | <p><b>Code Table:</b></p> |
|---|
| 218 | |
|---|
| 219 | <table border=1 cellspacing=0 cellpadding=2> |
|---|
| 220 | <tr><td valign=\"top\"><b>Logic value</b></td> |
|---|
| 221 | <td valign=\"top\"><b>Integer code</b></td> |
|---|
| 222 | <td valign=\"top\"><b>Meaning</b></td> |
|---|
| 223 | </tr> |
|---|
| 224 | |
|---|
| 225 | <tr><td valign=\"top\">'U'</td> <td valign=\"top\">1</td> <td valign=\"top\">Uninitialized</td></tr> |
|---|
| 226 | <tr><td valign=\"top\">'X'</td> <td valign=\"top\">2</td> <td valign=\"top\">Forcing Unknown</td></tr> |
|---|
| 227 | <tr><td valign=\"top\">'0'</td> <td valign=\"top\">3</td> <td valign=\"top\">Forcing 0</td></tr> |
|---|
| 228 | <tr><td valign=\"top\">'1'</td> <td valign=\"top\">4</td> <td valign=\"top\">Forcing 1</td></tr> |
|---|
| 229 | <tr><td valign=\"top\">'Z'</td> <td valign=\"top\">5</td> <td valign=\"top\">High Impedance</td></tr> |
|---|
| 230 | <tr><td valign=\"top\">'W'</td> <td valign=\"top\">6</td> <td valign=\"top\">Weak Unknown</td></tr> |
|---|
| 231 | <tr><td valign=\"top\">'L'</td> <td valign=\"top\">7</td> <td valign=\"top\">Weak 0</td></tr> |
|---|
| 232 | <tr><td valign=\"top\">'H'</td> <td valign=\"top\">8</td> <td valign=\"top\">Weak 1</td></tr> |
|---|
| 233 | <tr><td valign=\"top\">'-'</td> <td valign=\"top\">9</td> <td valign=\"top\">Don't care</td></tr> |
|---|
| 234 | </table> |
|---|
| 235 | |
|---|
| 236 | <p> |
|---|
| 237 | The library will be developed in two main steps. The first step contains the basic components and |
|---|
| 238 | the gates. In the next step the more complicated devices will be added. Currently the first step of |
|---|
| 239 | the library is implemented and released for public use. |
|---|
| 240 | </p> |
|---|
| 241 | |
|---|
| 242 | <p> |
|---|
| 243 | Copyright © 1998-2008, Modelica Association and Fraunhofer-Gesellschaft. |
|---|
| 244 | </p> |
|---|
| 245 | <p> |
|---|
| 246 | <i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified |
|---|
| 247 | under the terms of the <b>Modelica license</b>, see the license conditions |
|---|
| 248 | and the accompanying <b>disclaimer</b> |
|---|
| 249 | <a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense\">here</a>.</i> |
|---|
| 250 | </p><br> |
|---|
| 251 | |
|---|
| 252 | </HTML> |
|---|
| 253 | "), Diagram(coordinateSystem( |
|---|
| 254 | preserveAspectRatio=true, |
|---|
| 255 | extent={{-100,-100},{100,100}}, |
|---|
| 256 | grid={2,2}), graphics), |
|---|
| 257 | Icon(coordinateSystem( |
|---|
| 258 | preserveAspectRatio=true, |
|---|
| 259 | extent={{-100,-100},{100,100}}, |
|---|
| 260 | grid={2,2}), graphics={ |
|---|
| 261 | Polygon( |
|---|
| 262 | points={{-100,-100},{-100,50},{80,50},{80,-100},{-100,-100}}, |
|---|
| 263 | fillColor={235,235,235}, |
|---|
| 264 | fillPattern=FillPattern.Solid, |
|---|
| 265 | lineColor={0,0,255}), |
|---|
| 266 | Polygon( |
|---|
| 267 | points={{-100,50},{-80,70},{100,70},{80,50},{-100,50}}, |
|---|
| 268 | fillColor={235,235,235}, |
|---|
| 269 | fillPattern=FillPattern.Solid, |
|---|
| 270 | lineColor={0,0,255}), |
|---|
| 271 | Polygon( |
|---|
| 272 | points={{100,70},{100,-80},{80,-100},{80,50},{100,70}}, |
|---|
| 273 | fillColor={235,235,235}, |
|---|
| 274 | fillPattern=FillPattern.Solid, |
|---|
| 275 | lineColor={0,0,255}), |
|---|
| 276 | Text( |
|---|
| 277 | extent={{-120,122},{120,73}}, |
|---|
| 278 | lineColor={255,0,0}, |
|---|
| 279 | textString="%name"), |
|---|
| 280 | Rectangle( |
|---|
| 281 | extent={{-52,4},{-32,-36}}, |
|---|
| 282 | lineColor={0,0,0}, |
|---|
| 283 | fillColor={255,255,255}, |
|---|
| 284 | fillPattern=FillPattern.Solid), |
|---|
| 285 | Rectangle( |
|---|
| 286 | extent={{8,-46},{28,-86}}, |
|---|
| 287 | lineColor={0,0,0}, |
|---|
| 288 | fillColor={255,255,255}, |
|---|
| 289 | fillPattern=FillPattern.Solid), |
|---|
| 290 | Rectangle( |
|---|
| 291 | extent={{8,4},{28,-36}}, |
|---|
| 292 | lineColor={0,0,0}, |
|---|
| 293 | fillColor={255,255,255}, |
|---|
| 294 | fillPattern=FillPattern.Solid), |
|---|
| 295 | Line(points={{-72,-6},{-52,-6}}, color={0,0,0}), |
|---|
| 296 | Line(points={{-72,-28},{-52,-28}}, color={0,0,0}), |
|---|
| 297 | Ellipse(extent={{-32,-14},{-28,-18}}, lineColor={0,0,0}), |
|---|
| 298 | Ellipse(extent={{28,-14},{32,-18}}, lineColor={0,0,0}), |
|---|
| 299 | Line(points={{-28,-16},{8,-16}}, color={0,0,0}), |
|---|
| 300 | Line(points={{-28,-16},{-12,-16},{-12,-56},{8,-56}}, color={0,0,0}), |
|---|
| 301 | Line(points={{8,-76},{-72,-76}}, color={0,0,0}), |
|---|
| 302 | Line(points={{32,-16},{48,-16}}, color={0,0,0}), |
|---|
| 303 | Line(points={{28,-66},{48,-66}}, color={0,0,0}), |
|---|
| 304 | Text( |
|---|
| 305 | extent={{-32,-8},{-52,0}}, |
|---|
| 306 | lineColor={0,0,0}, |
|---|
| 307 | textString="&"), |
|---|
| 308 | Text( |
|---|
| 309 | extent={{28,-10},{8,-2}}, |
|---|
| 310 | lineColor={0,0,0}, |
|---|
| 311 | textString="1"), |
|---|
| 312 | Text( |
|---|
| 313 | extent={{28,-58},{8,-50}}, |
|---|
| 314 | lineColor={0,0,0}, |
|---|
| 315 | textString="="), |
|---|
| 316 | Text( |
|---|
| 317 | extent={{-90,40},{70,10}}, |
|---|
| 318 | lineColor={160,160,164}, |
|---|
| 319 | fillColor={0,0,0}, |
|---|
| 320 | fillPattern=FillPattern.Solid, |
|---|
| 321 | textString="Library")})); |
|---|
| 322 | |
|---|
| 323 | package Examples |
|---|
| 324 | "Examples that demonstrate the usage of the Digital electrical components" |
|---|
| 325 | model Multiplexer "4 to 1 Bit Multiplexer Example" |
|---|
| 326 | import D = Modelica.Electrical.Digital; |
|---|
| 327 | import L = Modelica.Electrical.Digital.Interfaces.Logic; |
|---|
| 328 | annotation ( |
|---|
| 329 | Documentation(info="<HTML> |
|---|
| 330 | <h4>4 to 1 Bit Multiplexer</h4> |
|---|
| 331 | <P> |
|---|
| 332 | The multiplexer converts a parallel 4 bit signal in a sequential |
|---|
| 333 | 1 bit stream. |
|---|
| 334 | </P> |
|---|
| 335 | </HTML> |
|---|
| 336 | "), Icon(coordinateSystem( |
|---|
| 337 | preserveAspectRatio=true, |
|---|
| 338 | extent={{-100,-100},{100,100}}, |
|---|
| 339 | grid={2,2}), graphics={Rectangle( |
|---|
| 340 | extent={{-100,100},{100,-100}}, |
|---|
| 341 | lineColor={0,0,0}, |
|---|
| 342 | lineThickness=0.5, |
|---|
| 343 | fillColor={255,255,170}, |
|---|
| 344 | fillPattern=FillPattern.Solid)}), |
|---|
| 345 | Diagram(coordinateSystem( |
|---|
| 346 | preserveAspectRatio=true, |
|---|
| 347 | extent={{-100,-100},{100,100}}, |
|---|
| 348 | grid={2,2}), graphics) |
|---|
| 349 | , |
|---|
| 350 | experiment(StopTime=250)); |
|---|
| 351 | D.Sources.Clock CLK(period=20) annotation (Placement(transformation( |
|---|
| 352 | extent={{-80,-56},{-60,-36}}, rotation=0))); |
|---|
| 353 | D.Sources.Table D0( |
|---|
| 354 | y0=3, |
|---|
| 355 | x={4,3,4,3}, |
|---|
| 356 | t={50,100,145,200}) annotation (Placement(transformation(extent={{-80, |
|---|
| 357 | 58},{-60,78}}, rotation=0))); |
|---|
| 358 | D.Sources.Table D1( |
|---|
| 359 | y0=3, |
|---|
| 360 | x={4,3,4,3}, |
|---|
| 361 | t={22,140,150,180}) annotation (Placement(transformation(extent={{-80, |
|---|
| 362 | 32},{-60,52}}, rotation=0))); |
|---|
| 363 | D.Examples.Utilities.MUX4 MUX annotation (Placement(transformation(extent= |
|---|
| 364 | {{-10,0},{70,80}}, rotation=0))); |
|---|
| 365 | D.Sources.Table D2( |
|---|
| 366 | y0=3, |
|---|
| 367 | x={4,3,4,3}, |
|---|
| 368 | t={22,140,150,180}) annotation (Placement(transformation(extent={{-80,6}, |
|---|
| 369 | {-60,26}}, rotation=0))); |
|---|
| 370 | D.Sources.Table D3( |
|---|
| 371 | y0=3, |
|---|
| 372 | x={4,3,4,3}, |
|---|
| 373 | t={22,140,150,180}) annotation (Placement(transformation(extent={{-80, |
|---|
| 374 | -20},{-60,0}}, rotation=0))); |
|---|
| 375 | D.Examples.Utilities.JKFF FF annotation (Placement(transformation(extent= |
|---|
| 376 | {{-20,-62},{0,-42}}, rotation=0))); |
|---|
| 377 | D.Sources.Set Enable annotation (Placement(transformation(extent={{-80, |
|---|
| 378 | -82},{-60,-62}}, rotation=0))); |
|---|
| 379 | equation |
|---|
| 380 | connect(CLK.y, FF.clk) annotation (Line( |
|---|
| 381 | points={{-60,-46},{-36,-46},{-36,-52},{-20,-52}}, |
|---|
| 382 | color={127,0,127})); |
|---|
| 383 | connect(Enable.y, FF.k) annotation (Line( |
|---|
| 384 | points={{-60,-72},{-30,-72},{-30,-59},{-20,-59}}, |
|---|
| 385 | color={127,0,127})); |
|---|
| 386 | connect(Enable.y, FF.j) annotation (Line( |
|---|
| 387 | points={{-60,-72},{-30,-72},{-30,-45},{-20,-45}}, |
|---|
| 388 | color={127,0,127})); |
|---|
| 389 | connect(CLK.y, MUX.a0) annotation (Line( |
|---|
| 390 | points={{-60,-46},{-36,-46},{-36,22.4},{-10,22.4}}, |
|---|
| 391 | color={127,0,127})); |
|---|
| 392 | connect(D0.y, MUX.d0) annotation (Line( |
|---|
| 393 | points={{-60,68},{-10,68}}, |
|---|
| 394 | color={127,0,127})); |
|---|
| 395 | connect(D1.y, MUX.d1) annotation (Line( |
|---|
| 396 | points={{-60,42},{-54,42},{-54,57.6},{-10,57.6}}, |
|---|
| 397 | color={127,0,127})); |
|---|
| 398 | connect(D2.y, MUX.d2) annotation (Line( |
|---|
| 399 | points={{-60,16},{-50,16},{-50,47.2},{-10,47.2}}, |
|---|
| 400 | color={127,0,127})); |
|---|
| 401 | connect(D3.y, MUX.d3) annotation (Line( |
|---|
| 402 | points={{-60,-10},{-46,-10},{-46,36.8},{-10,36.8}}, |
|---|
| 403 | color={127,0,127})); |
|---|
| 404 | connect(FF.q, MUX.a1) annotation (Line( |
|---|
| 405 | points={{0,-45},{2,-45},{2,-22},{-20,-22},{-20,12},{-10,12}}, |
|---|
| 406 | color={127,0,127})); |
|---|
| 407 | end Multiplexer; |
|---|
| 408 | |
|---|
| 409 | model FlipFlop "Pulse Triggered Master Slave Flip-Flop" |
|---|
| 410 | import D = Modelica.Electrical.Digital; |
|---|
| 411 | import L = Modelica.Electrical.Digital.Interfaces.Logic; |
|---|
| 412 | annotation ( |
|---|
| 413 | Documentation(info="<HTML> |
|---|
| 414 | <h4>FlipFlop</h4> |
|---|
| 415 | <P> |
|---|
| 416 | Pulse-triggered master-slave flip-flop. |
|---|
| 417 | </P> |
|---|
| 418 | </HTML> |
|---|
| 419 | "), Icon(coordinateSystem( |
|---|
| 420 | preserveAspectRatio=true, |
|---|
| 421 | extent={{-100,-100},{100,100}}, |
|---|
| 422 | grid={2,2}), graphics={Rectangle( |
|---|
| 423 | extent={{-100,100},{100,-100}}, |
|---|
| 424 | lineColor={0,0,0}, |
|---|
| 425 | lineThickness=0.5, |
|---|
| 426 | fillColor={255,255,170}, |
|---|
| 427 | fillPattern=FillPattern.Solid)}), |
|---|
| 428 | Diagram(coordinateSystem( |
|---|
| 429 | preserveAspectRatio=true, |
|---|
| 430 | extent={{-100,-100},{100,100}}, |
|---|
| 431 | grid={2,2}), graphics) |
|---|
| 432 | , |
|---|
| 433 | experiment(StopTime=250)); |
|---|
| 434 | D.Examples.Utilities.JKFF FF |
|---|
| 435 | annotation (Placement(transformation(extent={{-10,-40},{70, |
|---|
| 436 | 40}}, rotation=0))); |
|---|
| 437 | D.Sources.Clock CLK(period=10) annotation (Placement(transformation( |
|---|
| 438 | extent={{-80,-10},{-60,10}}, rotation=0))); |
|---|
| 439 | D.Sources.Table J( |
|---|
| 440 | y0=3, |
|---|
| 441 | x={4,3,4,3}, |
|---|
| 442 | t={50,100,145,200}) annotation (Placement(transformation(extent={{-80, |
|---|
| 443 | 18},{-60,38}}, rotation=0))); |
|---|
| 444 | D.Sources.Table K( |
|---|
| 445 | y0=3, |
|---|
| 446 | x={4,3,4,3}, |
|---|
| 447 | t={22,140,150,180}) annotation (Placement(transformation(extent={{-80, |
|---|
| 448 | -38},{-60,-18}}, rotation=0))); |
|---|
| 449 | equation |
|---|
| 450 | connect(J.y, FF.j) annotation (Line( |
|---|
| 451 | points={{-60,28},{-10,28}}, |
|---|
| 452 | color={127,0,127})); |
|---|
| 453 | connect(CLK.y, FF.clk) annotation (Line( |
|---|
| 454 | points={{-60,0},{-10,0}}, |
|---|
| 455 | color={127,0,127})); |
|---|
| 456 | connect(K.y, FF.k) annotation (Line( |
|---|
| 457 | points={{-60,-28},{-10,-28}}, |
|---|
| 458 | color={127,0,127})); |
|---|
| 459 | end FlipFlop; |
|---|
| 460 | |
|---|
| 461 | model HalfAdder "adding circuit for binary numbers without input carry bit" |
|---|
| 462 | import Modelica.Electrical.Digital; |
|---|
| 463 | annotation ( |
|---|
| 464 | Documentation(info="<HTML> |
|---|
| 465 | <P> |
|---|
| 466 | This example demonstrates an adding circuit for binary numbers, which internally realizes the interconnection to |
|---|
| 467 | And and to Xor in the final sum. |
|---|
| 468 | <br> |
|---|
| 469 | <br> |
|---|
| 470 | 1 + 0 = 1<br> |
|---|
| 471 | 0 + 1 = 1<br> |
|---|
| 472 | 1 + 1 = 10<br> |
|---|
| 473 | 0 + 0 = 0 |
|---|
| 474 | <br> |
|---|
| 475 | <br> |
|---|
| 476 | <b>a</b> + <b>b</b> = <b>s</b> |
|---|
| 477 | <br>(The carry of this adding is <b>c</b>.) |
|---|
| 478 | <br> |
|---|
| 479 | <br>and |
|---|
| 480 | <br> |
|---|
| 481 | <br> |
|---|
| 482 | <b>a</b> * <b>b</b> = <b>s</b> |
|---|
| 483 | <br> (It is an interconnection to And.) |
|---|
| 484 | <br> |
|---|
| 485 | <br> |
|---|
| 486 | <b>a</b> * <b>b</b> + <b>a</b> * <b>b</b> = <b>a</b> Xor <b>b</b> = <b>c</b> |
|---|
| 487 | <br>(It is an interconnection to Xor.) |
|---|
| 488 | <br> |
|---|
| 489 | <br> |
|---|
| 490 | <pre> <b>a</b> <b>b</b> <b>c</b> <b>s</b> <b>t</b></pre> |
|---|
| 491 | |
|---|
| 492 | <pre> 1 0 1 0 1</pre> |
|---|
| 493 | <pre> 0 1 1 0 2</pre> |
|---|
| 494 | <pre> 1 1 0 1 3</pre> |
|---|
| 495 | <pre> 0 0 0 0 4</pre> |
|---|
| 496 | |
|---|
| 497 | <br> |
|---|
| 498 | <br> |
|---|
| 499 | <b>t</b> is the pick-up instant of the next bit(s) in the simulation. |
|---|
| 500 | The simulation stop time should be 5 seconds. |
|---|
| 501 | </P> |
|---|
| 502 | </HTML> |
|---|
| 503 | "), Icon(coordinateSystem( |
|---|
| 504 | preserveAspectRatio=true, |
|---|
| 505 | extent={{-100,-100},{100,100}}, |
|---|
| 506 | grid={2,2}), graphics={Rectangle( |
|---|
| 507 | extent={{-88,100},{90,-100}}, |
|---|
| 508 | lineColor={0,0,0}, |
|---|
| 509 | lineThickness=0.5, |
|---|
| 510 | fillColor={255,255,170}, |
|---|
| 511 | fillPattern=FillPattern.Solid), Line(points={{40,54},{40,60},{-40, |
|---|
| 512 | 60},{10,0},{-40,-60},{40,-60},{40,-52}}, color={0,0,0})}), |
|---|
| 513 | Diagram(coordinateSystem( |
|---|
| 514 | preserveAspectRatio=true, |
|---|
| 515 | extent={{-100,-100},{100,100}}, |
|---|
| 516 | grid={2,2}), graphics) |
|---|
| 517 | , |
|---|
| 518 | experiment(StopTime=5)); |
|---|
| 519 | |
|---|
| 520 | Sources.Table a( |
|---|
| 521 | t={1,2,3,4}, |
|---|
| 522 | x={4,3,4,3}, |
|---|
| 523 | y0=3) annotation (Placement(transformation(extent={{-80,18},{-60,38}}, |
|---|
| 524 | rotation=0))); |
|---|
| 525 | Sources.Table b( |
|---|
| 526 | x={4,3}, |
|---|
| 527 | t={2,4}, |
|---|
| 528 | y0=3) annotation (Placement(transformation(extent={{-80,-38},{-60,-18}}, |
|---|
| 529 | rotation=0))); |
|---|
| 530 | Digital.Examples.Utilities.HalfAdder Adder(delayTime=0.3) |
|---|
| 531 | annotation (Placement(transformation(extent={{-40, |
|---|
| 532 | -40},{40,40}}, rotation=0))); |
|---|
| 533 | Digital.Converters.LogicToReal s |
|---|
| 534 | annotation (Placement(transformation(extent={{60, |
|---|
| 535 | 18},{80,38}}, rotation=0))); |
|---|
| 536 | Digital.Converters.LogicToReal c |
|---|
| 537 | annotation (Placement(transformation(extent={{60, |
|---|
| 538 | -38},{80,-18}}, rotation=0))); |
|---|
| 539 | equation |
|---|
| 540 | connect(b.y,Adder. b) annotation (Line( |
|---|
| 541 | points={{-60,-28},{-40,-28}}, |
|---|
| 542 | color={127,0,127})); |
|---|
| 543 | connect(a.y,Adder. a) annotation (Line( |
|---|
| 544 | points={{-60,28},{-40,28}}, |
|---|
| 545 | color={127,0,127})); |
|---|
| 546 | connect(Adder.s, s.x[1]) annotation (Line(points={{40,28},{65,28}}, color= |
|---|
| 547 | {127,0,127})); |
|---|
| 548 | connect(Adder.c, c.x[1]) annotation (Line(points={{40,-28},{65,-28}}, |
|---|
| 549 | color={127,0,127})); |
|---|
| 550 | end HalfAdder; |
|---|
| 551 | |
|---|
| 552 | model FullAdder "Full 1 Bit Adder Example" |
|---|
| 553 | import D = Modelica.Electrical.Digital; |
|---|
| 554 | import L = Modelica.Electrical.Digital.Interfaces.Logic; |
|---|
| 555 | annotation ( |
|---|
| 556 | Documentation(info="<HTML> |
|---|
| 557 | <P> |
|---|
| 558 | <br>It is an adding circuit for binary numbers with input carry bit, which consists of two HalfAdders. |
|---|
| 559 | <br> |
|---|
| 560 | <br> |
|---|
| 561 | <b>a</b>.y, <b>b</b>.y and <b>c</b>.y are the inputs of the FullAdder. |
|---|
| 562 | <br> |
|---|
| 563 | <b>c</b>out = <b& |
|---|