Parallella Fan!
Home記事一覧BBS

Epiphany SDKリファレンス概要



13.
Epiphany Hardware Utility Library (eLib)
13.1 Overview
The Epiphany Hardware Utility library provides functions for configuring and querying the
Epiphany hardware resources.  These routines automate many common programming tasks that
are not provided by the C and C++ languages and are specific to the Epiphany architecture.
In the following sections, the various eLib functions are described. Each section provides details
on a family of APIs.  The master header file for the eLib,  which includes all the per-family
headers, is the "e-lib.h" header file. Include this header file at the beginning of a program that
uses the eLib functions and objects.
#include "e-lib.h"

In order to use this library to build an Epiphany program,  use the e-gcc compiler
option -le-lib on the build command line.
Each core on the platform is referenced via a definition of a workgroup. Two global objects are
available at each core's space. One object, called e_group_config, contains the information
about the chip type, the workgroup's position and size, and the core's position in the containing
workgroup. Its members are:
e_group_config.chiptype   - Type of chip containing the core
e_group_config.group_id   - CoreID of first core in Workgroup
e_group_config.group_row  - Origin of Workgroup
e_group_config.group_col
e_group_config.group_rows - Size of Workgroup
e_group_config.group_cols
e_group_config.core_row   - Coordinates of core
e_group_config.core_col
The other object, called e_emem_config, contains information about the External Memory base
address. Its member is:
e_emem_config.base        - Absolute address of base of ext. mem.

In addition to the function prototypes and specific type enumerations,  the following definitions
are provided:  Two macro shortcuts for the  "align",  "packed"  and  "section"  function and
variable attributes are defined as:
#define ALIGN(x)   __attribute__ ((aligned (x)))
#define PACKED     __attribute__ ((packed))
#define SECTION(x) __attribute__ ((section (x)))

The e_bool_t type is defined as follows:
typedef enum {

E_FALSE,

E_TRUE,
} e_bool_t;
The e_return_stat_t type defined the eLib functions return values:
typedef enum {

E_OK,

E_ERR,

E_WARN,
} e_return_stat_t;




13.2 System Register Access Functions

13.2.1
Overview

The system register access functions enable the reading from and writing to the hardware special
registers.

Functions definition summary
unsigned e_reg_read(e_reg_id_t reg_id);
void e_reg_write(e_reg_id_t reg_id, unsigned val);


Enumerated constants and macros
// General Purpose Registers
typedef enum
{
    E_REG_R0,    E_REG_R8,    E_REG_R16,    E_REG_R24,
    E_REG_R1,    E_REG_R9,    E_REG_R17,    E_REG_R25,
    E_REG_R2,    E_REG_R10,   E_REG_R18,    E_REG_R26,
    E_REG_R3,    E_REG_R11,   E_REG_R19,    E_REG_R27,
    E_REG_R4,    E_REG_R12,   E_REG_R20,    E_REG_R28,
    E_REG_R5,    E_REG_R13,   E_REG_R21,    E_REG_R29,
    E_REG_R6,    E_REG_R14,   E_REG_R22,    E_REG_R30,
    E_REG_R7,    E_REG_R15,   E_REG_R23,    E_REG_R31,

    E_REG_R32,   E_REG_R40,   E_REG_R48,    E_REG_R56,
    E_REG_R33,   E_REG_R41,   E_REG_R49,    E_REG_R57,
    E_REG_R34,   E_REG_R42,   E_REG_R50,    E_REG_R58,
    E_REG_R35,   E_REG_R43,   E_REG_R51,    E_REG_R59,
    E_REG_R36,   E_REG_R44,   E_REG_R52,    E_REG_R60,
    E_REG_R37,   E_REG_R45,   E_REG_R53,    E_REG_R61,
    E_REG_R38,   E_REG_R46,   E_REG_R54,    E_REG_R62,
    E_REG_R39,   E_REG_R47,   E_REG_R55,    E_REG_R63,
} e_gp_reg_id_t;

// eCore Special Registers
typedef enum
{
    // Control Registers
    E_REG_CONFIG,             E_REG_IRET,
    E_REG_STATUS,             E_REG_IMASK,
    E_REG_FSTATUS,            E_REG_ILAT,
    E_REG_PC,                 E_REG_ILATST,
    E_REG_DEBUGSTATUS,        E_REG_ILATCL,
    E_REG_DEBUGCMD,           E_REG_IPEND,

    E_REG_LC,
    E_REG_LS,
    E_REG_LE,

    // DMA registers
    E_REG_DMA0CONFIG,         E_REG_DMA1CONFIG,
    E_REG_DMA0STRIDE,         E_REG_DMA1STRIDE,
    E_REG_DMA0COUNT,          E_REG_DMA1COUNT,
    E_REG_DMA0SRCADDR,        E_REG_DMA1SRCADDR,
    E_REG_DMA0DSTADDR,        E_REG_DMA1DSTADDR,
    E_REG_DMA0AUTODMA0,       E_REG_DMA1AUTODMA0,
    E_REG_DMA0AUTODMA1,       E_REG_DMA1AUTODMA1,
    E_REG_DMA0STATUS,         E_REG_DMA1STATUS,

    // Event Timer Registers
    E_REG_CTIMER0,            E_REG_CTIMER1,

    // Processor Control Registers
    E_REG_MEMPROTECT,
    E_REG_MESHCFG,
    E_REG_COREID,
    E_REG_CORE_RESET,
} e_core_reg_id_t;

// Chip Registers
typedef enum
{
    E_REG_IO_LINK_MODE_CFG,
    E_REG_IO_LINK_TX_CFG,
    E_REG_IO_LINK_RX_CFG,
    E_REG_IO_LINK_DEBUG,
    E_REG_IO_GPIO_CFG,
    E_REG_IO_FLAG_CFG,
    E_REG_IO_SYNC_CFG,
    E_REG_IO_HALT_CFG,
    E_REG_IO_RESET,
} e_chip_reg_id_t;



13.2.2
e_reg_read()

Synopsis
#include "e-lib.h"
unsigned e_reg_read(e_core_reg_id_t reg_id);

Description
Reads value from one of the system registers within the caller core.

Return value
Return the current value read from one of the system registers as identified by reg_id.

13.2.3
e_reg_write()

Synopsis
#include "e-lib.h"
void e_reg_write(e_core_reg_id_t reg_id, unsigned val);

Description
Set the value of the system register identified by reg_id within the caller core, to val.

Return value
None.



13.3 Interrupt Service Functions

13.3.1
Overview

The Interrupt Service functions handle system interrupt control and generation.  It is possible to
generate interrupts in the local core or in a remote core.

