#ifndef __CPI_INCLUDED__ #define __CPI_INCLUDED__ /******* Data types *******/ typedef void * cpi_hand; /* Cohandle */ typedef const char * cpi_str; typedef int cpi_int; typedef long long cpi_int64; typedef unsigned long long cpi_addr; typedef unsigned int cpi_ram_addr; typedef unsigned short int cpi_tag; #ifndef __cplusplus typedef unsigned char bool; const bool true=1; const bool false=0; #endif #define INLINE __attribute__((always_inline)) inline typedef enum { cpi_fifo = 0, cpi_reg = 1 } cpi_channel_ty; #define IO_BASE 0x80000000 #define CPI_INVALID_TAG 0x8000 #define CPI_ATTR_SINGLE_CLUSTER 0 #define cpi_poll(tag, x) \ while(1) { \ cpi_tag __temp__ = x;\ if(__temp__ != CPI_INVALID_TAG) { tag = __temp__; break; }\ } #define cpi_wait(hand, tag) if(tag != CPI_INVALID_TAG) { while(!cpi_test(hand, tag)) {}; tag = CPI_INVALID_TAG; } #define cpi_write_ram(han, raddr, maddr, words) { \ cpi_tag _tag_tmp = CPI_INVALID_TAG; \ _tag_tmp = cpi_nb_write_ram(han, raddr, maddr, words, _tag_tmp); \ cpi_wait(han, _tag_tmp); \ } #define cpi_read_ram(han, raddr, maddr, words) { \ { cpi_tag _tag_tmp = CPI_INVALID_TAG; \ _tag_tmp = cpi_nb_read_ram(han, raddr, maddr, words, _tag_tmp); \ cpi_wait(han, _tag_tmp); }\ } /******* Thread control actions *******/ void cpi_register_thread(cpi_str thread_name, cpi_int instances); cpi_int cpi_instance(); cpi_int cpi_time(); /******* Accessor control actions *******/ cpi_hand cpi_get_ram(cpi_int/*object_id*/, .../*sub_ids*/); cpi_hand cpi_get_rams(cpi_int/*num_rams*/, bool/*scatter/gather*/, cpi_int/*object_id*/, .../*subids*/); cpi_hand cpi_get_channel(cpi_channel_ty/*channel type*/, cpi_int/*object_id*/, .../*subids*/); /******* Channel control actions *******/ cpi_int64 cpi_read_channel(cpi_hand/*channel*/); void cpi_write_channel(cpi_hand/*channel*/, cpi_int64/*write data*/); /******* Nonblocking memory control actions *******/ cpi_tag cpi_nb_write_ram(cpi_hand/*dest ram*/, cpi_ram_addr/*ram_addr*/, cpi_addr/*mem_addr*/, cpi_int/*words*/, cpi_tag/*tag_append*/, .../*optional priority argument*/); cpi_tag cpi_nb_read_ram(cpi_hand/*source ram*/, cpi_ram_addr/*ram addr*/, cpi_addr/*mem_addr*/, cpi_int/*words*/, cpi_tag/*tag_append*/, .../*optional priority argument*/); //cpi_tag cpi_nb_copy_ram(cpi_hand/*source ram*/, cpi_hand/*dest ram*/, cpi_ram_addr/*srcaddr*/, cpi_ram_addr/*dstaddr*/, cpi_int/*words*/, cpi_tag/*tag_append*/); void cpi_set_attr(cpi_hand, cpi_int); /******* Query state control actions *******/ //cpi_int cpi_get_words_rem(cpi_tag/*ram tag*/); /******* Control actions for testing cohandles *******/ bool cpi_test_channel(cpi_hand/*channel*/, bool/*test if writable, otherwise test if readable*/); bool cpi_test(cpi_hand/*cohandle*/, cpi_tag/*ram tag*/); void cpi_membar(); /******* Simulation-only Debugging *******/ void cpi_dumpram(cpi_hand); void cpi_dumpmem(cpi_str fName, cpi_int timestamp); void cpi_printf(const char *fmt, ...); void cpi_split(); // force a basic block split here void cpi_finish(); // terminate simulation /******* Experimental control actions *******/ void cpi_bind(cpi_hand/*channel*/, cpi_hand rams); /******* No-op to prevent loop from being optimized away *******/ void cpi_noop(cpi_int x); #endif /* __CPI_INCLUDED__ */