[wiki:Component SocLib Components General Index] = !VciMultiTimer Functional Description = This VCI target is a memory mapped peripheral that can control up to 256 software controlled timers. Each timer can optionally generate an independent periodic interrupt. The memory segment allocated to this component must be aligned on 4K bytes boundary. This hardware component cheks for segmentation violation, and can be used as a default target. = Memory region layout = The timer index i is defined by the ADDRESS![12:4] bits. Each timer contains 4 memory mapped registers: * `TIMER_VALUE`: ADDRESS![3:0] = 0x0 This 32 bits register is unconditionally incremented at each cycle. A read request returns the current time contained in this register. A write request sets a new value in this register. * `TIMER_MODE`: ADDRESS![3:0] = 0x4 This register contains two flags: * Bit 0: TIMER_RUNNING. When 1, the associated timer will decrease on each cycle * Bit 1: TIMER_IRQ_ENABLED: When 1, the associated IRQ line will be activated if the timer underflows. * `TIMER_PERIOD`: ADDRESS![3:0] = 0x8 This 32 bits register defines the period between two successive interrupts. It may be read or written to. * `TIMER_RESETIRQ`: ADDRESS![3:0] = 0xC Any write request in this Boolean register will reset the pending IRQ. A read request returns the zero value when there is no pending interrupt, and returns a non zero value if there is a pending interrupt. = Component usage = For extensibility issues, you should access your terminal using globally-defined offsets. You should include file source:trunk/soclib/include/soclib/timer.h from your software, it defines `TIMER_VALUE`, `TIMER_MODE`, `TIMER_PERIOD`, `TIMER_RESETIRQ`, `TIMER_SPAN`, `TIMER_RUNNING`, `TIMER_IRQ_ENABLED`. Sample code: {{{ #include "soclib/tty.h" static const volatile void* timer_address = 0xc0000000; static timer_test(const size_t timer_no) { volatile int *timer = ((int*)timer_address) + timer_no*TIMER_SPAN; // Getting / setting timer current value timer[TIMER_VALUE] = 0x2a00; uint32_t foo = timer[TIMER_VALUE]; // Enabling timer and interrupt timer[TIMER_MODE] = TIMER_RUNNING | TIMER_IRQ_ENABLED; // Getting IRQ status, and resetting IRQ if ( timer[TIMER_RESETIRQ] ) timer[TIMER_RESETIRQ] = 0; } }}} (add -I/path/to/soclib/include to your compilation command-line) = !VciMultiTimer CABA Implementation = The caba implementation is in * source:trunk/soclib/systemc/include/caba/target/vci_timer.h * source:trunk/soclib/systemc/src/caba/target/vci_timer.cc == Template parameters: == * The VCI parameters == Constructor parameters == {{{ VciMultiTimer( sc_module_name name, // Component Name const soclib::common::IntTab & index, // Target index const soclib::common::MappingTable &mt, // MappingTable size_t nirq); // Number of available timers }}} == Ports == * sc_in '''p_resetn''' : Global system reset * sc_in '''p_clk''' : Global system clock * soclib::caba::!VciTarget '''p_vci''' : The VCI port * sc_out '''p_irq[]''' : Interrupts ports array