TAMS / Java / Hades / applets (print version): contents | previous | next

#### Logic values and glow-mode colors

Description

The choice of the modeling approach is perhaps the single most important question in any simulation. A model must keep all essential details of the original system to allow studying the behaviour of the real system, but all non-essential details should be dropped. In the context of digital system simulation, a few abstraction levels have evolved as the most useful. Programs like the famous Spice simulator (and its many variants) use elaborate mathematical formulas to model the physics of individual electronics devices like resitors, capacitors, and transistors. The formulas describe the voltages and currents involved, while enviromental effects like temperature or radiation are included whenever necessary. Differential equation solvers are then used to calculate the details of the device operation, with very high precision. However, due to the high computation cost and long simulation times, only a few components (at most a few dozen components) can be simulated.

The gate-level (or logic level) is then used as the next-higher abstraction level to describe digital systems. Here, a set of predefined logic values is used instead of the actual physical representation like voltages or currents. The Boolean algebra with its 0/1-value system is the obvious candidate for device modeling on the gate-level, because all basic gates and flipflops can be described with corresponding binary models. However, Boolean algebra describes ideal devices, while logic simulation is also meant to detect problems like short-circuits, inactive buses, or un-initialized flipflops. Therefore, additional logic levels like 'X' (un-defined) or 'Z' (tri-state) are often introduced to model such non-ideal behaviour of real circuits.

#### The std_logic_1164 nine-valued logic system

Hades uses the nine-valued logic system called std_logic_1164 for all of its gate-level and system-level simulation components. The original standard (IEEE Std 1164-1993) is called IEEE Standard Multivalue Logic System for VHDL Model Interoperability (Std_logic_1164) and is available on request from the IEEE. The standard was desiged to provide a common denominator for VHDL simulation models and simulators from different vendors, and it has become the industry standard for multilevel logic. The std_logic system defines nine logical values:

U       the "undefined" value which has never been assigned to.
All signals and components are initialized to this state
at the start of a simulation run.

X       an "invalid" or "unknown" value, e.g. the result of a short-circuit
condition.

0       the logical "0" or "low" value  (e.g. represented by 0 volts)

1       the logical "1" or "high" value (e.g. 3.3 or 5 volts)

The following states are used to model buses:

Z       a floating value, a signal not driven by any component

W       a weak unknown value.

L       a weak "low" value, e.g. a signal connected to a pulldown resistor.

H       a weak "high" value, e.g. a signal connected to a pullup resistor.

D       the "don't care" value is only used as input for logic synthesis
tools and does not occur during simulations.

The main advantage of std_logic over simpler systems like traditional Boolean logic (0/1) is that it allows modeling undefined and illegal logic values, as well as microprocessor system buses. Several examples of this will be seen in the later applets.

Most circuits only use the 0- and 1-values during the simulation, while U indicates signals that have not yet been initialized, and X indicates real malfunctions. The remaining values, namely Z, W, L, and H, are only used when necessary to model signals (buses) with multiple drivers. The special 'D' value is not used at all during simulation, but only as input to logic synthesis tools.

In the applet above, the utility classes hades.models.io.ConstantU .. hades.models.io.ConstantH are used to generate the corresponding std_logic values. (Note that these simulation components are not included in the default editor popup menu, because they are seldom used. To create these components, either use the component browser, or select popup->create->create by name, and then enter the class name, e.g. 'hades.models.io.ConstantH').

The INVERTER and AND-gate examples are meant to illustrate a few important combinations of std_logic values. Note that the 0 input value is a dominating value for the AND gate - a 0 input value at one input results in a 0 output value. Finally, a weak 1 (that is, H) at the AND gate input is treated exactly the same as a strong 1, because the gate transistors amplify this value. Therefore, AND(H,1) results in an output value of 1.

The applet also shows the glow mode colors used by Hades to visualize the std_logic values. The default settings use light gray for 0, red for 1, and orange for Z. The U and X values are shown in cyan and magenta, allowing to detect undefined and invalid logical values at one glance. Try to switch glow-mode on and off via the corresponding menu items in the editor layers menu or popup menu. You can also just press the 'g' key on the main object canvas to toggle glow mode. Note that LED and output pin components will still display their colors, even if glow mode is off.

Note that you can change the colors via settings in the Hades configuration files. For example, add the following lines to your user configuration file (called .hadesrc in your home directory), and enter the new RGB values for the colors:

# default glow-mode colors for StdLogic1164 values
#