CORE CPU
From ICE Enterprises
The Core class in nxm.ice.lib provides the standard framework for developing a Java callable Core. The wrappers for each hardware implementation are auto-generated by the inner class definitions in the Java reference class.
The Foo.c code contains the Native-C CPU implementation of the Core. It is also conditionally compiled to be the interface to the GPU, VHS, and ICE implementations.
Example
Here is an example Native-CPU implementation of the noop function contained in the file Noop.c:
Note: This file is also conditionally compiled to be the wrapper for both the VHS and ICE implementations (via the CORE_IS_FPGA define).
/**
Implements NOOP functions
*/
/* Define Signatures */
#define CORE_NAME Noop
#define CORE_AREA nxm_ice_core
#define CORE_BUFS 2
/* CORE defines */
#include "CoreDefs.h"
/* CORE Plan handle */
typedef struct {
CORETBL pal;
int_4 dec;
int_4 boff;
} NoopPlan;
#include "CoreProtos.h"
/* CORE Code */
void* Noop_alloc (char *config) {
NoopPlan *plan = Noop_plan();
plan->dec = 1;
plan->boff = 0;
HW_open(config);
return (void*)plan;
}
int_4 Noop_setkey (NoopPlan *plan, char *key, void *data, int_4 len) {
int_4 *ldata = (int_4*)data;
if (keyMatch("L:DECIMATION")) { plan->dec = ldata[0]; HW_write(COREG_DEC,plan->dec-1); }
else return 0;
return len;
}
int_4 Noop_getkey (NoopPlan *plan, char *key, void *data, int_4 len) {
int_4 *ldata = (int_4*)data;
if (keyMatch("L:DECIMATION")) { ldata[0] = plan->dec; return 4; }
return 0;
}
int_4 Noop_init (NoopPlan *plan) {
#if CORE_IS_FPGA
int_4 sys = getFmts(FMTS) | CORE_DEC;
HW_write(COREG_SYS,sys);
HW_write(COREG_DEC,plan->dec-1);
HW_write(COREG_SYS,sys|CORE_ENA);
#endif
return 0;
}
int_4 Noop_work (NoopPlan *plan, void *buf1, int_4 n1, void *buf2, int_4 n2) {
int_4 n=0;
#if CORE_IS_FPGA
n = HW_proc (buf1,n1, buf2,n2);
#elif CORE_IS_CPU
int_4 bpe1 = getFormatBytes(FMTS,1);
int_4 bpe2 = getFormatBytes(FMTS,2);
int_4 boff = plan->boff;
int_4 bdec = plan->dec*bpe1;
for (n=0; boff<n1; boff+=bdec,n+=bpe2) memcpy (buf2+n, buf1+boff, bpe2);
plan->boff = boff%n1;
#endif
return n;
}
int_4 Noop_free (NoopPlan *plan) {
HW_close();
free(plan);
return 0;
}