Functions definition summary
void e_irq_attach(e_irq_type_t irq, sighandler_t handler);
void e_irq_global_mask(e_bool_t state);
void e_irq_mask(e_irq_type_t irq, e_bool_t state);
void e_irq_set(unsigned row, unsigned col, e_irq_type_t irq);
void e_irq_clear(unsigned row, unsigned col, e_irq_type_t irq);

Enumerated constants, macros and types
typedef void (*sighandler_t)(int);

typedef enum
{
    E_SYNC,
    E_SW_EXCEPTION,
    E_MEM_FAULT,
    E_TIMER0_INT,
    E_TIMER1_INT,
    E_MESSAGE_INT,
    E_DMA0_INT,
    E_DMA1_INT,
    E_USER_INT,
} e_irq_type_t



13.3.2
e_irq_attach()

Synopsis
#include "e-lib.h"
void e_irq_attach(e_irq_type_t irq, sighandler_t handler);

Description
This function attaches  (registers)  an interrupt handler function  (ISR),  given by handler,  to a
specific entry in the IVT (Interrupt Vector Table), specified by irq.

Using this function,  ISR for a specific event type can be assigned and replaced in run-time.  It
uses an indirect handler attachment,  which may impose a slight delay on the execution of the
handler in case of an event.

The ISR should be compiled using the interrupt function attribute in order to apply proper
entry and exit sequences, guaranteeing safe context switching.

Note that the sighandler_t ISR prototype contains an integer argument.  Generally,  this
argument is intended for passing the interrupt type (irq parameter) to the handler, enabling the
sharing of the same handler among several interrupt types,  and identifylng the specific
generating event during the ISR processing.  For example,  it allows sharing the handler for
DMA0 and DMA1, taking proper action depending on the specific generating DMA. However,
when attaching an ISR to the interrupt using the e_irq_attach() function, this parameter is
not populated upon interrupt invocation.  If this parameter is required,  use the signal()
mechanism instead.

Return value
None.

13.3.3
e_irq_global_mask()

Synopsis
#include "e-lib.h"
void e_irq_global_mask(e_bool_t state);

Description
Globally enable or disable interrupts on caller core. When state is E_TRUE, the GID bit of the
core's STATUS register is set and consequent interrupt events are masked.  When state is
E_FALSE,  the GID bit is cleared and consequent interrupt events are tested against the other
masking mechanisms and pending interrupts.

Return value
None.



13.3.4
e_irq_mask()

Synopsis
#include "e-lib.h"
void e_irq_mask(e_irq_type_t irq, e_bool_t state);

Description
Disable or enables a single interrupt event type, specified by irq, by setting its respective bit in
the core's IMASK register according to state.  If state is E_TRUE,  then consequent interrupt
events of type irq are masked. If state is E_FALSE, this interrupt type is not masked.

Return value
None.



13.3.5
e_irq_set()

Synopsis
#include "e-lib.h"
void e_irq_set(unsigned row, unsigned col, e_irq_type_t irq);

Description
Generate an interrupt event by setting its ILAT register bit specified by irq.  The event is
generated on the core with relative coordinates (row, col) in a core workgroup.

Return value
None.



13.3.6
e_irq_clear()

Synopsis
#include "e-lib.h"
void e_irq_clear(unsigned row, unsigned col, e_irq_type_t irq);

Description
Clears pending interrupt request by clearing its ILAT register bit specified by irq. The request is
cleared from the core with relative coordinates (row, col) in a core workgroup.

Return value
None.



13.4 Timer Functions

13.4.1
Overview

The Timer functions interface the system timers  (two per core)  and the read,  write and
manipulation of their operation.

Functions definition summary
unsigned e_ctimer_get(e_ctimer_id_t timerid);
unsigned e_ctimer_set(e_ctimer_id_t timerid, unsigned val);
unsigned e_ctimer_start(e_ctimer_id_t timerid,
    e_ctimer_config_t config);
unsigned e_ctimer_stop(e_ctimer_id_t timerid);
void e_wait(e_ctimer_id_t timerid, unsigned clicks);

Enumerated constants and macros
typedef enum
{
    E_CTIMER_0,
    E_CTIMER_1,
} e_ctimer_id_t;

typedef enum
{
    E_CTIMER_OFF,
    E_CTIMER_CLK,
    E_CTIMER_IDLE,
    E_CTIMER_IALU_INST,
    E_CTIMER_FPU_INST,
    E_CTIMER_DUAL_INST,
    E_CTIMER_E1_STALLS,
    E_CTIMER_RA_STALLS,
    E_CTIMER_EXT_FETCH_STALLS,
    E_CTIMER_EXT_LOAD_STALLS,
} e_ctimer_config_t;

#define E_CTIMER_MAX



13.4.2
e_ctimer_get()

Synopsis
#include "e-lib.h"
unsigned e_ctimer_get(e_ctimer_id_t timerid);

Description
Read value of the core's timer specified by timerid. Note that the core counters decrement on
events and stop counting at zero.

Return value
Returns the current value of timer timerid.



13.4.3
e_ctimer_set()

Synopsis
#include "e-lib.h"
unsigned e_ctimer_set(e_ctimer_id_t timerid, unsigned val);

Description
Sets value of the core's timer specified by timerid to val.  Note that the core counters
decrement on events and stop counting at zero. Use E_CTIMER_MAX to set val to the maximum
allowed value.


and the initial value of the ctimer count register to val. Note that the core counters decrement on
events and stop counting at zero.

Return value  
Returns the new value of timer timerid.



13.4.4
e_ctimer_start()

Synopsis
#include "e-lib.h"
unsigned e_ctimer_start(e_ctimer_id_t timerid,
    e_ctimer_config_t config);

Description
Causes the ctimer specified by timerid to begin counting down upon events.  The type of
events to be counted is specified by config.  The function sets the ctimer configuration field
CTIMERxCFG in the core's CONFIG register to config.

Return value
Returns the current value of timer timerid.



13.4.5
e_ctimer_stop()

Synopsis
#include "e-lib.h"
unsigned e_ctimer_stop(unsigned timerid);

Description  
Causes the ctimer specified with timerid to stop counting down by setting the ctimer
configuration field CTIMERxCFG in the core's CONFIG register to E_CTIMER_OFF.

Return value
Returns the current value of the stopped timer.





13.4.6
e_wait()

Synopsis
#include "e-lib.h"
void e_wait(e_ctimer_id_t timerid, unsigned clicks);

Description  
Pauses the execution of the program for the number of clock cycles specified by clicks.

