January 18, 2007 by xman
Posted in
DMA:
Prototype: co_memory co_memory_create(const char *name, const char *loc, size_t size);
// "Name" is used by external application to identify this memory.
// Create 64 bytes memory from the heap. loc is architecture dependent.
co_memory_create("name", "heap0", 64);
Prototype: void co_memory_readblock(co_memory mem, unsigned int offset, void *buf, size_t buffersize);
Prototype: void co_memory_writeblock(co_memory mem, unsigned int offset, void *buf, size_t buffersize);
Prototype: void *co_memory_ptr(co_memory mem); // Return a C pointer to the buffer of the shared memory.
Fixed-Point Arithmetic:
Example of format specification - 1s8.23 => 1 sign bit, 8 bit integer, 23 bit fraction.
We can choose several modes: saturation, floor, ceil.
co_int16 a = (co_int16) FXCONST16(96,7); // a <- 96 in 1s8.7 format. c = FXADD16(a,b,8); // Add a and b in 1s7.8 format. c = FXMUL32(a,b,8); // Multiply a and b in 1s7.8 format. c = FXDIV16(a,b,10); // c <- a/b in 1s6.9 format.
Macros: FXADD8(), FXADD16(), FXADD32(), FXMUL8(), FXMUL16(), FXMUL32(), ...
Convert fixed-point to floating-point:
co_int32 a = 0x000000F4; // 15.2 in 1s11.4 format. float f = FX2REAL(a,4);
Note that converting to floating-point for use in software only, perhaps for debugging purpose, since hardware does not support floating-point, or too expensive to.
Stream:
Prototype: co_stream co_stream_create(const char *name, co_type type, int numelements);
// Create int32 stream with buffer size of 4.
co_stream_create("name", INT_TYPE(32), 4);
Prototype: co_error co_stream_open(co_stream stream, mode_t mode, co_type type);
// Open an int32 stream for read.
co_stream_open(stream, O_RDONLY, INT_TYPE(32));
// Open an int32 stream for write.
co_stream_open(stream, O_WRONLY, INT_TYPE(32));
Prototype: co_error co_stream_read(co_stream stream, void *buffer, size_t buffersize);
// co_stream_read(...) == co_err_none
Prototype: co_error co_stream_write(co_stream stream, const void *buffer, size_t buffersize);
Prototype: co_error co_stream_close(co_stream stream);
Process:
Prototype: co_process co_process_create(const char *name, co_function run, int argc, ...); // Changes attributes of a created process. Prototype: co_error co_process_config(co_process process, co_attribute attribute, const char *val);
System:
// Associate user's application with specific architecture defined in "configure". Prototype: co_architecture co_architecture_create(const char *name, const char *arch, co_function configure, void *arg); Prototype: void co_execute(co_architecture architecture); Prototype: co_architecture co_initialize(void *arg); // FPGA entry point in software. co_par_break() ????
Pragma:
#pragma CO pipeline // Set the max stage delay. This will affect the maximum clock frequency. #pragma CO SET StageDelay 200
Others:
- Array.
- Bit manipulation - Bit extract, bit insert.
- Signals - Wait, post.
- Registers - Read, write, put, get (put/get for single value).
- Semaphores - Wait, release.
- Memory - Readblock, writeblock, ptr, set.
- Port - Create.
- Error.
- Co sim log windows - Create, init, write (for using application monitor).
Misc:
Inside a process, it seems that only fixed size arrays are being used.
Reference: Impulse C Application Programming Interface
Post new comment