[wiki:Component SocLib Components General Index] = !VciMultiTty = == 1) Functional Description == This VCI target is a TTY terminal controller. This hardware component controls one or several independant terminals. The number of emulated terminals is defined by the arguments in the constructor (one name per terminal). Each terminal is acting both as a character display, and a keyboard interface. For each terminal, a specific IRQ is activated when a character entered at the keyboard is available in a buffer. IRQ is kept low as long as the buffer is not empty. This hardware component cheks for segmentation violation, and can be used as a default target. This component uses a [wiki:Component/TtyWrapper TtyWrapper] per terminal in order to abstract the simulated ttys. The terminal index ''i'' is defined by the ADDRESS![12:4] bits. Each TTY controller contains 3 memory mapped registers: * `TTY_WRITE` This 8 bits pseudo-register is write only. Any write request will interpret the 8 LSB bits of the WDATA field as an ASCII character, and this character will be displayed on the addressed terminal. * `TTY_STATUS` This Boolean status register is read-only. A read request returns the zero value if there is no pending character. It returns a non zero value if there is a pending character in the keyboard buffer. * `TTY_READ` This 8 bits register contains one single ASCII character. This register is read-only. A read request returns the ACSII character in the 8 LSB bits of the RDATA field, and reset the status register. For extensibility issues, you should access your terminal using globally-defined offsets. The file source:trunk/soclib/soclib/module/connectivity_component/vci_multi_tty/include/soclib/tty.h defines `TTY_WRITE`, `TTY_STATUS`, `TTY_READ` and `TTY_SPAN`. A putc/getc implementation could be: {{{ #include "soclib/tty.h" static const volatile void* tty_address = 0xc0000000; static inline void putc(const size_t term_no, const char x) { soclib_io_set( tty_address, term_no*TTY_SPAN + TTY_WRITE, x ); } static inline char getc(const size_t term_no) { return soclib_io_get( tty_address, term_no*TTY_SPAN + TTY_READ ); } }}} (add -I/path/to/soclib/include to your compilation command-line) == 2) Component definition & usage == source:trunk/soclib/soclib/module/connectivity_component/vci_multi_tty/caba/metadata/vci_multi_tty.sd {{{ Uses( 'vci_multi_tty' ) }}} == 3) CABA Implementation == === CABA sources === * interface : source:trunk/soclib/soclib/module/connectivity_component/vci_multi_tty/caba/source/include/vci_multi_tty.h * implementation : source:trunk/soclib/soclib/module/connectivity_component/vci_multi_tty/caba/source/src/vci_multi_tty.cpp === CABA Constructor parameters === * With a known number of ttys {{{ VciMultiTty( sc_module_name name, // Instance name const soclib::common::IntTab &index, // Target index const soclib::common::MappingTable &mt, // Mapping Table const char *first_tty_name, ...); // TTY names (as many names as terminals), NULL terminated }}} * With a variable number of ttys {{{ VciMultiTty( sc_module_name name, const IntTab &index, const MappingTable &mt, const std::vector &names ); }}} Example instanciation: * With a known number of ttys {{{ VciMultiTty tty("tty_comp", IntTab(2,3), mapping_table, "term0", "term1", "term2", NULL); }}} Note : the name list MUST be terminated by NULL. * With a variable number of ttys {{{ std::vector names; names.push_back("term0"); names.push_back("term1"); names.push_back("term2"); VciMultiTty("tty_comp", IntTab(2,3), mapping_table, names); }}} === CABA Ports === * '''p_resetn''' : Global system reset * '''p_clk''' : Global system clock * '''p_vci''' : VCI target port * '''p_irq[i]''' : as many interrupt ports as terminals. == 4) TLM-DT Implementation == === TLM-DT sources === * interface : source:trunk/soclib/soclib/module/connectivity_component/vci_multi_tty/tlmdt/source/include/vci_multi_tty.h * implementation : source:trunk/soclib/soclib/module/connectivity_component/vci_multi_tty/tlmdt/source/src/vci_multi_tty.cpp === TLM-DT Constructor parameters === {{{ VciMultiTty( sc_module_name name, // Instance name const soclib::common::IntTab &index, // Target index const soclib::common::MappingTable &mt, // Mapping Table const char *first_tty_name, ...); // TTY names (as many names as terminals) }}} === TLM-DT Ports === * '''p_vci''' : VCI target port * '''p_irq[i]''' : as many IRQ output ports as terminals