This function utilizes ctimer timerid for counting the clocks.  Consequently,  it will override
whatever counting process is currently being performed by ctimer timerid. Make sure to store
the old value before calling e_wait() if required later.

Note that as this function counts clock cycles, the actual time (wall-clock) depends on the clock
rate of the Epiphany chip.

Return value
None.


13.5 DMA and Data Movement Functions

13.5.1
Overview

The DMA functions control the two DMA channels included in each core.  Functionality is
provided for querying status, configuring and copying memory using the DMA engine.

Functions definition summary
void *e_read(void *remote, void *dst, unsigned row, unsigned col,
    const void *src, size_t bytes);
void *e_write(void *remote, const void *src, unsigned row,
    unsigned col, void *dst, size_t bytes);
int e_dma_copy(void *dst, void *src, size_t bytes);
int e_dma_start(e_dma_desc_t *descriptor, e_dma_id_t chan);
int e_dma_busy(e_dma_id_t chan);
void e_dma_wait(e_dma_id_t chan);
void e_dma_set_desc(e_dma_id_t chan,
    unsigned config, e_dma_desc_t *next_desc,
    unsigned stride_i_src, unsigned stride_i_dst,
    unsigned count_i, unsigned count_o,
    unsigned stride_o_src, unsigned stride_o_dst,
    void *addr_src, void *addr_dst, e_dma_desc_t *descriptor);

Enumerated constants, macros and types
typedef enum
{
    E_DMA_0,
    E_DMA_1
} e_dma_id_t;

typedef struct
{
    unsigned config;
    unsigned inner_stride;
    unsigned count;
    unsigned outer_stride;
    void    *src_addr;
    void    *dst_addr;
} e_dma_desc_t;

typedef enum
{
    E_DMA_ENABLE,

    E_DMA_MASTER,
    E_DMA_CHAIN,
    E_DMA_STARTUP,
    E_DMA_IRQEN,
    E_DMA_BYTE,
    E_DMA_HWORD,
    E_DMA_WORD,
    E_DMA_DWORD,
    E_DMA_MSGMODE,
    E_DMA_SHIFT_SRC_IN,
    E_DMA_SHIFT_DST_IN,
    E_DMA_SHIFT_SRC_OUT,
    E_DMA_SHIFT_DST_OUT,
} e_dma_config_t;



13.5.2
e_read()

Synopsis
#include "e-lib.h"
void *e_read(void *remote, void *dst, unsigned row, unsigned col,
    const void *src, size_t bytes);

Description
Copy bytes bytes of data from a remote source src to a local destination dst.  The remote
source can be either a core on the caller core's workgroup, or an External Memory buffer. The
remote parameter must be either e_group_config or e_emem_config, specifying the nature
if the source.

If the remote parameter is e_group_config,  then the source core is specified by its
(row, col)  coordinates in the caller core's workgroup.  If the src address is a global address,
then it is used unmodified.

If the remote parameter is e_emem_config,  then the source address is given relative to the
External Memory base address. In this case, the row and col parameters are ignored.

Return value
None.



13.5.3
e_write()

Synopsis
#include "e-lib.h"
void *e_write(void *remote, const void *src, unsigned row,
    unsigned col, void *dst, size_t bytes);

Description
Copy bytes bytes of data from a local source src to a remote destination dst.  The remote
destination can be either a core on the caller core's workgroup, or an External Memory buffer.
The remote parameter must be either e_group_config or e_emem_config,  specifying the
nature if the destination.

If the remote parameter is e_group_config,  then the destination core is specified by its
(row, col)  coordinates in the caller core's workgroup.  If the dst address is a global address,
then it is used unmodified.

If the remote parameter is e_emem_config, then the destination address is given relative to the
External Memory base address. In this case, the row and col parameters are ignored.

Return value
None.



13.5.4
e_dma_copy()

Synopsis
#include "e-lib.h"
int e_dma_copy(void *dst, void *src, size_t bytes);

Description
Copy bytes bytes of data from src to dst using the DMA engine DMA1. If the DMA channel is
busy when calling this function, it waits until the previous transfer is concluded. After initiating
the DMA transfer process it waits until the transfer is finished (blocking DMA).

This is generally a faster alternative to the standard memcpy() function. However, utilizing the
DMA, it has some limitations that the standard function does not impose, like some restrictions
on the source and destination addresses.  Please consult the Epiphany Architecture Reference
Manual for more details.

Return value
Returns 0 if successful.



13.5.5
e_dma_start()

Synopsis
#include "e-lib.h"
int e_dma_start(e_dma_desc_t *descriptor, e_dma_id_t chan);

Description  
Start a DMA on channel chan as described by the descriptor descriptor.  Use the
e_dma_desc_t constants to populate the descriptor descriptor fields.

Return value
Returns 0 if successful.



13.5.6
e_dma_busy()

Synopsis
#include "e-lib.h"
int e_dma_busy(e_dma_id_t chan);

Description
Queries the status of the state machine of dma channel chan.

Return value
Return 0 if the DMA channel identified by chan is idle, otherwise return DMA channel status.



13.5.7
e_dma_wait()

Synopsis
#include "e-lib.h"
void e_dma_wait(e_dma_id_t chan);

Description
Halts the execution of the program and waits as long as DMA channel chan is busy.

Return value
None.



13.5.8
e_dma_set_desc()

Synopsis
#include "e-lib.h"
void e_dma_set_desc(e_dma_id_t chan,
    unsigned config, e_dma_desc_t *next_desc,
    unsigned stride_i_src, unsigned stride_i_dst,
    unsigned count_i, unsigned count_o,
    unsigned stride_o_src, unsigned stride_o_dst,
    void *addr_src, void *addr_dst, e_dma_desc_t *descriptor);

Description
Sets the DMA descriptor descriptor of DMA channel chan with the various members:
config
-  16-bit configuration field.  This field is comprised of the Logical OR of the
e_dma_config_t constants.
next_desc
-  16-bit address of DMA descriptor, loaded when current transfer ends,  when
E_DMA_CHAIN mode was set.
stride_i_src  -  16-bit stride of the inner loop of the source address generator.
stride_i_dst  -  16-bit stride of the inner loop of the destination address generator.
count_i
-  16-bit count of the inner loop transactions. This value must be positive.
count_o
-  16-bit count of the outer loop transactions. This value must be positive.
stride_o_src  -  16-bit stride of the outer loop of the source address generator.
stride_o_dst  -  16-bit stride of the outer loop of the destination address generator.
addr_src
-  32-bit start address of source data.
addr_dst
-  32-bit start address of destination data.

