Changes between Version 8 and Version 9 of Component/Vci Multi Timer


Ignore:
Timestamp:
May 9, 2007, 3:00:29 PM (17 years ago)
Author:
Nicolas Pouillon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Component/Vci Multi Timer

    v8 v9  
    55This VCI target is a memory mapped peripheral that can
    66control up to 256 software controlled timers.
    7 Each timer can optionally generates an independent periodic interrupt.
     7Each timer can optionally generate an independent periodic interrupt.
    88The memory segment allocated to this component must be aligned
    99on 4K bytes boundary.
    10 The timer index i is defined by the ADDRESS![12:4] bits.
     10
    1111This hardware component cheks for segmentation violation, and can be used
    1212as a default target.
    1313
     14= Memory region layout =
     15
     16The timer index i is defined by the ADDRESS![12:4] bits.
     17
    1418Each timer contains 4 memory mapped registers:
    1519
    16  * '''TIMER_VALUE'''     : ADDRESS![3:0] = 0x0
    17 This 32 bits register is unconditionnally incremented at each cycle.
     20 * `TIMER_VALUE`: ADDRESS![3:0] = 0x0
     21This 32 bits register is unconditionally incremented at each cycle.
    1822A read request returns the current time contained in this register.
    1923A write request sets a new value in this register.
    2024
    21  * '''TIMER_RUNNING''' : ADDRESS![3:0] = 0x4
    22 When the Boolean value contained in this register is true,
    23 the corresponding interrupt is enabled. 
    24 A write request of a zero gives resets this register.
    25 A write request of a non-zero value sets this registe.
     25 * `TIMER_MODE`: ADDRESS![3:0] = 0x4
     26   This register contains two flags:
     27   * Bit 0: TIMER_RUNNING. When 1, the associated timer will decrease on each cycle
     28   * Bit 1: TIMER_IRQ_ENABLED: When 1, the associated IRQ line will be activated if the timer underflows.
    2629
    27  * '''TIMER_PERIOD'''    : ADDRESS![3:0] = 0x8
     30 * `TIMER_PERIOD`: ADDRESS![3:0] = 0x8
    2831This 32 bits register defines the period between two successive interrupts.
    29 A write request writes a new value in this register, and the TIMER_RUNNING
    30 register is set to false.
    31 A read request returns the current value in this register.
     32It may be read or written to.
    3233
    33  * '''TIMER_RESETIRQ''' : ADDRESS![3:0] = 0xC
     34 * `TIMER_RESETIRQ`: ADDRESS![3:0] = 0xC
    3435Any write request in this Boolean register will reset the pending IRQ.
    3536A read request returns the zero value when there is no pending interrupt,
    3637and returns a non zero value if there is a pending interrupt.
    3738
     39= Component usage =
     40
     41For extensibility issues, you should access your terminal using globally-defined offsets.
     42
     43You should include file source:trunk/soclib/include/soclib/timer.h from your software, it
     44defines `TIMER_VALUE`, `TIMER_MODE`, `TIMER_PERIOD`, `TIMER_RESETIRQ`, `TIMER_SPAN`,
     45`TIMER_RUNNING`, `TIMER_IRQ_ENABLED`.
     46
     47Sample code:
     48{{{
     49#include "soclib/tty.h"
     50
     51static const volatile void* timer_address = 0xc0000000;
     52
     53static timer_test(const size_t timer_no)
     54{
     55    volatile int *timer = ((int*)timer_address) + timer_no*TIMER_SPAN;
     56
     57    // Getting / setting timer current value
     58    timer[TIMER_VALUE] = 0x2a00;
     59    uint32_t foo = timer[TIMER_VALUE];
     60
     61    // Enabling timer and interrupt
     62    timer[TIMER_MODE] = TIMER_RUNNING | TIMER_IRQ_ENABLED;
     63
     64    // Getting IRQ status, and resetting IRQ
     65    if ( timer[TIMER_RESETIRQ] )
     66        timer[TIMER_RESETIRQ] = 0;
     67}
     68}}}
     69
     70(add -I/path/to/soclib/include to your compilation command-line)
     71
    3872= !VciMultiTimer CABA  Implementation =
    3973
    4074The caba implementation is in
    41  * source:trunk/soclib/systemc/include/caba/target/vci_multi_timer.h
    42  * source:trunk/soclib/systemc/src/caba/target/vci_multi_timer.cc
     75 * source:trunk/soclib/systemc/include/caba/target/vci_timer.h
     76 * source:trunk/soclib/systemc/src/caba/target/vci_timer.cc
    4377
    4478== Template parameters: ==
     79
    4580 * The VCI parameters
    4681
     
    5994 * sc_in<bool> '''p_clk''' : Global system clock
    6095 * soclib::caba::!VciTarget<vci_param> '''p_vci''' : The VCI port
    61  * sc_out<bool> '''*p_irq''' : Pointer on Interrupts ports table
     96 * sc_out<bool> '''p_irq[]''' : Interrupts ports array