void common_net_element_error(SIM_NET_ELEMENT * net_element) { output_level = 1; common_print("\t!ERROR @ [%s]'s NET_ELEMENT:\n\t", net_element->father->name); common_net_element_print(net_element); common_print("\n"); output_level = 0; }
void common_net_element_list_print(SIM_NET_ELEMENT_LIST * net_element_list) { common_print("\t\t|---[NET] { "); while(net_element_list){ common_net_element_print(net_element_list->net_element); net_element_list = net_element_list->next; } common_print(" };\n"); }
void common_module_list_print(SIM_MODULE_LIST * head) { SIM_MODULE_LIST * temp; common_print("+------- module list begin --------\n"); temp = head; while (temp) { common_module_print(temp->module); temp = temp->next; } common_print("-------- module list end --------\n"); return; }
/* find a module in list by given name, return NULL no match */ void common_module_error(SIM_MODULE * module) { output_level = 1; common_print(" !ERROR @ MODULE[%s]\n", module->name); output_level = 0; }
void common_net_element_list_error(SIM_NET_ELEMENT_LIST * net_element_list) { output_level = 1; common_print("\t!ERROR @ ELEMENT_LIST:\n"); common_net_element_list_print(net_element_list); output_level = 0; }
void common_element_error(SIM_ELEMENT * element) { output_level = 1; common_print("\t!ERROR @ [%s]'s ELEMENT:\n", element->father->name); common_element_print(element); output_level = 0; }
void common_dimension_print(SIM_DIMENSION * dimension) { int i; int count; if(dimension == NULL){ return; } for(i = 0, count = dimension->count; i < count; i++){ common_print("[%d]", (dimension->width)[i]); } if(dimension->way){ common_print("[%d:%d]", dimension->way_low, dimension->way_high); } }
static void print(char *fmt, ...) { va_list ap; va_start(ap, fmt); common_print(fmt, ap); va_end(ap); }
void common_link_print(SIM_LINK * link) { //common_print("+---\n"); if(link == NULL){ return; } // common_print("src_module_node->name:[%s]\n", link->src_module_node->name); // common_print("src_module_name:[%s]\n", link->src_module_name); // common_print("src_module_type->name:[%s]\n", link->src_module_type->name); // common_print("src_port_type->name:[%s]\n", link->src_port_type->name); // common_print("src_port_way:[%s]\n", link->src_port_way); // common_print("dest_module_node->name:[%s]\n", link->dest_module_node->name); // common_print("dest_module_name:[%s]\n", link->dest_module_name); // common_print("dest_module_type->name:[%s]\n", link->dest_module_type->name); // common_print("dest_port_type->name:[%s]\n", link->dest_port_type->name); // common_print("dest_port_way:[%s]\n", link->dest_port_way); // common_print("%s.%s", link->src_module_name, link->src_port_type->name); // common_print("%s ==>> ", link->src_port_way); // // common_print("%s.%s", link->dest_module_name, link->dest_port_type->name); // common_print("%s\n", link->dest_port_way); // common_print("|%s . %s", link->src_module_node->name, link->src_port_type->name); // common_print("%s ==>> ", link->src_port_way); // // common_print("|%s . %s", link->dest_module_node->name, link->dest_port_type->name); // common_print("%s\n", link->dest_port_way); if(link->type == LINK_CONST){ common_print("const"); } common_print("%s ==>> %s\n", link->src_full_name, link->dest_full_name); // common_print("SRC(%s):", link->src_module_type->behavior?"b":"s"); // common_print("DEST(%s)\n", link->dest_module_type->behavior?"b":"s"); //common_print("----\n"); }
static void verbose_print(char *fmt, ...) { if (verbose) { va_list ap; va_start(ap, fmt); common_print(fmt, ap); va_end(ap); } }
void common_module_print(SIM_MODULE * module) { common_print("+---- module begin:%s\n", module->name); /* cycle */ if (module->behavior) { common_print("# ~cycle:%d\n", module->cycle); } /* behavior */ common_print("# %s\n", module->behavior ? "behavior" : "structural"); /* elements */ common_element_list_print(module->element_list); /* nets */ common_net_list_print(module->net_list); common_print("----- module-end----\n\n"); }
void main(int argc, char* argv[]) { // for 宏参数预处理 // 宏参数中若包含另外的宏,那么宏参数在被代入到宏体之前会做一次完全的展开,除非宏体中含有#或##。 AFTERX(BUFSIZE)(); XAFTERX(BUFSIZE)(); // for # & ## // WARN_IF int divider = 0; WARN_IF(divider == 0); M_CONTATENOR(AA, BB, CC)(); common_print(M_CONTATENOR(AA, BB, CC)); char* templt = "apple = %d, banana = %d, orange = %d\n"; char* arg1 = "hello"; VARIADIC_MACRO_PRINT(templt, 1, 2, 3); VARIADIC_MACRO_FUNCTION(templt, 1, 2, 3); }
void common_module_tree_print(SIM_MODULE_TREE * root) { SIM_MODULE_TREE *temp = root->child; static int level = 1; int i; if (level == 1) { common_print("--------------\n"); } i = level; common_print("[%6d]", root->id); common_print("[%6d]", root->sortid); while (i-- > 1) { common_print("\t"); } common_print("|---"); // info if(root->module->behavior){ if(root->module->cycle == 0){ common_print(" * "); }else{ common_print(" + "); } }else{ common_print(" ~ "); } common_print("%s\n", root->name); level++; while (temp) { common_module_tree_print(temp); temp = temp->brother; } level--; if (root->brother == NULL) { common_print("\t"); i = level; while (i-- > 1) { common_print("\t"); } common_print("`\n"); } if (level == 1) { common_print("--------------\n"); } return; }
void common_net_print(SIM_NET * net) { common_print("NET(%s)", net->type == NET_TYPE_BUS ? "BUS" : "LINKS"); common_net_element_list_print(net->net_element_list); }
void common_net_element_print(SIM_NET_ELEMENT * net_element) { if(net_element == NULL){ common_print("<empty>"); return; } common_print("<"); switch(net_element->type){ case NET_ELEMENT_UNKNOWN: common_print("[????]"); break; case NET_ELEMENT_PORT: common_print("PORT"); break; case NET_ELEMENT_WRITER: common_print("WRITER"); break; case NET_ELEMENT_READER: common_print("READER"); break; case NET_ELEMENT_INOUT: common_print("INOUT"); break; case NET_ELEMENT_VALUE: common_print("VALUE"); break; } common_print(":"); switch(net_element->type){ case NET_ELEMENT_UNKNOWN: common_print("??"); break; case NET_ELEMENT_PORT: case NET_ELEMENT_WRITER: case NET_ELEMENT_READER: case NET_ELEMENT_INOUT: if(net_element->module_name){ common_print("%s.", net_element->module_name); } if(net_element->port_name){ common_print("%s", net_element->port_name); } common_dimension_print(net_element->way); if(net_element->way->count + net_element->way->way > 0){ common_print(";"); } common_dimension_print(net_element->dimension); break; case NET_ELEMENT_VALUE: common_print("\"%s\"", net_element->port_name); break; } common_print("> "); }
/* print an element */ void common_element_print(SIM_ELEMENT * element) { char * data_type; common_print("\t\t|---[ELEMENT]--^[%s]--", element->father->name); switch(element->type){ case ELEMENT_INPUT: common_print("[input]"); break; case ELEMENT_OUTPUT: common_print("[output]"); break; case ELEMENT_INOUT: common_print("[inout]"); break; case ELEMENT_RAM: common_print("[ram]"); break; case ELEMENT_CONTAIN: common_print("[contain]"); break; case ELEMENT_UNKNOWN: common_print("[unknown]"); break; } switch(element->type){ case ELEMENT_INPUT: case ELEMENT_OUTPUT: case ELEMENT_INOUT: case ELEMENT_RAM: data_type = common_data_type_to_string(element->data_type); common_print("[%s]", data_type); break; case ELEMENT_CONTAIN: common_print("[%s]", element->module_type); break; case ELEMENT_UNKNOWN: common_print("[??]"); break; } common_print("[\"%s\"]", element->name); common_dimension_print(element->dimension); common_print("------\n"); return; }