Use this function to make sure that the DMA channel is idle when programming the descriptor.

Return value
None.



13.6 Mutex and Barrier Functions

13.6.1
Overview

A mutex is an object which allows locking of a shared resource, enabling exclusive access to just
one agent.  When an access to the shared resource is required,  first the associated mutex is
checked.  If the mutex is cleared,  then resource is free.  The mutex is then set and access is
granted to the querying agent.

A barrier is a means for synchronizing parallel executing threads.  When a program reaches a
barrier, it will wait until all other threads reached the barrier as well. Only then will the program
(and all the other programs) continue their execution.

Functions definition summary
void e_mutex_init(unsigned row, unsigned col, e_mutex_t *mutex,
    e_mutexattr_t *attr);
void e_mutex_lock(unsigned row, unsigned col, e_mutex_t *mutex);
unsigned e_mutex_trylock(unsigned row, unsigned col,
    e_mutex_t *mutex);
void e_mutex_unlock(unsigned row, unsigned col, e_mutex_t *mutex);
void e_barrier_init(volatile e_barrier_t bar_array[],
    e_barrier_t *tgt_bar_array[]);
void e_barrier(volatile e_barrier_t *bar_array,
    e_barrier_t *tgt_bar_array[]);


Enumerated constants, macros and types
typedef int e_mutex_t;
typedef int e_mutexattr_t;
typedef char e_barrier_t;


13.6.2
e_mutex_init()

Synopsis
#include "e-lib.h"
void e_mutex_init(unsigned row, unsigned col, e_mutex_t *mutex,
    e_mutexattr_t *attr);

Description
This function initializes the mutex referenced by mutex, on the core at coordinates (row,  col)
in the caller core's workgroup.  Upon successful initialization,  the state of the mutex becomes
initialized and unlocked.

The initialization attribute,  specified by attr,  is reserved for future use.  When calling the
function, use NULL for attr.

Return value
Returns 0 upon successful initialization; otherwise, a nonzero error value is returned.



13.6.3
e_mutex_lock()

Synopsis
#include "e-lib.h"
void e_mutex_lock(unsigned row, unsigned col, e_mutex_t *mutex);

Description
This function tries to lock the mutex object referenced by mutex,  on the core at coordinates
(row,  col) in the caller core's workgroup. If the mutex is already locked, the calling thread will
be blocked until the mutex becomes available.

Return value
If successful, the function returns 0; otherwise, a nonzero error value is returned.



13.6.4
e_mutex_trylock()

Synopsis
#include "e-lib.h"
unsigned e_mutex_trylock(unsigned row, unsigned col,
    e_mutex_t *mutex);

Description
This function tries to lock the mutex object referenced by mutex,  on the core at coordinates
(row,  col) in the caller core's workgroup.  If the mutex is already locked, the function returns
with a failure code.

Return value
If successful, the function returns 0; otherwise, nonzero value is returned, which is the Core ID
of the agent that holds the associated resource.



13.6.5
e_mutex_unlock()

Synopsis
#include "e-lib.h"
void e_mutex_unlock(unsigned row, unsigned col, e_mutex_t *mutex);

Description
This function unlocks the mutex object referenced by mutex,  on the core at coordinates
(row, col) in the caller core's workgroup.

Return value
If successful, the function returns 0; otherwise, a nonzero error value is returned.



13.6.6
e_barrier_init()

Synopsis
#include "e-lib.h"
void e_barrier_init(volatile e_barrier_t bar_array[],
    e_barrier_t *tgt_bar_array[]);

Description
Initialize a workgroup barrier. The bar_array and tgt_bar_array parameters are defined as
arrays of size equal to the number of cores in the workgroup. The barrier is mutual to all cores in
the workgroup, so care must be taken w

Return value
None.




13.6.7
e_barrier()

Synopsis
#include "e-lib.h"
void e_barrier(volatile e_barrier_t *bar_array,
    e_barrier_t *tgt_bar_array[]);

Description
Set a workgroup barrier point  (a sync point)  across the workgroup cores.  When the program
reaches the barrier point, it will halt and wait until all cores in the workgroup reached that point
as well.

The bar_array and tgt_bar_array parameters are defined as arrays of size equal to the
number of cores in the workgroup, and must be initialized by e_barrier_init().

The barrier is mutual to all cores in the workgroup,  so care must be taken when placing the
e_barrier() call, to prevent deadlock conditions.

Return value
None.



13.7 Core ID and Workgroup Functions

13.7.1
Overview

The Core ID is a number which identifies a core in the system. Each core is associated with a
unique number that is related to the core's coordinates in the global mesh.  The ID is a 12-bit
number where the 6 high order bits are the core row coordinate and the 6 low order bits are the
core column coordinates. This number also indicates the core's 1MB slice in the global memory
space, where it comprises the most significant bits of the core's globally addressable space.

Functions definition summary
e_coreid_t e_get_coreid(void);
void *e_get_global_address(unsigned row, unsigned col,
    const void *ptr);
e_coreid_t e_coreid_from_coords(unsigned row, unsigned col);
void e_coords_from_coreid(e_coreid_t coreid, unsigned *row,
    unsigned *col);
e_bool_t e_is_on_core(const void *ptr);
void e_neighbor_id(e_coreid_wrap_t dir, e_coreid_wrap_t wrap,
    unsigned *row, unsigned *col);

Enumerated constants and macros
typedef unsigned int e_coreid_t;

#define E_SELF

typedef enum
{
    // neighboring cores wrap topology
    E_GROUP_WRAP, // all workgroup cores form a ring
    E_ROW_WRAP,   // core rows form rings
    E_COL_WRAP,   // core columns form rings
    // neighboring cores direction
    E_NEXT_CORE,  // neighbor core with the next coreID
    E_PREV_CORE,  // neighbor core with the prev coreID
} e_coreid_wrap_t





typedef enum {
    E_E16G301,
    E_E64G401,
} e_chiptype_t;

typedef struct {
    e_chiptype_t chiptype;
    e_coreid_t group_id;
    unsigned group_row;
    unsigned group_col;
    unsigned group_rows;
    unsigned group_cols;
    unsigned core_row;
    unsigned core_col;
    unsigned alignment_padding;
} e_group_config_t;

typedef struct {
    unsigned base;
} e_emem_config_t;




13.7.2
e_get_coreid()


Synopsis
#include "e-lib.h"
e_coreid_t e_get_coreid(void);

Description
Reads coreid from the hardware register.

Return value
Returns a 12-bit coreid value, aligned to lsb of the result.



13.7.3
e_get_global_address ()

