Пример #1
0
void _trace_blk(IBlk * blk, const char * action)
{
	char path[F8_MAX_PATH];
	*path = 0;
	IBlk_path_by_blk(blk, path, sizeof(path));
	KD_PRINT(("%s block %s\n", action, path));
}
Пример #2
0
string _blk_path(IBlk * b)
{
	char path[F8_MAX_PATH];
	IBlk_path_by_blk(b, path, sizeof(path));
	path[sizeof(path) - 1] = 0;
	return path;
}
Пример #3
0
void CErrorDetector::show()
{
	CInvalidList::iterator i1;
	CConflictList::iterator i2;
	char path[F8_MAX_PATH];
	struct blk_pin_t * p;
	struct blk_var_t * v;

	for(i1 = m_invalidAddress.begin(); i1 != m_invalidAddress.end(); i1++){
		if(i1->magic == PIN_MAGIC){
			p = (struct blk_pin_t*)i1->o;
			IBlk_path_by_pin(p, path, sizeof(path));
			utils_error(
				"pin %s, %%%d%05d invalid, type %d\n", 
				path, p->u2.mem_addr.section, p->u2.mem_addr.addr, i1->a
				);
		}else{
			v = (struct blk_var_t*)i1->o;
			IBlk_path_by_blk(v->blk, path, sizeof(path));
			strncat(path, ".", sizeof(path));
			strncat(path, v->name, sizeof(path));
			utils_error(
				"var %s, %%%d%05d invalid\n", 
				path, v->addr.section, v->addr.addr
				);
		}
	}
}
Пример #4
0
static __bool defineVariable(struct blk_var_t * v, __uint context)
{
	FILE * of = (FILE*)context;
	char buf[1024];
	char path[F8_MAX_PATH];
	const char *tp = _type_name(v->type);
	IBlk_path_by_blk(v->blk, path, sizeof(path));
	sprintf(buf, "set type=%s name=\"%s\" comment=\"%s\" scope=\"%s\"", tp, v->name, v->comment, path);
	if (of==stdout)
		utils_trace("%s\n", buf);
	else
		fprintf(of, "%s\n", buf);
	return __true;
}
Пример #5
0
static void dump_map(int idx)
{
	mem_addr_t addr;
	char path[F8_MAX_PATH];
	int i;
	if(!_is_valid_section(idx)){
		return;
	}
	reg_map * rm = &g_regmap[idx];
	reg_map_ent * e = rm->bitmap;
	void * owner = 0;
	const blk_var_t * var;

	addr.section = idx;

	for(i=0; i<rm->total_items; i++, e++){		
		if(!e->owner){
			continue;
		}
		addr.addr = i;
		if(e->owner != owner){
			owner = e->owner;			
			utils_trace(
				"%%%d%05d owned by ",
				idx,
				i
				);
			var = query_var_by_addr(&addr);
			if(var){
				IBlk_path_by_blk(var->blk, path, sizeof(path));
				utils_trace("{%s}.%s", path, var->name);
			}else{
				IBlk_path_by_pin((struct blk_pin_t*)owner, path, sizeof(path));
				utils_trace("%s", path);
			}
			utils_trace("\n");
		}
	}
}
Пример #6
0
void CErrorDetector::fix()
{
	CInvalidList::iterator i1;
	CConflictList::iterator i2;
	char path[F8_MAX_PATH];
	struct blk_pin_t * p;
	struct blk_var_t * v;

	for(i1 = m_invalidAddress.begin(); i1 != m_invalidAddress.end(); i1++){
		if(i1->magic == PIN_MAGIC){
			p = (struct blk_pin_t*)i1->o;
			IBlk_path_by_pin(p, path, sizeof(path));
			utils_error(
				"pin %s, %%%d%05d invalid, type %d\n", 
				path, p->u2.mem_addr.section, p->u2.mem_addr.addr, i1->a
				);
			switch(i1->a){
			case 0:
				/* allocate a register for this PIN */
				break;
			case 1:
				p->binding = PIN_B_CONST;
				break;
			case 2:
				break;
			}
		}else{
			v = (struct blk_var_t*)i1->o;
			IBlk_path_by_blk(v->blk, path, sizeof(path));
			strncat(path, ".", sizeof(path));
			strncat(path, v->name, sizeof(path));
			utils_error(
				"var %s, %%%d%05d invalid\n", 
				path, v->addr.section, v->addr.addr
				);
		}
	}
}
Пример #7
0
static void dumpBblk(IBlk * b, FILE * of)
{
	const char * name;
	char path[F8_MAX_PATH];
	char buf[1024];
	char idName[128];
	struct blk_ent_t be;
	struct blk_pin_t * p;

	*buf=0;
	if(!(parent_blk(b)->h.flags & BLK_F_READONLY)){
		name = IBlk_name(b);
		IBlk_path_by_blk(parent_blk(b), path, sizeof(buf));
		if(blklib_query(&b->h.uuid, &be)){
			sprintf(buf, "mount  path=\"%s\" type=\"%s.%s\" name=\"%s\"", path, be.dir, be.name, name);
		}else{
			f8_uuid_to_string(&b->h.uuid, idName, sizeof(idName));
			sprintf(buf, "mount  path=\"%s\" id=%s name=\"%s\" ", path, idName, name);
		}
		if(of==stdout)
			utils_trace("%s\n", buf);
		else
			fprintf(of, "%s\n", buf);
		IBlk_path_by_blk(b, path, sizeof(path));
		sprintf(buf, "place block \"%s\" (%d,%d)", path, get_res_int(&b->uuid, "x", 0), get_res_int(&b->uuid, "y", 0));
		if (of==stdout)
			utils_trace("%s\n", buf);
		else
			fprintf(of, "%s\n", buf);		
	}
	
	for(p = __vcall__(b, first_pin, (b)); p; p = __vcall__(b, next_pin, (p))){
		if(p->_class != PIN_CLASS_DI && p->_class != PIN_CLASS_DO){
			continue;
		}
		IBlk_path_by_pin(p, path, sizeof(path));
		// dump binding
		*buf = 0;
		if(p->binding == PIN_B_CONST){
			switch(p->type){
			case  PIN_T_INTEGER	:
				if(p->dp->u.d.i32 != 0){
					sprintf(buf, "bind \"%s\" %d", path, p->dp->u.d.i32);
				}
				break;
			case  PIN_T_BOOL		:
				if(p->dp->u.d.ui8 != 0){
					sprintf(buf, "bind \"%s\" %d", path, p->dp->u.d.ui8);
				}
				break;
			case  PIN_T_FLOAT		:
				if(p->dp->u.d.flt != 0){
					sprintf(buf, "bind \"%s\" %f", path, p->dp->u.d.flt);
				}
				break;
			case  PIN_T_BYTE		:
				if(p->dp->u.d.ui8 != 0){
					sprintf(buf, "bind \"%s\" %d", path, p->dp->u.d.ui8);
				}
				break;
			case  PIN_T_WORD		:
				if(p->dp->u.d.ui16 != 0){
					sprintf(buf, "bind \"%s\" %d", path, p->dp->u.d.ui16);
				}
				break;
			case  PIN_T_DOUBLE	:
				if(p->dp->u.d.dbl != 0){
					sprintf(buf, "bind \"%s\" %.15f", path, p->dp->u.d.dbl);
				}
				break;
			case  PIN_T_DATE		:
				if(fabs(p->dp->u.d.dbl) > 1e-9){
					if(p->dp->u.d.dbl > 2.0){
						sprintf(buf, "bind \"%s\" t#%fs", path, p->dp->u.d.dbl);
					}else{
						sprintf(buf, "bind \"%s\" t#%fms", path, p->dp->u.d.dbl*1000);
					}
				}
				break;
			case  PIN_T_CHAR		:
				if(p->dp->u.d.i8 != 0){
					sprintf(buf, "bind \"%s\" %d", path, p->dp->u.d.i8);
				}
				break;
			case  PIN_T_SHORT		:
				if(p->dp->u.d.i16 != 0){
					sprintf(buf, "bind \"%s\" %d", path, p->dp->u.d.ui16);
				}
				break;
			case  PIN_T_DWORD		:
				if(p->dp->u.d.ui32 != 0){
					sprintf(buf, "bind \"%s\" %d", path, p->dp->u.d.ui32);
				}
				break;
			}
		}else {
			struct blk_var_t * v;
			v = query_var_by_pin(p);
			if(v){
				char vpath[F8_MAX_PATH];
				IBlk_path_by_blk(v->blk, vpath, sizeof(vpath));
				sprintf(buf, "bind \"%s\" %s.%s", path, vpath, v->name);
				// on_bind
			}
		}

		if(*buf){
			if(of==stdout)
				utils_trace("%s\n", buf);
			else
				fprintf(of, "%s\n", buf);
		}
		
		if(p->type==PIN_T_BOOL && (p->flags & PIN_F_INVERTED)){
			sprintf(buf, "invert \"%s\"", path);
			if(of==stdout)
				utils_trace("%s\n", buf);
			else
				fprintf(of, "%s\n", buf);
		}
		
	}
}
Пример #8
0
static void dumpCblk(IBlk * b, __bool firstVisit, FILE * of)
{
	const char * name;
	char path[F8_MAX_PATH];
	char buf[1024];
	char idName[128];
	struct blk_ent_t be;

	if(firstVisit){
		name = IBlk_name(b);
		IBlk_path_by_blk(parent_blk(b), path, sizeof(path));
		if(parent_blk(b) && !(parent_blk(b)->h.flags & BLK_F_READONLY)){
			if(b->h.flags & BLK_F_READONLY){
				if(blklib_query(&b->h.uuid, &be)){
					sprintf(buf, "mount  path=\"%s\" type=\"%s.%s\" name=\"%s\"", path, be.dir, be.name, name);
				}else{
					f8_uuid_to_string(&b->h.uuid, idName, sizeof(idName));
					sprintf(buf, "mount  path=\"%s\" id=%s name=\"%s\"", path, idName, name);
				}
				if(of==stdout)
					utils_trace("%s\n",buf);
				else
					fprintf(of, "%s\n", buf);
				return;
			}else{
				sprintf(buf, "mount path=\"%s\" file=blank.blk name=\"%s\" rw", path, name);
			}
			if (of==stdout)
				utils_trace("%s\n",buf);
			else
				fprintf(of, "%s\n", buf);
			IBlk_path_by_blk(b, path, sizeof(path));
			sprintf(buf, "place block \"%s\" (%d,%d)", path, get_res_int(&b->uuid, "x", 0), get_res_int(&b->uuid, "y", 0));
			if(of==stdout)
				utils_trace("%s\n",buf);
			else
				fprintf(of, "%s\n", buf);
		}

		enum_variables(b, defineVariable, (__uint)of);
	}else{
		/*
			dump links positions/export pins
		*/
		if(b->h.flags & BLK_F_READONLY){
			return;
		}
		ICBlk * cb = __dcast__(IBlk, ICBlk, b);
		struct cblk_link_t * l;
		for(l=ICBlk_first_link(cb); l; l=ICBlk_next_link(l)){
			char p1[F8_MAX_PATH];
			char p2[F8_MAX_PATH];
			IBlk_path_by_pin(l->s.pin, p1, sizeof(p1));
			IBlk_path_by_pin(l->t.pin, p2, sizeof(p2));
			sprintf(buf, "link \"%s\" \"%s\"", p1, p2);
			if(of==stdout)
				utils_trace("%s\n",buf);
			else
				fprintf(of, "%s\n", buf);

			TLinkMetrics *m;
			m = (TLinkMetrics *)get_res_buf(&l->uuid, 0, "metrics");
			if(m){
				char *p;
				p = buf;
				p += sprintf(p, "place link \"%s\" %d ", p2, m->count);
				int i;
				for(i=0; i<m->count; i++){
					p += sprintf(p, "(%d,%d) ", m->coord[i].x, m->coord[i].y);
				}
				if(of==stdout)
					utils_trace("%s\n",buf);
				else
					fprintf(of, "%s\n", buf);
			}
		}
	}
}