Wire Class Reference
|
yasimavr
|
General Purpose wire model. More...
#include <sim_wire.h>
Classes | |
| class | state_t |
Public Types | |
| enum | StateEnum { State_Floating = 0x00 , State_PullUp = 0x03 , State_PullDown = 0x01 , State_Analog = 0x04 , State_High = 0x07 , State_Low = 0x05 , State_Shorted = 0x80 , State_Error = 0x90 } |
| enum | SignalId { Signal_StateChange = 0 , Signal_DigitalChange , Signal_VoltageChange } |
Public Member Functions | |
| Wire () | |
| Wire (Wire &other) | |
| Wire (const Wire &other) | |
| virtual | ~Wire () |
| DataSignal & | signal () |
| const state_t & | state () const |
| bool | digital_state () const |
| double | voltage () const |
| void | set_state (const state_t &state) |
| void | set_state (StateEnum state, double v=0.0) |
| void | set_state (char state, double v=0.0) |
| void | attach (Wire &other) |
| void | detach () |
| bool | attached (const Wire &other) const |
| bool | attached () const |
| std::vector< Wire * > | siblings () const |
| Wire & | operator= (Wire &other) |
| Wire & | operator= (const Wire &other) |
Static Public Member Functions | |
| static StateEnum | char2state (char c) |
| static state_t | resolve_two_states (const state_t &a, const state_t &b) |
Protected Member Functions | |
| void | auto_resolve_state () |
| virtual void | notify_digital_state (bool state) |
| virtual state_t | state_for_resolution () const |
Detailed Description
General Purpose wire model.
This class models a logical line used to represents digital/analog electrical signals. Its main purpose is to serve as base class for the MCU pin models and can be used by external component models to simulate digital or analog signals connected to a MCU model.
Wires need to be attached to each other. An attachment represents an electrical connection between two input and/or output circuits. Wires have a individual state (one of the State enum values) representing how the local circuit is driving them (or not driving) and a resolved state, shared by all attached Wires representing the common state.
For example, if Wires A and B are attached, A's state is Floating, B's state is High, the common resolved state is High.
As for the rest of the library, analog voltage levels are relative to VCC, hence limited to the range [0.0, 1.0].
- See also
- Pin
Member Enumeration Documentation
◆ SignalId
| enum Wire::SignalId |
Signal IDs raised by the pin. For all signals, the index is set to the pin ID.
| Enumerator | |
|---|---|
| Signal_StateChange | Signal raised for any change of the resolved state. data is set to the new state (one of State enum values) |
| Signal_DigitalChange | Signal raised for any change of the resolved digital state. data is set to the new digital state (0 or 1). |
| Signal_VoltageChange | Signal raised for any change to the analog value, including when induced by a digital state change. data is set to the analog value (double, in range [0;1]) |
◆ StateEnum
| enum Wire::StateEnum |
Pin state enum. All the possible logical/analog electrical states that the wire can take.
| Enumerator | |
|---|---|
| State_Floating | |
| State_PullUp | |
| State_PullDown | |
| State_Analog | |
| State_High | |
| State_Low | |
| State_Shorted | |
| State_Error | |
Constructor & Destructor Documentation
◆ Wire() [1/3]
| Wire::Wire | ( | ) |
Build a Wire.
◆ Wire() [2/3]
◆ Wire() [3/3]
| Wire::Wire | ( | const Wire & | other | ) |
◆ ~Wire()
|
virtual |
Member Function Documentation
◆ attach()
| void Wire::attach | ( | Wire & | other | ) |
◆ attached() [1/2]
| bool Wire::attached | ( | ) | const |
- Returns
- whether 'this' is attached to any other Wire object.
◆ attached() [2/2]
| bool Wire::attached | ( | const Wire & | other | ) | const |
- Returns
- whether 'this' is attached to the other Wire object.
◆ auto_resolve_state()
|
protected |
◆ char2state()
|
static |
Converts an ASCII charcode into a wire state enum value :
- 'Z'/'z' : Floating
- 'H'/'h' : High
- 'L'/'l' : Low
- 'U'/'u' : PullUp
- 'D'/'d' : PullDown
- 'A'/'a' : Analog
- 'S'/'s' : Shorted
- any other value : Error
◆ detach()
| void Wire::detach | ( | ) |
Detach from all Wire 'this' is attached to.
◆ digital_state()
| bool Wire::digital_state | ( | ) | const |
Returns the resolved state reduced to a boolean.
◆ notify_digital_state()
|
protectedvirtual |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ resolve_two_states()
|
static |
Resolution algorithm for combining two state_t structures representing the logical state of two Wires attached together and returning the common resolved state.
◆ set_state() [1/3]
|
inline |
Set the state of the wire using a charcode
- See also
- char2state
- Parameters
-
state new Wire state level voltage level (only for the Analog state)
◆ set_state() [2/3]
◆ set_state() [3/3]
|
inline |
Set the state of the wire using one of the StateEnum values
- Parameters
-
state new Wire state level voltage level (only for the Analog state)
◆ siblings()
| std::vector< Wire * > Wire::siblings | ( | ) | const |
◆ signal()
|
inline |
- Returns
- the signal raising the state/value changes
◆ state()
|
inline |
- Returns
- the resolved state
◆ state_for_resolution()
|
protectedvirtual |
◆ voltage()
|
inline |
- Returns
- the pin voltage value
The documentation for this class was generated from the following files:
Generated by