claraty::DIO_sim Class Reference
#include <digital_io_sim.h>
Inheritance diagram for claraty::DIO_sim:


Public Member Functions | |
| DIO_sim (size_t n_bits, char *dir_str="", bool invert_signal=false) | |
| int | input () |
| int | output () |
| int | output (unsigned long data) |
| void | set_hw_bits (unsigned long data) |
| DIO_impl & | set_mask (unsigned long mask) |
| void | set_IO_direction (char *dir_str) |
| void | invert_IO (bool val=true) |
| std::string | to_str () const |
| void | print (const char *msg="") const |
Protected Attributes | |
| Bits | _data_bits |
| Bits | _mask_bits |
| int | _invert_signal |
Private Attributes | |
| Bits | _hw_bits |
Detailed Description
Definition at line 40 of file digital_io_sim.h.
Constructor & Destructor Documentation
| claraty::DIO_sim::DIO_sim | ( | size_t | n_bits, | |
| char * | dir_str = "", |
|||
| bool | invert_signal = false | |||
| ) |
Member Function Documentation
| int claraty::DIO_sim::input | ( | ) | [virtual] |
Implements claraty::DIO_impl.
Definition at line 40 of file digital_io_sim.cc.
References claraty::DIO_impl::_data_bits, _hw_bits, claraty::DIO_impl::_invert_signal, and OK.
00041 { 00042 _data_bits = _invert_signal ? ~_hw_bits : _hw_bits; 00043 00044 // _hw_bits.print("==DIO_sim::input() _hw_bits"); 00045 00046 return OK; 00047 }
| int claraty::DIO_sim::output | ( | ) | [virtual] |
Implements claraty::DIO_impl.
Definition at line 49 of file digital_io_sim.cc.
References claraty::DIO_impl::_data_bits, _hw_bits, claraty::DIO_impl::_invert_signal, and OK.
00050 { 00051 _hw_bits = _invert_signal ? ~_data_bits : _data_bits; 00052 00053 // _hw_bits.print("DIO_sim::output() _hw_bits"); 00054 00055 return OK; 00056 }
| int claraty::DIO_sim::output | ( | unsigned long | data | ) | [virtual] |
Implements claraty::DIO_impl.
Definition at line 58 of file digital_io_sim.cc.
References _hw_bits, and claraty::DIO_impl::_invert_signal.
00059 { 00060 _hw_bits = _invert_signal ? ~data : data; 00061 00062 // _hw_bits.print("==DIO_sim::output() _hw_bits"); 00063 00064 return 0; 00065 }
| void claraty::DIO_sim::set_hw_bits | ( | unsigned long | data | ) |
Definition at line 67 of file digital_io_sim.cc.
References _hw_bits, and claraty::Bits::print().
Here is the call graph for this function:

| DIO_impl & claraty::DIO_impl::set_mask | ( | unsigned long | mask | ) | [inherited] |
Definition at line 80 of file digital_io_impl.cc.
References claraty::DIO_impl::_mask_bits, and claraty::Bits::unchecked_set().
00081 { 00082 _mask_bits.unchecked_set (mask); // for effciency 00083 00084 return *this; 00085 }
Here is the call graph for this function:

| void claraty::DIO_impl::set_IO_direction | ( | char * | dir_str | ) | [inherited] |
Definition at line 87 of file digital_io_impl.cc.
References claraty::DIO_impl::_input_bits, claraty::DIO_impl::_output_bits, claraty::Bits::clr(), claraty::Bits::set(), and claraty::Bits::set_bit().
Referenced by claraty::DIO_impl::DIO_impl(), and claraty::DIO_null::DIO_null().
00088 { 00089 // Setting I/O direction for all bits: B = bi-directional for all bits 00090 // I = input for all bits 00091 // O = output for all bits 00092 // 00093 // Setting I/O direction for each bit 00094 // e.g., "BBIO" for 4 bits where rightmost character is bit 0 or LSB 00095 // 00096 // b = input bit 00097 // i = input bit 00098 // o = input bit 00099 // x = neither input nor output 00100 // 00101 00102 int len = strlen(dir_str); 00103 00104 00105 if (len == 1) { 00106 switch (dir_str[0]) { 00107 case 'B': 00108 _input_bits.set(); 00109 _output_bits.set(); 00110 return; 00111 case 'I': 00112 _input_bits.set(); 00113 _output_bits.clr(); 00114 return; 00115 case 'O': 00116 _input_bits.clr(); 00117 _output_bits.set(); 00118 return; 00119 } 00120 } 00121 00122 00123 _input_bits.clr(); 00124 _output_bits.clr(); 00125 00126 for (int i=0; i < len; ++i) { 00127 // start with the last character for bit 0 or LSB 00128 // 00129 switch (dir_str[len-i-1]) { 00130 case 'b': 00131 _input_bits.set_bit(i); 00132 _output_bits.set_bit(i); 00133 break; 00134 case 'i': 00135 _input_bits.set_bit(i); 00136 break; 00137 case 'o': 00138 _output_bits.set_bit(i); 00139 break; 00140 case 'x': 00141 break; 00142 default: 00143 cerr << "invalid argument DIO_impl::set_IO_direction" << endl; 00144 } // switch 00145 } // for i 00146 }
Here is the call graph for this function:

| void claraty::DIO_impl::invert_IO | ( | bool | val = true |
) | [inherited] |
Definition at line 149 of file digital_io_impl.cc.
References claraty::DIO_impl::_invert_signal.
00150 { 00151 // default: invert_signal 00152 // 00153 00154 _invert_signal = val; 00155 }
| string claraty::DIO_impl::to_str | ( | ) | const [inherited] |
Definition at line 158 of file digital_io_impl.cc.
References claraty::DIO_impl::_data_bits, and claraty::Bits::to_str().
00159 { 00160 return _data_bits.to_str(); 00161 }
Here is the call graph for this function:

| void claraty::DIO_impl::print | ( | const char * | msg = "" |
) | const [inherited] |
Definition at line 164 of file digital_io_impl.cc.
References claraty::DIO_impl::_data_bits, and claraty::Bits::print().
00165 { 00166 _data_bits.print(msg); 00167 }
Here is the call graph for this function:

Member Data Documentation
Bits claraty::DIO_sim::_hw_bits [private] |
Bits claraty::DIO_impl::_data_bits [protected, inherited] |
Definition at line 72 of file digital_io_impl.h.
Referenced by claraty::DIO::clr(), claraty::DIO::clr_bit(), input(), claraty::DIO::operator unsigned long(), output(), claraty::DIO_impl::print(), claraty::DIO::set(), claraty::DIO::set_bit(), claraty::DIO::test(), claraty::DIO_impl::to_str(), claraty::DIO::toggle(), and claraty::DIO::toggle_bit().
Bits claraty::DIO_impl::_mask_bits [protected, inherited] |
Definition at line 73 of file digital_io_impl.h.
Referenced by claraty::DIO::input(), claraty::DIO::output(), and claraty::DIO_impl::set_mask().
int claraty::DIO_impl::_invert_signal [protected, inherited] |
Definition at line 74 of file digital_io_impl.h.
Referenced by claraty::DIO::DIO(), input(), claraty::DIO_impl::invert_IO(), claraty::DIO::operator unsigned long(), and output().
The documentation for this class was generated from the following files: