// SetConfigBit writes a bit to a specified config register using read-modify-write. Only use // function to access memory locations that are not (!) performance critical (e.g. Tile-ID). // Use MallocConfigReg() function for performance critical memory locations! // // Parameter: ConfigAddr - Address of configuration register... // BitPos - Bit position within config register to set/reset // BitValue - Value to write to specified bit... // void SetConfigBit(unsigned int ConfigAddr, int BitPos, int BitValue) { int Register = ReadConfigReg(ConfigAddr); if (DEBUG) printf("RMW Read: %0x...\n", Register); if (BitValue) { Register = Register | (1<<BitPos); } else { Register = Register & ~(1<<BitPos); } if (DEBUG) printf("RMW Write: %0x...\n", Register); SetConfigReg(ConfigAddr, Register); }
//-------------------------------------------------------------------------------------- // FUNCTION: MYCOREID //-------------------------------------------------------------------------------------- // return physical core ID of calling core //-------------------------------------------------------------------------------------- int MYCOREID() { #ifdef SCC int tmp, x, y, z; tmp=ReadConfigReg(CRB_OWN+MYTILEID); x=(tmp>>3) & 0x0f; // bits 06:03 y=(tmp>>7) & 0x0f; // bits 10:07 z=(tmp ) & 0x07; // bits 02:00 return ( ( x + ( 6 * y ) ) * 2 ) + z; // True Processor ID! #else // the COREIDs are read into the main program in potentially random order. // Each core can access its own Core ID. We simulate that by selecting // the value in the list of coreids that corresponds to the sequence // number of the OpenMP thread number return RC_COREID[omp_get_thread_num()]; #endif }
// readFpgaGrb allows to read a register value from the SIF FPGA register bank // by passing the register bank address as specified in the SIF FPGA documentation. // Some addresses have already been specified in config.h! // // Parameter: addr - Register address // value ref - pointer to the unsigned int variable that will be // updated with the result... // void readFpgaGrb(int addr, unsigned int* value) { *value=ReadConfigReg(FPGA_BASE+addr); }