| | 1 | = MutekS = |
| | 2 | |
| | 3 | MutekS is a System Resource API restricted to DSX users' needs: |
| | 4 | * Tasks |
| | 5 | * (shared) memory, locks, barriers |
| | 6 | * MWMR channels |
| | 7 | |
| | 8 | * For compatibility and portability this API may be implemented over POSIX threads. |
| | 9 | * For performance this API is implemented directly on Hexo. This implementation is MutekS. |
| | 10 | |
| | 11 | In the MutekH project, MutekS is distributed as an SRL library, ie [source:trunk/mutekh/libsrl libsrl]. |
| | 12 | |
| | 13 | = Srl API = |
| | 14 | |
| | 15 | The Srl API is an abstraction layer that provides the software programmer |
| | 16 | an easy acces to several [wiki:DsxResource "communication and synchronisation resources"]. |
| | 17 | |
| | 18 | Thanks to the Srl (System Ressource Layer) API, the same code can be compiled and executed |
| | 19 | on several platforms such as |
| | 20 | * a Linux/Posix workstation |
| | 21 | * an MP-SoC architecture running the Mutek OS. |
| | 22 | |
| | 23 | The code of the tasks is supposed to be written in C. |
| | 24 | |
| | 25 | == Mwmr Communication Channels == |
| | 26 | |
| | 27 | * {{{srl_mwmr_t channel = GET_ARG(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. |
| | 28 | |
| | 29 | * {{{srl_mwmr_read(channel, local_buffer, size)}}} reads ''size'' 32-bit words 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. |
| | 30 | |
| | 31 | * {{{srl_mwmr_write(channel, local_buffer, size)}}} writes ''size'' 32-bit words 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. |
| | 32 | |
| | 33 | == Locks == |
| | 34 | |
| | 35 | * {{{srl_lock_t lock = GET_ARG(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. |
| | 36 | |
| | 37 | * {{{srl_lock_lock( lock )}}} takes a lock, waiting if necessary |
| | 38 | * {{{srl_lock_unlock( lock )}}} releases the lock |
| | 39 | |
| | 40 | == Barriers == |
| | 41 | |
| | 42 | * {{{srl_barrier_t barrier = GET_ARG(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. |
| | 43 | |
| | 44 | * {{{srl_barrier_wait( barrier )}}} waits for a barrier-global synchronization |
| | 45 | |
| | 46 | == Logging == |
| | 47 | |
| | 48 | 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. |
| | 49 | |
| | 50 | In order, levels are: |
| | 51 | * NONE |
| | 52 | * TRACE |
| | 53 | * DEBUG |
| | 54 | * MAX |
| | 55 | |
| | 56 | 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. |
| | 57 | |
| | 58 | * {{{srl_log(level, "message")}}} prints a message |
| | 59 | * {{{srl_log_printf(level, "message_with_format", arguments...)}}} prints a printf-like message |
| | 60 | |
| | 61 | 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: |
| | 62 | {{{ |
| | 63 | srl_log_printf(DEBUG, "i=%d\n", i++); |
| | 64 | }}} |
| | 65 | |
| | 66 | == Other services == |
| | 67 | |
| | 68 | * {{{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. |
| | 69 | * {{{srl_mwmr_config( controller_name, reg_n, value )}}} puts value ''value'' in the config register ''reg_n'' of specified controller |
| | 70 | * {{{srl_mwmr_status( controller_name, reg_n )}}} reads status register ''reg_n'' of specified controller, returns a int32_t |
| | 71 | * {{{srl_assert( cond )}}} checks if ''cond'' is true, and fatally fails otherwise |
| | 72 | < |