Synopsis
#include "e-lib.h"
void *e_get_global_address(unsigned row, unsigned col,
    const void *ptr);

Description
Transforms a local pointer ptr into the matching address on a neighbor core,  referred to by
coordinates (row,  col), in the caller core's workgroup.

Note that for ptr values that point to a global address not local to coreid, the function returns
an unmodified version of ptr.

If either row or col are E_SELF, or they are equal to the caller core's own coordinates, then the
function calculates the global version of the local address.  That is,  the returned address is the
same address as would be referenced from outside of the core.

If ptr points to a global address  (that is,  its 12-bit msb's are nonzero),  then it is returned
unmodified.

Return value
Returns a 32-bit absolute global address.



13.7.4
e_coreid_from_coords()

Synopsis
#include "e-lib.h"
e_coreid_t e_coreid_from_coords(unsigned row, unsigned col);

Description
Returns the coreid value of the neighbor core,  referred to by coordinates  (row,   col),  in the
caller core's workgroup.

Return value
Returns 12-bit wide coreid value.



13.7.5
e_coords_from_coreid()

Synopsis
#include "e-lib.h"
void e_coords_from_coreid(e_coreid_t coreid, unsigned *row,
    unsigned *col);

Description
Calculate the row and column coordinates (row,  col) of the core specified by coreid, in the
caller's workgroup.

Note that no check is made for a coreid value outside of the workgroup.  In such case,  the
return coordinates may be either bigger than the workgroup's size or negative.

Return value
None.



13.7.6
e_is_oncore()

Synopsis
#include "e-lib.h"
e_bool_t e_is_on_core(const void *ptr);

Description
This function checks whether an address  (either global or local) is within the memory space of
the caller core.

Return value
The function returns E_FALSE if the address is not in the caller's space.  Otherwise,  it returns
E_TRUE.



13.7.7
e_neighbor_id()

Synopsis
#include "e-lib.h"
void e_neighbor_id(e_coreid_wrap_t dir, e_coreid_wrap_t wrap,
    unsigned *row, unsigned *col);

Description
This function calculates the  (row,   col)  coordinates of the neighboring core,  according to a
specified topology.

Cores can be logically chained in one linear string across the whole chip, from north-west core to
south-east core in a raster scan fashion. The cores can also be chained in a row-wise fashion or
column-wise fashion, such that rows or columns create parallel rings.

The dir argument  (one of E_NEXT_CORE,  E_PREV_CORE)  specifies whether the next or
previous cores in the chain are required.  The function will always calculate the coordinates of
another core on the same group,  wrapping on a row,  column,  or workgroup boundary as
specified by the wrap argument (one of E_ROW_WRAP, E_COL_WRAP, E_GROUP_WRAP). The
calculated coordinates are returned in the row and col parameters.

This function is limited to workgroup dimensions  (rows and columns)  which are powers of 2,
i.e., 2, 4, 8, etc.

Return value
None.



14.
Epiphany Host Library (eHAL)
14.1 Overview

The Epiphany Hardware Abstraction Layer  (eHAL)  library provides functionality for
communicating with the Epiphany chip when the application runs on a host. The host can be a
PC or an embedded processor.  The communication is performed using memory writes to and
reads from shared buffers that the applications on both sides should define. The library interface
is defined in the e-hal.h header file.

In order to use this library in your application, the compiler and linker must be configured with
the paths to the header file and the library binary.  In your tools options use the following
configurations:

$ gcc -I${EPIPHANY_HOME}/tools/host/include \
      -L${EPIPHANY_HOME}/tools/host/lib -le-hal ...

Basic mode of operation
As described in an earlier chapter, the standard mode of operation of the eHAL API is working
in eCore workgroups. A workgroup is a rectangular mesh of eCore nodes that are allocated for
performing a computational task.  It is possible to load the group with identical copies of the
same program (SPMD style), or load subgroups, or even single cores with different programs. It
is the user's responsibility to make sure that tasks are not allocated to a previously allocated
group cores.

External (shared) memory architecture
The host application can communicate with the Epiphany device by either accessing the eCore's
private memory space, or by using shared buffers in the device external memory.

In a platform which implements such shared memory (for example, a bulk of DRAM accessible
by the host via system bus or other connection, and by the Epiphany via the eLinks), there may
be a different mapping of the physical address space of this memory, as seen from the host side
and from the Epiphany side. For example, the Parallella platform is configured by default with
32MB of DRAM used as device memory.  The physical address of this memory segment is

0x1e000000-0x1fffffff.  However,  to overcome some system limitations,  this range is
aliased to address 0x8e000000-0x8fffffff,  as seen from the Epiphany side.  For example,
when a buffer of 8KB is allocated at offset 64KB on that segment,  the host sees this buffer as
occupying addresses 0x1e010000-0x1e012000.  For accessing the buffer from the Epiphany
program, this range is aliased to 0x8e010000-0x8e012000.

The base addresses of the external shared memory space (the real and the aliased) are defined in
the Hardware Description File (HDF) so the eHAL is aware of the difference. The aliased base
address is also defined in the Epiphany program's Linker Description File (LDF).

Enumerated constants and macros
typedef enum {
    E_FALSE,
    E_TRUE,
} e_bool_t;

typedef enum {
    E_OK,
    E_ERR,
    E_WARN,
} e_return_stat_t;

The following symbols are defined and can be used as addresses to access eCore and Epiphany
system registers using the e_read() and e_write() API's:

// General Purpose Registers
// (see Epiphany Architecture Manual for details)
typedef enum
{
    E_REG_R0,    E_REG_R8,    E_REG_R16,    E_REG_R24,
    E_REG_R1,    E_REG_R9,    E_REG_R17,    E_REG_R25,
    E_REG_R2,    E_REG_R10,   E_REG_R18,    E_REG_R26,
    E_REG_R3,    E_REG_R11,   E_REG_R19,    E_REG_R27,
    E_REG_R4,    E_REG_R12,   E_REG_R20,    E_REG_R28,
    E_REG_R5,    E_REG_R13,   E_REG_R21,    E_REG_R29,
    E_REG_R6,    E_REG_R14,   E_REG_R22,    E_REG_R30,
    E_REG_R7,    E_REG_R15,   E_REG_R23,    E_REG_R31,

    E_REG_R32,   E_REG_R40,   E_REG_R48,    E_REG_R56,
    E_REG_R33,   E_REG_R41,   E_REG_R49,    E_REG_R57,
    E_REG_R34,   E_REG_R42,   E_REG_R50,    E_REG_R58,
    E_REG_R35,   E_REG_R43,   E_REG_R51,    E_REG_R59,

    E_REG_R36,   E_REG_R44,   E_REG_R52,    E_REG_R60,
    E_REG_R37,   E_REG_R45,   E_REG_R53,    E_REG_R61,
    E_REG_R38,   E_REG_R46,   E_REG_R54,    E_REG_R62,
    E_REG_R39,   E_REG_R47,   E_REG_R55,    E_REG_R63,
} e_gp_reg_id_t;

// eCore Special Registers
typedef enum
{
    // Control Registers
    E_REG_CONFIG,             E_REG_IRET,
    E_REG_STATUS,             E_REG_IMASK,
    E_REG_FSTATUS,            E_REG_ILAT,
    E_REG_PC,                 E_REG_ILATST,
    E_REG_DEBUGSTATUS,        E_REG_ILATCL,
    E_REG_DEBUGCMD,           E_REG_IPEND,
    E_REG_LC,
    E_REG_LS,
    E_REG_LE,

    // DMA registers
    E_REG_DMA0CONFIG,         E_REG_DMA1CONFIG,
    E_REG_DMA0STRIDE,         E_REG_DMA1STRIDE,
    E_REG_DMA0COUNT,          E_REG_DMA1COUNT,
    E_REG_DMA0SRCADDR,        E_REG_DMA1SRCADDR,
    E_REG_DMA0DSTADDR,        E_REG_DMA1DSTADDR,
    E_REG_DMA0AUTODMA0,       E_REG_DMA1AUTODMA0,
    E_REG_DMA0AUTODMA1,       E_REG_DMA1AUTODMA1,
    E_REG_DMA0STATUS,         E_REG_DMA1STATUS,

    // Event Timer Registers
    E_REG_CTIMER0,            E_REG_CTIMER1,

    // Processor Control Registers
    E_REG_MEMPROTECT,
    E_REG_MESH_CONFIG,
    E_REG_COREID,
    E_REG_CORE_RESET,
} e_core_reg_id_t;

// Chip Registers
// (see Epiphany Chip Datasheets for details)
typedef enum
{
    E_REG_IO_LINK_MODE_CFG,
    E_REG_IO_LINK_TX_CFG,
    E_REG_IO_LINK_RX_CFG,
    E_REG_IO_LINK_DEBUG,
    E_REG_IO_GPIO_CFG,
    E_REG_IO_FLAG_CFG,
    E_REG_IO_SYNC_CFG,
    E_REG_IO_HALT_CFG,

    E_REG_IO_RESET,
} e_chip_reg_id_t;

// Epiphany system registers
// (see Board manual for details)
typedef enum
{
    E_SYS_CONFIG,
    E_SYS_RESET,
    E_SYS_VERSION,
    E_SYS_FILTERL,
    E_SYS_FILTERH,
    E_SYS_FILTERC,
} e_sys_reg_id_t



14.2 Platform Configuration Functions

14.2.1
Overview

These functions are used to initialize and prepare the Epiphany system for working with the Host
application. It also enables the query and retrieval of platform information.

Functions definition summary
int e_init(char *hdf);
int e_get_platform_info(e_platform_t *platform);
int e_finalize();


14.2.2
e_init()

Synopsis
#include "e-hal.h"
int e_init(char *hdf);

Description
This function initializes the HAL data structures, and establishes a connection to the Epiphany
platform.  The platform parameters are read form a Hardware Description File  (HDF),  whose
path is given at the function argument.

If the hdf parameter is a NULL pointer, then the file location is read from the EPIPHANY_HDF
environment variable. This variable is normally set on your system startup file (~/.bashrc in
Linux), and reflects the structure of the underlying Epiphany platform. For example:

EPIPHANY_HDF="${EPIPHANY_HOME}/bsps/parallella/parallella.xml"

If the EPIPHANY_HDF variable is not set, then the function will try to locate the platform.hdf
file located in the current BSP directory.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.

Note:  At the time of the release,  the XML parser was not yet fully integrated into the driver.
Instead of an XML description file,  the library now uses a simplified  (flat)  text file listing the
platform components. Please use the provided files or create your own accordingly:

EPIPHANY_HDF="${EPIPHANY_HOME}/bsps/parallella/parallella.hdf"

14.2.3
e_get_platform_info()

Synopsis
#include "e-hal.h"
int e_get_platform_info(e_platform_t *platform);

Description
The Epiphany platform information is stored internally in an e_platform_t type object.  It
contains the data on the various chips, external memory segments and geometry comprising the
system. Some of this data can be retrieved through this function.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.

Note: The data that is currently made available through this function is:
char *version       - platform version string
unsigned row, col   - coordinates of effective chip area
unsigned rows, cols - size of effective chip area
int num_chips       - number of Epiphany chips in platform
int num_emems       - number of external memory segments

If necessary for the application, the internal object can be accessed using this declaration:
extern e_platform_t e_platform;
However,  this practice should be normally avoided,  and if used,  absolutely no modification of
the data is allowed,  or the integrity of the driver system may be broken.  Additionally,  because
the variable is currently exposed (the extern keyword is not really necessary), there should be
no user-defined object of this name in the application!

14.2.4
e_finalize()

Synopsis
#include "e-hal.h"
int e_finalize();

Description
Use this function to finalize the connection with the Epiphany system. Some resources that were
allocated in the e_init() call are released here.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.


14.3 Workgroup and External Memory Allocation Functions

14.3.1
Overview

These functions are used to assign and allocate the eCore workgroups and external memory
buffers resources.

Functions definition summary
int e_open(e_epiphany_t *dev, unsigned row, unsigned col,
    unsigned rows, unsigned cols);
int e_close(e_epiphany_t *dev);
int e_alloc(e_mem_t *mbuf, off_t base, size_t size);
int e_free(e_mem_t *mbuf);


14.3.2
e_open()

Synopsis
#include "e-hal.h"
int e_open(e_epiphany_t *dev, unsigned row, unsigned col,
    unsigned rows, unsigned cols);

Description
This function defines an eCore workgroup. The workgroup is defined in terms of the coordintaes
relative to the platform's effective chip area. The arguments row and col define the place of the
group's origin eCore. The origin is set relative to the Epiphany platform's origin, defined in the
e_init()  call.  The arguments rows and cols give the group's size,  defining the work
rectangle.  A work group can be as amall as a single core or as large as the whole available
effective chip area.  The core group data is saved in the provided e_epiphany_t type object
dev.

Subsequent accesses to the core group  (e.g.,  for read and write of data)  are done using a
reference to the dev object.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.

14.3.3
e_close()

Synopsis
#include "e-hal.h"
int e_close(e_epiphany_t *dev);

Description
The function closes the eCore workgroup.  The resources allocated by the e_open()  call are
released here. Use this function before re-allocating an eCore to a new workgroup.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.

14.3.4
e_alloc()

Synopsis
#include "e-hal.h"
int e_alloc(e_mem_t *mbuf, off_t base, size_t size);

Description
This function defines a buffer in external memory. The buffer is defined in terms of the relative
from the beginning of the external memory segment,  defined in the e_init()  call.  The
argument base defines the offset, starting at 0. The argument and size gives the buffer's size.
The external memory buffer data is saved in the provided e_mem_t type object mbuf.

Subsequent accesses to the buffer (e.g., for read and write of data) are done using a reference to
the mbuf object.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.

14.3.5
e_free()

Synopsis
#include "e-hal.h"
int e_free(e_mem_t *mbuf);

Description
The resources allocated by the e_alloc()  call are released here.  Use this function before re-
allocating an external memory space to a new buffer.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.


14.4 Data Transfer Functions

14.4.1
Overview

These functions are used to read and write data from and to Epiphany eCore workgroups and
external memory buffers.

Functions definition summary
ssize_t e_read(void *dev, unsigned row, unsigned col,
    off_t from_addr, void *buf, size_t size);
ssize_t e_write(void *dev, unsigned row, unsigned col,
    off_t to_addr, const void *buf, size_t size);


14.4.2
e_read()

Synopsis
#include "e-hal.h"
ssize_t e_read(void *dev, unsigned row, unsigned col,
    off_t from_addr, void *buf, size_t size);

Description
This function reads data of length size from a workgroup core or an external memory buffer to
the local byte buffer buf. The argument dev specifies the target from which to read the data. It
can be of either types e_epiphany_t or e_mem_t.

If an object of type e_epiphany_t is given,  then the row and col arguments specify the
relative target eCore coordinates in the workgroup.

If an object of type e_mem_t is given, then the row and col arguments are ignored.

In both cases, the from_addr parameter specifies the write offset relative to the buffer's start, or
to the eCore's internal space.

To access system registers,  the to_addr parameter can be one of the register symbols of the
types e_gp_reg_id_t, e_core_reg_id_t, e_chip_reg_id_t, e_sys_reg_id_t.

Return value
If successful, the function returns the number of bytes read. On a failure it returns E_ERR.




14.4.3
e_write()

Synopsis
#include "e-hal.h"
ssize_t e_write(void *dev, unsigned row, unsigned col,
    off_t to_addr, const void *buf, size_t size);

Description
This function writes data of length size from the local byte buffer buf to a workgroup core or
an external memory buffer. The argument dev specifies the target on which to write the data. It
can be of either types e_epiphany_t or e_mem_t.

If an object of type e_epiphany_t is given,  then the row and col arguments specify the
relative target eCore coordinates in the workgroup.

If an object of type e_mem_t is given, then the row and col arguments are ignored.

In both cases, the to_addr parameter specifies the write offset relative to the buffer's start, or to
the eCore's internal space.

To access system registers,  the to_addr parameter can be one of the register symbols of the
types e_gp_reg_id_t, e_core_reg_id_t, e_chip_reg_id_t, e_sys_reg_id_t.

Return value
If successful, the function returns the number of bytes written. On a failure it returns E_ERR.




14.5 System Control Functions

14.5.1
Overview

These functions provide some means to control different aspects of the system and a program
execution.

Functions definition summary
int e_reset_system();
int e_reset_group(e_epiphany_t *dev);
int e_start(e_epiphany_t *dev, unsigned row, unsigned col);
int e_start_group(e_epiphany_t *dev);
int e_signal(e_epiphany_t *dev, unsigned row, unsigned col);
int e_halt(e_epiphany_t *dev, unsigned row, unsigned col);
int e_resume(e_epiphany_t *dev, unsigned row, unsigned col);


14.5.2
e_reset_system()

Synopsis
#include "e-hal.h"
int e_reset_system();

Description
Use this function to perform a full hardware reset of the Epiphany platform,  including the
Epiphany chips and the FPGA glue logic.

Special care must be taken when using this function in a multiprocessing environment not to
disrupt working tasks, possibly launched by other applications.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.


14.5.3
e_reset_group()

Synopsis
#include "e-hal.h"
int e_reset_group(e_epiphany_t *dev);

Description
Use this function to perform a soft reset of a workgroup.

Special care must be taken when using this function,  as resetting the eCore when memory
transactions,  that were generated with a core read instruction from the global memory space
(either LDR instruction or an instruction fetch from outside of the core)  are not concluded can
bring the system to an undefined state.

Return value
If successful, the function returns E_OK.


14.5.4
e_start()

Synopsis
#include "e-hal.h"
int e_start(e_epiphany_t *dev, unsigned row, unsigned col);

Description
This function writes the SYNC signal to the workgroup core's ILAT register. It causes the core to
jump to the IVT entry #0. Normally, this will be used after loading a program on the core.

The row and col parameters specify the target eCore coordinates,  relative to the workgroup
given by the dev argument.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.


14.5.5
e_start_group()

Synopsis
#include "e-hal.h"
int e_start_group(e_epiphany_t *dev);

Description
This function writes the SYNC signal to the workgroup cores'  ILAT registers.  It causes the
workgroup cores to jump to their IVT entry  #0.  Normally,  this will be used after loading a
program on the core.


Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.


14.5.6
e_signal()

Synopsis
#include "e-hal.h"
int e_signal(e_epiphany_t *dev, unsigned row, unsigned col);

Description
This function writes the USER_INT (soft interrupt) signal to the workgroup core's ILAT register.
It causes the core to jump to the IVT entry #9.

The row and col parameters specify the target eCore coordinates,  relative to the workgroup
given by the dev argument.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.


14.5.7
e_halt()

Synopsis
#include "e-hal.h"
int e_halt(e_epiphany_t *dev, unsigned row, unsigned col);

Description
This function halts the workgroup core's program execution.  It may be useful for debug
purposes.

The row and col parameters specify the target eCore coordinates,  relative to the workgroup
specified by the dev argument.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.



14.5.8
e_resume()

Synopsis
#include "e-hal.h"
int e_resume(e_epiphany_t *dev, unsigned row, unsigned col);

Description
This function resumes a workgroup core's program execution that was previously stopped with a
call to e_halt().

The row and col parameters specify the target eCore coordinates,  relative to the workgroup
specified by the dev argument.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.



14.6 Program Load Functions

14.6.1
Overview

These loader functions load an Epiphany program on an eCore or an eCore workgroup in a
SPMD manner.  Optionally,  the loaded programs can be started immediately after loading the
group.

Functions definition summary
int e_load(char *executable, e_epiphany_t *dev, unsigned row,
    unsigned col, e_bool_t start);
int e_load_group(char *executable, e_epiphany_t *dev, unsigned row,
    unsigned col, unsigned rows, unsigned cols, e_bool_t start);


14.6.2
e_load()

Synopsis
#include "e-hal.h"
int e_load(char *executable, e_epiphany_t *dev, unsigned row,
    unsigned col, e_bool_t start);

Description
This function loads an Epiphany program onto a workgroup core.  The executable string
specifies the path to the program's image.  The target core workgroup is specified by the dev
argument.  The target core is specified by the row and col coordinates,  relative to the
workgroup.

Optionally, a loaded program can be started immediately after loading, according to the start
parameter.  When the start parameter is e_true,  the program is launched after load.  If it is
e_false, the program is not launched.

Program load should be performed only when the core is in an idle or halt state. A safe way to
achieve this is to use the e_reset_system() or e_reset_core() API's before the load.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR.

Note: Currently, the eHAL supports loading executable images in the form of SREC file format.
Use the e-objcopy utility to generate an SREC image from the binary ELF executable,  as
described in chapters 6 and 9 of this book.


14.6.3
e_load_group()

Synopsis
#include "e-hal.h"
int e_load_group(char *executable, e_epiphany_t *dev, unsigned row,
    unsigned col, unsigned rows, unsigned cols, e_bool_t start);

Description
This function loads an Epiphany program onto a subgroup of a workgroup.  The executable
string specifies the path to the program's image. The target workgroup is specified by the dev
argument.  The target cores subgroup for loading the image is specified by the row and col
coordinates, relative to the workgroup origin. The rows and cols parameters specify the size of
the subgroups. All cores in the subgroup are loaded with the same program image.

Optionally,  the loaded programs can be started immediately after loading on all cores in the
subgroup,  according to the start parameter.  When the start parameter is e_true,  the
programs are launched after load. If it is e_false, the programs are not launched.

Program load should be performed only when the core is in an idle or halt state. A safe way to
achieve this is to use the e_reset_system() or e_reset_core() API's before the load.

Return value
If successful, the function returns E_OK. On a failure it returns E_ERR. Some non-fatal erroneous
image content generates an E_WARN return value.  The SREC parser ignores the errors and
continues the program load.

Note: Currently, the eHAL supports loading executable images in the form of SREC file format.
Use the e-objcopy utility to generate an SREC image from the binary ELF executable,  as
described in chapters 6 and 9 of this book.


14.7 Utility Functions

14.7.1
Overview

These is a set of utility functions, provided for easing some Host application programming tasks.

Functions definition summary
unsigned e_get_num_from_coords(e_epiphany_t *dev, unsigned row,
    unsigned col);
void e_get_coords_from_num(e_epiphany_t *dev, unsigned corenum,
    unsigned *row, unsigned *col);
e_bool_t e_is_addr_on_chip(void *addr);
e_bool_t e_is_addr_on_group(e_epiphany_t *dev, void *addr);
e_hal_diag_t e_set_host_verbosity(e_hal_diag_t verbose);
e_loader_diag_t e_set_loader_verbosity(e_loader_diag_t verbose);


14.7.2
e_get_num_from_coords()

Synopsis
#include "e-hal.h"
unsigned e_get_num_from_coords(e_epiphany_t *dev, unsigned row,
    unsigned col);

Description
Convert a workgroup's eCore coordinates to a core number.  The workgroup is defined by the
dev argument.  The core numbering is done in a  "raster scan"  manner,  starting at the groups
origin as core #0 and continuing row-wise. Thus, the number of the first core in the second row
equals to the group's cols parameter, and the last core in the third row equals to (3,cols-1).
The last core in the group is numbered (rows,cols-1).

Return value
The function returns the selected core's number.


14.7.3
e_get_coords_from_num()

Synopsis
#include "e-hal.h"
void e_get_coords_from_num(e_epiphany_t *dev, unsigned corenum,
    unsigned *row, unsigned *col);

Description
Convert a workgroup's eCore number to core's coordinates,  relative to the group origin.  The
workgroup is defined by the dev argument. The core numbering is done in a raster scan manner,
starting at the groups origin as core  #0 and continuing column-wise.  Thus,  the  (row,  col)
coordinates of the core #0 are (0,0), core #cols coordinates are (1,0), and core #(3,cols-
1)  coordinates are  (2,cols-1).  The last core in the group,  numbered  (rows,cols-1),  has
coordinates (rows-1,cols-1).

