| 1 | = Srl API = |
| 2 | |
| 3 | This Chapter describe the use of the SRL API in DSX-VM (inspired from DSX SRL API). |
| 4 | |
| 5 | The Srl API is an abstraction layer that provides the software programmer |
| 6 | an easy acces to several software resources. |
| 7 | |
| 8 | Thanks to the Srl (System Ressource Layer) API, the same code can be compiled and executed |
| 9 | on several platforms such as |
| 10 | * a Linux/Posix workstation |
| 11 | * an MP-SoC architecture running the Mutek OS. |
| 12 | |
| 13 | The code of the tasks is supposed to be written in C. |
| 14 | |
| 15 | == Mwmr Communication Channels == |
| 16 | |
| 17 | * {{{srl_mwmr_t channel = GET_MWMR(port_name)}}} defines a local variable associated to a MWMR channel acces port. The ''port_name'' argument corresponds to the port name defined in the task model defined in the DSX/L description. |
| 18 | |
| 19 | * {{{srl_mwmr_read(channel, local_buffer, size)}}} reads ''size'' bytes from the MWMR channel to the local buffer. The ''local_buffer'' argument is a void*. The size argument must be a multiple of the channel width, and the the channel width must be a multiple of 4 bytes. |
| 20 | |
| 21 | * {{{srl_mwmr_write(channel, local_buffer, size)}}} writes ''size'' bytes from the local buffer to the MWMR channel. The ''local_buffer'' argument is a void*. The ''size'' argument must be a multiple of the channel width, and the channel width must be a multiple of 4 bytes. |
| 22 | |
| 23 | == Locks == |
| 24 | |
| 25 | * {{{srl_lock_t lock = GET_LOCK(port_name)}}} defines a local variable associated to a lock. The ''port_name'' argument corresponds to the port name defined in the task model defined in the DSX/L description. |
| 26 | |
| 27 | * {{{srl_lock_lock( lock )}}} takes a lock, waiting if necessary |
| 28 | * {{{srl_lock_unlock( lock )}}} releases the lock |
| 29 | |
| 30 | == Barriers == |
| 31 | |
| 32 | * {{{srl_barrier_t barrier = GET_BARRIER(port_name)}}} defines a local variable associated to a barrier. The ''port_name'' argument corresponds to the port name defined in the task model defined in the DSX/L description. |
| 33 | |
| 34 | * {{{srl_barrier_wait( barrier )}}} waits for a barrier-global synchronization |
| 35 | |
| 36 | == Logging == |
| 37 | |
| 38 | Log API let you define several message levels. Levels allow you to keep the debug code in the source, and only compile it when needed. |
| 39 | |
| 40 | In order, levels are: |
| 41 | * NONE |
| 42 | * TRACE |
| 43 | * DEBUG |
| 44 | * MAX |
| 45 | |
| 46 | When writing your software, you decide what level the message is for. When compiling or running you software, you decide what minimal level your code must have to be printed. |
| 47 | |
| 48 | * {{{srl_log(level, "message")}}} prints a message |
| 49 | * {{{srl_log_printf(level, "message_with_format", arguments...)}}} prints a printf-like message |
| 50 | |
| 51 | Arguments in printf-like version may be not evaluated if level is not sufficient. Therefore you '''MUST NOT''' put expressions with side effects in the parameter list. ie do '''not''' do this: |
| 52 | {{{ |
| 53 | srl_log_printf(DEBUG, "i=%d\n", i++); |
| 54 | }}} |
| 55 | |
| 56 | == Other services == |
| 57 | |
| 58 | * {{{srl_busy_cycles( N )}}} tells the simulation environment the simulation should run at least N cycles while in this call. This makes sense only for virtually synthetised tasks, otherwise, this call is a noop. |
| 59 | * {{{srl_assert( cond )}}} checks if ''cond'' is true, and fatally fails otherwise |
| 60 | * {{{srl_abort()}}} make the application (whatever the backend) abort now |
| 61 | |
| 62 | == Instrumentation services == |
| 63 | |
| 64 | * {{{srl_cycle_count()}}} returns the current cycle (most useful in a simulation context). On Posix, this returns the current millisecond since EPOCH (modulo 1^32). |