#include "types.h"
Go to the source code of this file.
Functions | |
ast_node_t * | create_node_w_type (ids id, int line_number, int file_number) |
void | free_child_in_tree (ast_node_t *from, int idx_removal) |
void | free_ast_node (ast_node_t *child) |
void | free_ast_node_only (ast_node_t *child) |
ast_node_t * | create_tree_node_id (char *string, int line_number, int file_number) |
ast_node_t * | create_tree_node_long_long_number (long long number, int line_number, int file_number) |
ast_node_t * | create_tree_node_number (char *number, int line_number, int file_number) |
void | allocate_children_to_node (ast_node_t *node, int num_children,...) |
void | add_child_to_node (ast_node_t *node, ast_node_t *child) |
int | get_range (ast_node_t *first_node) |
void | make_concat_into_list_of_strings (ast_node_t *concat_top) |
char * | get_name_of_pin_at_bit (ast_node_t *var_node, int bit) |
char * | get_name_of_var_declare_at_bit (ast_node_t *var_declare, int bit) |
char_list_t * | get_name_of_pins (ast_node_t *var_node) |
char_list_t * | get_name_of_pins_with_prefix (ast_node_t *var_node, char *instance_name_prefix) |
void add_child_to_node | ( | ast_node_t * | node, | |
ast_node_t * | child | |||
) |
Definition at line 325 of file ast_util.c.
00326 { 00327 /* allocate space for the children */ 00328 node->children = (ast_node_t**)realloc(node->children, sizeof(ast_node_t*)*(node->num_children+1)); 00329 node->num_children ++; 00330 node->children[node->num_children-1] = child; 00331 }
void allocate_children_to_node | ( | ast_node_t * | node, | |
int | num_children, | |||
... | ||||
) |
Definition at line 304 of file ast_util.c.
00305 { 00306 va_list ap; 00307 int i; 00308 00309 /* allocate space for the children */ 00310 node->children = (ast_node_t**)malloc(sizeof(ast_node_t*)*num_children); 00311 node->num_children = num_children; 00312 00313 /* set the virtual arguments */ 00314 va_start(ap, num_children); 00315 00316 for (i = 0; i < num_children; i++) 00317 { 00318 node->children[i] = va_arg(ap, ast_node_t*); 00319 } 00320 }
ast_node_t* create_node_w_type | ( | ids | id, | |
int | line_number, | |||
int | file_number | |||
) |
Definition at line 41 of file ast_util.c.
00042 { 00043 static long unique_count = 0; 00044 00045 // oassert(unique_count != 198); 00046 00047 ast_node_t* new_node; 00048 00049 new_node = (ast_node_t*)calloc(1, sizeof(ast_node_t)); 00050 oassert(new_node != NULL); 00051 new_node->type = id; 00052 00053 new_node->children = NULL; 00054 new_node->num_children = 0; 00055 00056 new_node->line_number = line_number; 00057 new_node->file_number = file_number; 00058 new_node->unique_count = unique_count++; 00059 00060 new_node->far_tag = 0; 00061 new_node->high_number = 0; 00062 00063 return new_node; 00064 }
ast_node_t* create_tree_node_id | ( | char * | string, | |
int | line_number, | |||
int | file_number | |||
) |
Definition at line 169 of file ast_util.c.
00170 { 00171 ast_node_t* new_node = create_node_w_type(IDENTIFIERS, line_number, current_parse_file); 00172 new_node->types.identifier = string; 00173 00174 return new_node; 00175 }
ast_node_t* create_tree_node_long_long_number | ( | long long | number, | |
int | line_number, | |||
int | file_number | |||
) |
Definition at line 180 of file ast_util.c.
00181 { 00182 ast_node_t* new_node = create_node_w_type(NUMBERS, line_number, current_parse_file); 00183 new_node->types.number.base = LONG_LONG; 00184 new_node->types.number.value = number; 00185 00186 return new_node; 00187 }
ast_node_t* create_tree_node_number | ( | char * | number, | |
int | line_number, | |||
int | file_number | |||
) |
Definition at line 192 of file ast_util.c.
00193 { 00194 ast_node_t* new_node = create_node_w_type(NUMBERS, line_number, current_parse_file); 00195 char *string_pointer = number; 00196 int index_string_pointer = 0; 00197 char *temp_string; 00198 short flag_constant_decimal = FALSE; 00199 00200 /* find the ' character if it's a base */ 00201 for (string_pointer=number; *string_pointer; string_pointer++) 00202 { 00203 if (*string_pointer == '\'') 00204 { 00205 break; 00206 } 00207 index_string_pointer++; 00208 } 00209 00210 if (index_string_pointer == strlen(number)) 00211 { 00212 flag_constant_decimal = TRUE; 00213 /* this is base d */ 00214 new_node->types.number.base = DEC; 00215 /* reset to the front */ 00216 string_pointer = number; 00217 00218 /* size is the rest of the string */ 00219 new_node->types.number.size = strlen((string_pointer)); 00220 /* assign the remainder of the number to a string */ 00221 new_node->types.number.number = strdup((string_pointer)); 00222 } 00223 else 00224 { 00225 /* there is a base in the form: number[bhod]'number */ 00226 switch(tolower(*(string_pointer+1))) 00227 { 00228 case 'd': 00229 new_node->types.number.base = DEC; 00230 break; 00231 case 'h': 00232 new_node->types.number.base = HEX; 00233 break; 00234 case 'o': 00235 new_node->types.number.base = OCT; 00236 break; 00237 case 'b': 00238 new_node->types.number.base = BIN; 00239 break; 00240 default: 00241 printf("Not a number\n"); 00242 oassert(FALSE); 00243 } 00244 00245 /* check if the size matches the design specified size */ 00246 temp_string = strdup(number); 00247 temp_string[index_string_pointer] = '\0'; 00248 /* size is the rest of the string */ 00249 new_node->types.number.size = atoi(temp_string); 00250 free(temp_string); 00251 00252 /* move to the digits */ 00253 string_pointer += 2; 00254 00255 /* assign the remainder of the number to a string */ 00256 new_node->types.number.number = strdup((string_pointer)); 00257 } 00258 00259 /* check for decimal numbers without the formal 2'd... format */ 00260 if (flag_constant_decimal == FALSE) 00261 { 00262 /* size describes how may bits */ 00263 new_node->types.number.binary_size = new_node->types.number.size; 00264 } 00265 else 00266 { 00267 /* size is for a constant that needs */ 00268 if (strcmp(new_node->types.number.number, "0") != 0) 00269 { 00270 new_node->types.number.binary_size = ceil((log(convert_dec_string_of_size_to_long(new_node->types.number.number, new_node->types.number.size)+1))/log(2)); 00271 } 00272 else 00273 { 00274 new_node->types.number.binary_size = 1; 00275 } 00276 } 00277 /* add in the values for all the numbers */ 00278 switch (new_node->types.number.base) 00279 { 00280 case(DEC): 00281 new_node->types.number.value = convert_dec_string_of_size_to_long(new_node->types.number.number, new_node->types.number.size); 00282 new_node->types.number.binary_string = convert_long_to_bit_string(new_node->types.number.value, new_node->types.number.binary_size); 00283 break; 00284 case(HEX): 00285 new_node->types.number.value = convert_hex_string_of_size_to_long(new_node->types.number.number, strlen(new_node->types.number.number)); 00286 new_node->types.number.binary_string = convert_long_to_bit_string(new_node->types.number.value, new_node->types.number.binary_size); 00287 break; 00288 case(OCT): 00289 new_node->types.number.value = convert_oct_string_of_size_to_long(new_node->types.number.number, strlen(new_node->types.number.number)); 00290 new_node->types.number.binary_string = convert_long_to_bit_string(new_node->types.number.value, new_node->types.number.binary_size); 00291 break; 00292 case(BIN): 00293 new_node->types.number.value = convert_binary_string_of_size_to_long(new_node->types.number.number, strlen(new_node->types.number.number));// a -1 is in case of x or z's 00294 new_node->types.number.binary_string = convert_long_to_bit_string(new_node->types.number.value, new_node->types.number.binary_size); 00295 break; 00296 } 00297 00298 return new_node; 00299 }
void free_ast_node | ( | ast_node_t * | child | ) |
Definition at line 108 of file ast_util.c.
00109 { 00110 int i; 00111 00112 if ((child == NULL) || (child->shared_node == TRUE)) 00113 return; 00114 00115 /* free all it's children .... and so on recursively */ 00116 for (i = 0; i < child->num_children; i++) 00117 { 00118 free_child_in_tree(child, i); 00119 } 00120 00121 if (child->children != NULL) 00122 free(child->children); 00123 00124 switch(child->type) 00125 { 00126 case IDENTIFIERS: 00127 if (child->types.identifier != NULL) 00128 free(child->types.identifier); 00129 break; 00130 case NUMBERS: 00131 if (child->types.number.number != NULL) 00132 free(child->types.number.number); 00133 break; 00134 default: 00135 break; 00136 } 00137 00138 free(child); 00139 }
void free_ast_node_only | ( | ast_node_t * | child | ) |
Definition at line 144 of file ast_util.c.
00145 { 00146 if (child->children != NULL) 00147 free(child->children); 00148 00149 switch(child->type) 00150 { 00151 case IDENTIFIERS: 00152 if (child->types.identifier != NULL) 00153 free(child->types.identifier); 00154 break; 00155 case NUMBERS: 00156 if (child->types.number.number != NULL) 00157 free(child->types.number.number); 00158 break; 00159 default: 00160 break; 00161 } 00162 00163 free(child); 00164 }
void free_child_in_tree | ( | ast_node_t * | from, | |
int | idx_removal | |||
) |
Definition at line 70 of file ast_util.c.
00071 { 00072 ast_node_t *child = from->children[idx_removal]; 00073 int i; 00074 00075 if ((child == NULL) || (child->shared_node == TRUE)) 00076 return; 00077 00078 /* free all it's children .... and so on recursively */ 00079 for (i = 0; i < child->num_children; i++) 00080 { 00081 free_child_in_tree(child->children[i], i); 00082 } 00083 00084 if (child->children != NULL) 00085 free(child->children); 00086 00087 switch(child->type) 00088 { 00089 case IDENTIFIERS: 00090 if (child->types.identifier != NULL) 00091 free(child->types.identifier); 00092 break; 00093 case NUMBERS: 00094 if (child->types.number.number != NULL) 00095 free(child->types.number.number); 00096 break; 00097 default: 00098 break; 00099 } 00100 00101 free(child); 00102 from->children[idx_removal] = NULL; 00103 }
char* get_name_of_pin_at_bit | ( | ast_node_t * | var_node, | |
int | bit | |||
) |
Definition at line 489 of file ast_util.c.
00490 { 00491 char *return_string; 00492 00493 if (var_node->type == ARRAY_REF) 00494 { 00495 return_string = make_full_ref_name(NULL, NULL, NULL, var_node->children[0]->types.identifier, (int)var_node->children[1]->types.number.value); 00496 } 00497 else if (var_node->type == RANGE_REF) 00498 { 00499 oassert((var_node->children[2]->types.number.value+bit <= var_node->children[1]->types.number.value) && (var_node->children[2]->types.number.value+bit >= var_node->children[2]->types.number.value)); 00500 return_string = make_full_ref_name(NULL, NULL, NULL, var_node->children[0]->types.identifier, var_node->children[2]->types.number.value+bit); 00501 } 00502 else if ((var_node->type == IDENTIFIERS) && (bit == -1)) 00503 { 00504 return_string = make_full_ref_name(NULL, NULL, NULL, var_node->types.identifier, -1); 00505 } 00506 else if (var_node->type == IDENTIFIERS) 00507 { 00508 long sc_spot; 00509 int pin_index; 00510 00511 if ((sc_spot = sc_lookup_string(local_symbol_table_sc, var_node->types.identifier)) == -1) 00512 { 00513 error_message(NETLIST_ERROR, var_node->line_number, var_node->file_number, "Missing declaration of this symbol %s\n", var_node->types.identifier); 00514 } 00515 00516 if (((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[1] == NULL) 00517 { 00518 pin_index = bit; 00519 } 00520 else if (((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[3] == NULL) 00521 { 00522 pin_index = ((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[2]->types.number.value + bit; 00523 } 00524 else 00525 oassert(FALSE); 00526 00527 return_string = make_full_ref_name(NULL, NULL, NULL, var_node->types.identifier, pin_index); 00528 } 00529 else if (var_node->type == NUMBERS) 00530 { 00531 if (bit == -1) 00532 bit = 0; 00533 00534 oassert(bit < var_node->types.number.binary_size); 00535 if (var_node->types.number.binary_string[var_node->types.number.binary_size-bit-1] == '1') 00536 { 00537 return_string = (char*)malloc(sizeof(char)*11+1); // ONE_VCC_CNS 00538 sprintf(return_string, "ONE_VCC_CNS"); 00539 } 00540 else if (var_node->types.number.binary_string[var_node->types.number.binary_size-bit-1] == '0') 00541 { 00542 return_string = (char*)malloc(sizeof(char)*13+1); // ZERO_GND_ZERO 00543 sprintf(return_string, "ZERO_GND_ZERO"); 00544 } 00545 else 00546 { 00547 oassert(FALSE); 00548 } 00549 } 00550 else if (var_node->type == CONCATENATE) 00551 { 00552 if (var_node->types.concat.num_bit_strings == 0) 00553 { 00554 oassert(FALSE); 00555 } 00556 else 00557 { 00558 if (var_node->types.concat.num_bit_strings == -1) 00559 { 00560 /* If this hasn't been made into a string list then do it */ 00561 make_concat_into_list_of_strings(var_node); 00562 } 00563 00564 return_string = (char*)malloc(sizeof(char)*strlen(var_node->types.concat.bit_strings[bit])+1); 00565 sprintf(return_string, "%s", var_node->types.concat.bit_strings[bit]); 00566 } 00567 } 00568 else 00569 { 00570 oassert(FALSE); 00571 } 00572 00573 return return_string; 00574 }
char_list_t* get_name_of_pins | ( | ast_node_t * | var_node | ) |
Definition at line 581 of file ast_util.c.
00582 { 00583 char **return_string; 00584 char_list_t *return_list = (char_list_t*)malloc(sizeof(char_list_t)); 00585 00586 int i; 00587 int width; 00588 00589 if (var_node->type == ARRAY_REF) 00590 { 00591 width = 1; 00592 return_string = (char**)malloc(sizeof(char*)); 00593 return_string[0] = make_full_ref_name(NULL, NULL, NULL, var_node->children[0]->types.identifier, (int)var_node->children[1]->types.number.value); 00594 } 00595 else if (var_node->type == RANGE_REF) 00596 { 00597 width = (var_node->children[1]->types.number.value - var_node->children[2]->types.number.value+1); 00598 return_string = (char**)malloc(sizeof(char*)*width); 00599 for (i = 0; i < width; i++) 00600 { 00601 return_string[i] = make_full_ref_name(NULL, NULL, NULL, var_node->children[0]->types.identifier, var_node->children[2]->types.number.value+i); 00602 } 00603 } 00604 else if (var_node->type == IDENTIFIERS) 00605 { 00606 /* need to look in the symbol table for details about this identifier (i.e. is it a port) */ 00607 long sc_spot; 00608 char *temp_string = make_full_ref_name(NULL, NULL, NULL, var_node->types.identifier, -1); 00609 00610 if ((sc_spot = sc_lookup_string(local_symbol_table_sc, temp_string)) == -1) 00611 { 00612 error_message(NETLIST_ERROR, var_node->line_number, var_node->file_number, "Missing declaration of this symbol %s\n", temp_string); 00613 } 00614 free(temp_string); 00615 00616 if (((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[1] == NULL) 00617 { 00618 width = 1; 00619 return_string = (char**)malloc(sizeof(char*)*width); 00620 return_string[0] = make_full_ref_name(NULL, NULL, NULL, var_node->types.identifier, -1); 00621 } 00622 else if (((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[3] == NULL) 00623 { 00624 int index = 0; 00625 width = ((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[1]->types.number.value - ((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[2]->types.number.value + 1; 00626 return_string = (char**)malloc(sizeof(char*)*width); 00627 for (i = 0; i < width; i++) 00628 // for (i = 0; i < ((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[2]->types.number.value; i < ((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[1]->types.number.value+1; i++) 00629 { 00630 return_string[index] = make_full_ref_name(NULL, NULL, NULL, var_node->types.identifier, i+((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[2]->types.number.value); 00631 index++; 00632 } 00633 } 00634 else if (((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[3] != NULL) 00635 { 00636 oassert(FALSE); 00637 } 00638 } 00639 else if (var_node->type == NUMBERS) 00640 { 00641 width = var_node->types.number.binary_size; 00642 return_string = (char**)malloc(sizeof(char*)*width); 00643 for (i = 0; i < width; i++) 00644 { 00645 /* strings are msb is 0th index in string, reverse access */ 00646 if (var_node->types.number.binary_string[var_node->types.number.binary_size-i-1] == '1') 00647 { 00648 return_string[i] = (char*)malloc(sizeof(char)*11+1); // ONE_VCC_CNS 00649 sprintf(return_string[i], "ONE_VCC_CNS"); 00650 } 00651 else if (var_node->types.number.binary_string[var_node->types.number.binary_size-i-1] == '0') 00652 { 00653 return_string[i] = (char*)malloc(sizeof(char)*13+1); // ZERO_GND_ZERO 00654 sprintf(return_string[i], "ZERO_GND_ZERO"); 00655 } 00656 else 00657 { 00658 oassert(FALSE); 00659 } 00660 } 00661 } 00662 else if (var_node->type == CONCATENATE) 00663 { 00664 if (var_node->types.concat.num_bit_strings == 0) 00665 { 00666 oassert(FALSE); 00667 } 00668 else 00669 { 00670 if (var_node->types.concat.num_bit_strings == -1) 00671 { 00672 /* If this hasn't been made into a string list then do it */ 00673 make_concat_into_list_of_strings(var_node); 00674 } 00675 00676 width = var_node->types.concat.num_bit_strings; 00677 return_string = (char**)malloc(sizeof(char*)*width); 00678 for (i = 0; i < width; i++) // 0th bit is MSB so need to access reverse 00679 { 00680 return_string[i] = (char*)malloc(sizeof(char)*strlen(var_node->types.concat.bit_strings[var_node->types.concat.num_bit_strings-i-1])+1); 00681 sprintf(return_string[i], "%s", var_node->types.concat.bit_strings[var_node->types.concat.num_bit_strings-i-1]); 00682 } 00683 } 00684 } 00685 else 00686 { 00687 oassert(FALSE); 00688 } 00689 00690 return_list->strings = return_string; 00691 return_list->num_strings = width; 00692 00693 return return_list; 00694 }
char_list_t* get_name_of_pins_with_prefix | ( | ast_node_t * | var_node, | |
char * | instance_name_prefix | |||
) |
Definition at line 699 of file ast_util.c.
00700 { 00701 int i; 00702 char_list_t *return_list; 00703 00704 /* get the list */ 00705 return_list = get_name_of_pins(var_node); 00706 00707 for (i = 0; i < return_list->num_strings; i++) 00708 { 00709 return_list->strings[i] = make_full_ref_name(instance_name_prefix, NULL, NULL, return_list->strings[i], -1); 00710 } 00711 00712 return return_list; 00713 }
char* get_name_of_var_declare_at_bit | ( | ast_node_t * | var_declare, | |
int | bit | |||
) |
Definition at line 462 of file ast_util.c.
00463 { 00464 char *return_string; 00465 00466 /* calculate the port details */ 00467 if (var_declare->children[1] == NULL) 00468 { 00469 oassert(bit == 0); 00470 return_string = make_full_ref_name(NULL, NULL, NULL, var_declare->children[0]->types.identifier, -1); 00471 } 00472 else if (var_declare->children[3] == NULL) 00473 { 00474 return_string = make_full_ref_name(NULL, NULL, NULL, var_declare->children[0]->types.identifier, var_declare->children[2]->types.number.value+bit); 00475 } 00476 else if (var_declare->children[3] != NULL) 00477 { 00478 /* MEMORY output */ 00479 oassert(FALSE); 00480 } 00481 00482 return return_string; 00483 }
int get_range | ( | ast_node_t * | first_node | ) |
Definition at line 336 of file ast_util.c.
00337 { 00338 long temp_value; 00339 /* look at the first item to see if it has a range */ 00340 if (first_node->children[1] != NULL) 00341 { 00342 /* IF the first element in the list has a second element...that is the range */ 00343 oassert(first_node->children[2] != NULL); // the third element should be a value 00344 oassert((first_node->children[1]->type == NUMBERS) && (first_node->children[2]->type == NUMBERS)); // should be numbers 00345 if(first_node->children[1]->types.number.value < first_node->children[2]->types.number.value) 00346 { 00347 /* swap them around */ 00348 temp_value = first_node->children[1]->types.number.value; 00349 first_node->children[1]->types.number.value = first_node->children[2]->types.number.value; 00350 first_node->children[2]->types.number.value = temp_value; 00351 } 00352 00353 return abs(first_node->children[1]->types.number.value - first_node->children[2]->types.number.value + 1); // 1:0 is 2 spots 00354 } 00355 return -1; // indicates no range 00356 }
void make_concat_into_list_of_strings | ( | ast_node_t * | concat_top | ) |
Definition at line 362 of file ast_util.c.
00363 { 00364 int i, j; 00365 00366 concat_top->types.concat.num_bit_strings = 0; 00367 concat_top->types.concat.bit_strings = NULL; 00368 00369 /* recursively do all embedded concats */ 00370 for (i = 0; i < concat_top->num_children; i++) 00371 { 00372 if (concat_top->children[i]->type == CONCATENATE) 00373 { 00374 make_concat_into_list_of_strings(concat_top->children[i]); 00375 } 00376 } 00377 00378 for (i = 0; i < concat_top->num_children; i++) 00379 { 00380 if (concat_top->children[i]->type == IDENTIFIERS) 00381 { 00382 char *temp_string = make_full_ref_name(NULL, NULL, NULL, concat_top->children[i]->types.identifier, -1); 00383 long sc_spot; 00384 00385 if ((sc_spot = sc_lookup_string(local_symbol_table_sc, temp_string)) == -1) 00386 { 00387 error_message(NETLIST_ERROR, concat_top->line_number, concat_top->file_number, "Missing declaration of this symbol %s\n", temp_string); 00388 } 00389 free(temp_string); 00390 00391 if (((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[1] == NULL) 00392 { 00393 concat_top->types.concat.num_bit_strings ++; 00394 concat_top->types.concat.bit_strings = (char**)realloc(concat_top->types.concat.bit_strings, sizeof(char*)*(concat_top->types.concat.num_bit_strings)); 00395 concat_top->types.concat.bit_strings[concat_top->types.concat.num_bit_strings-1] = get_name_of_pin_at_bit(concat_top->children[i], -1); 00396 } 00397 else if (((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[3] == NULL) 00398 { 00399 /* reverse thorugh the range since highest bit in index will be lower in the string indx */ 00400 for (j = ((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[1]->types.number.value - ((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[2]->types.number.value; j >= 0; j--) 00401 { 00402 concat_top->types.concat.num_bit_strings ++; 00403 concat_top->types.concat.bit_strings = (char**)realloc(concat_top->types.concat.bit_strings, sizeof(char*)*(concat_top->types.concat.num_bit_strings)); 00404 concat_top->types.concat.bit_strings[concat_top->types.concat.num_bit_strings-1] = get_name_of_pin_at_bit(concat_top->children[i], j); 00405 } 00406 } 00407 else if (((ast_node_t*)local_symbol_table_sc->data[sc_spot])->children[3] != NULL) 00408 { 00409 oassert(FALSE); 00410 } 00411 00412 } 00413 else if (concat_top->children[i]->type == ARRAY_REF) 00414 { 00415 concat_top->types.concat.num_bit_strings ++; 00416 concat_top->types.concat.bit_strings = (char**)realloc(concat_top->types.concat.bit_strings, sizeof(char*)*(concat_top->types.concat.num_bit_strings)); 00417 concat_top->types.concat.bit_strings[concat_top->types.concat.num_bit_strings-1] = get_name_of_pin_at_bit(concat_top->children[i], 0); 00418 } 00419 else if (concat_top->children[i]->type == RANGE_REF) 00420 { 00421 oassert(concat_top->children[i]->children[1]->types.number.value >= concat_top->children[i]->children[2]->types.number.value); 00422 /* reverse thorugh the range since highest bit in index will be lower in the string indx */ 00423 for (j = concat_top->children[i]->children[1]->types.number.value - concat_top->children[i]->children[2]->types.number.value; j >= 0; j--) 00424 { 00425 concat_top->types.concat.num_bit_strings ++; 00426 concat_top->types.concat.bit_strings = (char**)realloc(concat_top->types.concat.bit_strings, sizeof(char*)*(concat_top->types.concat.num_bit_strings)); 00427 concat_top->types.concat.bit_strings[concat_top->types.concat.num_bit_strings-1] = get_name_of_pin_at_bit(concat_top->children[i], ((concat_top->children[i]->children[1]->types.number.value - concat_top->children[i]->children[2]->types.number.value))-j); 00428 } 00429 } 00430 else if (concat_top->children[i]->type == NUMBERS) 00431 { 00432 if(concat_top->children[i]->types.number.base == DEC) 00433 { 00434 error_message(NETLIST_ERROR, concat_top->line_number, concat_top->file_number, "Concatenation can't include decimal numbers due to conflict on bits\n"); 00435 } 00436 00437 /* forward through list since 0th bit of a number (get_name_of_pin) is the msb */ 00438 for (j = 0; j < concat_top->children[i]->types.number.binary_size; j++) 00439 { 00440 concat_top->types.concat.num_bit_strings ++; 00441 concat_top->types.concat.bit_strings = (char**)realloc(concat_top->types.concat.bit_strings, sizeof(char*)*(concat_top->types.concat.num_bit_strings)); 00442 concat_top->types.concat.bit_strings[concat_top->types.concat.num_bit_strings-1] = get_name_of_pin_at_bit(concat_top->children[i], j); 00443 } 00444 } 00445 else if (concat_top->children[i]->type == CONCATENATE) 00446 { 00447 /* forward through list since we build concatenate list in idx order of MSB at index 0 and LSB at index list_size */ 00448 for (j = 0; j < concat_top->children[i]->types.concat.num_bit_strings; j++) 00449 { 00450 concat_top->types.concat.num_bit_strings ++; 00451 concat_top->types.concat.bit_strings = (char**)realloc(concat_top->types.concat.bit_strings, sizeof(char*)*(concat_top->types.concat.num_bit_strings)); 00452 concat_top->types.concat.bit_strings[concat_top->types.concat.num_bit_strings-1] = get_name_of_pin_at_bit(concat_top->children[i], j); 00453 } 00454 } 00455 } 00456 }