Return value
The function returns the selected core's coordinates.


14.7.4
e_is_addr_on_chip()

Synopsis
#include "e-hal.h"
e_bool_t e_is_addr_on_chip(void *addr);

Description
This function checks whether a global,  32-bit address,  given by argument addr,  is within a
physical Epiphany chip's space.

Return value
The function returns e_true if an address is on a chip and e_false otherwise.




14.7.5
e_is_addr_on_group()

Synopsis
#include "e-hal.h"
e_bool_t e_is_addr_on_group(e_epiphany_t *dev, void *addr);

Description
This function checks whether a global, 32-bit address, given by argument addr, is within a core
workgroup's space. The workgroup is specified by the dev argument.

Return value
The function returns e_true if an address is on a workgroup and e_false otherwise.




14.7.6
e_set_host_verbosity()

Synopsis
#include "e-hal.h"
e_hal_diag_t e_set_host_verbosity(e_hal_diag_t verbose);

Description
This function sets the verbosity level of the eHAL function calls. The levels defined from H_D0
to H_D4.  Level H_D0 means no diagnostics are emitted,  and any higher level designates more
detailed diagnostics. This function is meant for diagnostics and debug purposes.

Return value
The function returns the old diagnostics level value.




14.7.7
e_set_loader_verbosity()

Synopsis
#include "e-hal.h"
e_loader_diag_t e_set_loader_verbosity(e_loader_diag_t verbose);

Description
This function sets the verbosity level of the program loader function calls,  on top of the other
eHAL calls diagnostics..  The levels defined from L_D0 to L_D4.  Level L_D0 means no
diagnostics are emitted, and any higher level designates more detailed diagnostics. This function
is meant for diagnostics and debug purposes.

Return value
The function returns the old diagnostics level value.




上記の情報は米国Adapteva社による「Epiphany SDK Reference」などを基にしたものです。出典元の著作物の権利は、米国Adapteva社など、その原著作権者に帰属します。