90#define IS_IDENTIFIER(x) (0 == strcmp(identifier, x))
92#define IS_NAPA_PREFIX() (0 == strncmp(identifier, "napa_", (size_t) 5))
93#define IS_DEBUG_PREFIX() (0 == strncmp(identifier, "DEBUG_", (size_t) 6))
94#define IS_COMPILE_PREFIX() (0 == strncmp(identifier, "COMPILE_", (size_t) 8))
106 return (
int) (-1 >=
Node_List[num].errflag);
114void strcpy_alloc(
char **dest,
const char *sour,
const unsigned long *mlin,
const unsigned long *mfil) {
115 *dest = (
char*) malloc((
size_t) (
LENGTH(sour) + 1L));
116 if ((
char*) NULL == *dest) {
118 (void) fprintf(
STDERR,
" dynamic memory allocation error\n");
121 (void) strcpy(*dest, sour);
129void strcpy_realloc(
char **dest,
const char *sour,
const unsigned long *mlin,
const unsigned long *mfil) {
130 if ((
char*) NULL == *dest) {
132 (void) fprintf(
STDERR,
" impossible to reallocate memory for something not yet allocated\n");
133 (void) fprintf(
STDERR,
" when processing data <%s>\n", sour);
137 *dest = (
char*) NULL;
138 *dest = (
char*) malloc((
size_t) (
LENGTH(sour) + 1L));
139 if ((
char*) NULL == *dest) {
141 (void) fprintf(
STDERR,
" dynamic memory allocation error during reallocation when processing data <%s>\n", sour);
144 (void) strcpy(*dest, sour);
152 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
153 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
154 (void) fprintf(
STDERR,
" too many aliases (current max = %ld)\n",
MAXALIASES);
165 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
166 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
167 (void) fprintf(
STDERR,
" too many node arrays (current max = %ld)\n",
MAXARRAYS);
178 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
179 (void) fprintf(
STDERR,
" (%s / update) internal array overflow!", kind);
180 (void) fprintf(
STDERR,
" assert instruction is overflowing the update table\n");
191 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
192 (void) fprintf(
STDERR,
" (%s / update) internal array overflow!", kind);
193 (void) fprintf(
STDERR,
" call instruction is overflowing the update table\n");
204 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
205 (void) fprintf(
STDERR,
" (%s) internal command line overflow!", kind);
206 (void) fprintf(
STDERR,
" too many parameters in 'command_line' instructions (current max = %ld)\n",
MAXCMDLINES);
217 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
218 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
230 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
231 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
243 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
244 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
245 (void) fprintf(
STDERR,
" too many debug instructions (current max = %ld)\n",
MAXDEBUGS);
256 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
257 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
258 (void) fprintf(
STDERR,
" too many declare instructions (current max = %ld)\n",
MAXDECLARES);
269 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
270 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
271 (void) fprintf(
STDERR,
" too many user's directives (current max = %ld)\n",
MAXDIRS);
282 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
283 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
284 (void) fprintf(
STDERR,
" too many export variables (current max = %ld)\n",
MAXEXPORTS);
295 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
296 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
297 (void) fprintf(
STDERR,
" too many different cells (current max = %ld)\n",
MAXFILECELLS);
309 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
310 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
311 (void) fprintf(
STDERR,
" too many external functions (current max = %ld)\n",
MAXFUNCTIONS);
322 static int flag =
false;
325 (void) fprintf(
STDERR,
"\nNAPA Compiler Warning:\n");
326 (void) fprintf(
STDERR,
" (%s) large number of generators!", kind);
327 (void) fprintf(
STDERR,
" consider to review the number of authorized instances (current max = %ld)\n",
MAXINSTANCES);
336 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
337 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
338 (void) fprintf(
STDERR,
" too many groups of postprocess functions (current max = %ld)\n",
MAXGROUPS);
349 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
350 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
351 (void) fprintf(
STDERR,
" too many header files (current max = %ld)\n",
MAXHEADERS);
362 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
363 (void) fprintf(
STDERR,
" (%s / var) internal array overflow!", kind);
364 (void) fprintf(
STDERR,
" %s instruction is overflowing the var table\n", kind);
375 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
376 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
377 (void) fprintf(
STDERR,
" too many node injections (current max = %ld)\n",
MAXINJECTS);
388 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
389 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
390 (void) fprintf(
STDERR,
" cell name registering overflow (current max = %ld)\n",
MAXINSTANCES);
401 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
402 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
403 (void) fprintf(
STDERR,
" too many input and output instructions (current max = %ld)\n",
MAXIOS);
415 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
416 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
417 (void) fprintf(
STDERR,
" too many nodes (current max = %ld)\n",
MAXNODES);
429 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
430 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
431 (void) fprintf(
STDERR,
" too many opcodes (current max = %ld)\n",
MAXOPCODES);
442 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
443 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
444 (void) fprintf(
STDERR,
" too many postprocessing functions (current max = %ld)\n",
MAXPOSTS);
455 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
456 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
457 (void) fprintf(
STDERR,
" array of pointers name registering overflow (current max = %ld)\n",
MAXRECORDS);
468 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
469 (void) fprintf(
STDERR,
" (%s / update) internal array overflow!", kind);
470 (void) fprintf(
STDERR,
" call instruction is overflowing the update table\n");
481 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
482 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
483 (void) fprintf(
STDERR,
" too many simulation segments (current max = %ld)\n",
MAXSEGMENTS);
494 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
495 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
496 (void) fprintf(
STDERR,
" too many stuck nodes (current max = %ld)\n",
MAXSTUCKS);
507 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
508 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
509 (void) fprintf(
STDERR,
" too many tool functions (current max = %ld)\n",
MAXUSERTOOLS);
520 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
521 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
522 (void) fprintf(
STDERR,
" too many update of variables (current max = %ld)\n",
MAXUPDATES);
534 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
535 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
536 (void) fprintf(
STDERR,
" too many user functions (current max = %ld)\n",
MAXUSERTOOLS);
547 (void) fprintf(
STDERR,
"\nNAPA Compiler Error:\n");
548 (void) fprintf(
STDERR,
" (%s) internal array overflow!", kind);
549 (void) fprintf(
STDERR,
" too many variables (current max = %ld)\n",
MAXVARS);
574 num = strcmp(*(
char**) a, *(
char**) b);
667 (void) strcpy(tok,
Var_List[v].name1);
674 (void) strcpy(tok,
Var_List[v].name2);
724 char *str = (
char*) NULL;
737 (void) strcpy(tok1, identifier);
738 str = strchr(tok1,
'.');
739 if ((
char*) NULL == str) {
742 (void) strcpy(tok2, str + 1);
745 if ((1 != sscanf(tok2,
"%li", &m)) || (1L > m)) {
747 (void) fprintf(
STDERR,
" <%s.%s> is not a correct identifier, <%s> must be a strictly positive integer\n",tok1,tok2,tok2);
759 (void) fprintf(
STDERR,
" there is no element #%s in array <%s>\n", tok2, tok1);
818 (void) strcpy(tok,
Var_List[v].name1);
829 (void) strcpy(tok,
Var_List[v].name2);
861 char *str = (
char*) NULL;
874 (void) strcpy(tok1, identifier);
875 str = strchr(tok1,
'.');
876 if ((
char*) NULL == str) {
879 (void) strcpy(tok2, str + 1);
882 if ((1 != sscanf(tok2,
"%li", &m)) || (1L > m)) {
884 (void) fprintf(
STDERR,
" <%s.%s> is not a correct identifier, <%s> must be a strictly positive integer\n",tok1,tok2,tok2);
896 (void) fprintf(
STDERR,
" there is no element #%s in array <%s>\n", tok2, tok1);
920 long i, j, k, m, n, u, v;
921 char *nam = (
char*) NULL;
922 char *str = (
char*) NULL;
931 if ((0 == strncmp(nam,
"$call$", (
size_t) 6)) || (0 == strncmp(nam,
"$null$", (
size_t) 6))
932 || (0 == strncmp(nam,
"$assert$", (
size_t) 8)) || (0 == strncmp(nam,
"$restart$", (
size_t) 9))) {
993 if ((0 == strcmp(nam,
Var_List[v].name1)) || (0 == strcmp(nam,
Var_List[v].name2))) {
1131 char *str = (
char*) NULL;
1133 unsigned long long x;
1164 if ((
'0' == *identifier) && (
'x' == *(identifier+1))) {
1165 if (1 == sscanf(identifier,
"%llux", &x)) {
1169 if (1 != sscanf(identifier,
"%lf", &r)) {
1170 if ((
'"' == identifier[0]) && (
'"' == identifier[
LENGTH(identifier)-1L])) {
1180 while (
'\0' != *str) {
1204 if ((0 == strcmp(identifier,
"LOOP_INDEX"))
1205 || (0 == strcmp(identifier,
"ABS_LOOP_INDEX"))
1206 || (0 == strcmp(identifier,
"REL_LOOP_INDEX"))
1207 || (0 == strcmp(identifier,
"RANDOM_SEED"))) {
1210 if ((0 == strcmp(identifier,
"ABS_TIME"))
1211 || (0 == strcmp(identifier,
"REF_TIME"))
1212 || (0 == strcmp(identifier,
"REL_TIME"))
1213 || (0 == strcmp(identifier,
"TIME"))
1214 || (0 == strcmp(identifier,
"WALL_CLOCK"))
1215 || (0 == strcmp(identifier,
"SIM_RATE"))
1216 || (0 == strcmp(identifier,
"FS"))
1217 || (0 == strcmp(identifier,
"FSL"))) {
1349 }
else if (
IS_IDENTIFIER(
"IO_COMMAND_NAME" )) {
return true;
1360 }
else {
return false;
1396 }
else if (
IS_IDENTIFIER(
"napa_array_setup" )) {
return true;
1397 }
else if (
IS_IDENTIFIER(
"napa_check_directives")) {
return true;
1400 }
else if (
IS_IDENTIFIER(
"napa_record_manager" )) {
return true;
1401 }
else if (
IS_IDENTIFIER(
"napa_record_setup" )) {
return true;
1460 }
else {
return false;
1502 }
else if (
IS_IDENTIFIER(
"napa_short_title")) {
return true;
1522 }
else {
return false;
1704 }
else {
return false;
1743 }
else if (
IS_IDENTIFIER(
"NUM_OF_SEGMENTS" )) {
return true;
1744 }
else if (
IS_IDENTIFIER(
"NUM_OF_TIME_OUTPUTS")) {
return true;
1762 }
else {
return false;
1783 }
else {
return false;
void print_error_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
void increment_debug_number(const char *kind)
long constant_type(char *identifier)
int is_an_operator(const char *identifier)
void increment_call_number(const char *kind)
long get_type(char *identifier)
void increment_post_number(const char *kind)
int is_a_modifier(const char *identifier)
long alias_id(const char *identifier)
#define IS_DEBUG_PREFIX()
long postprocess_id(const char *identifier)
void increment_opcode_number(const char *kind)
void increment_array_number(const char *kind)
void mark_updates_if_constant(void)
void swap_nodes(long i, long j)
void increment_generator_number(const char *kind)
int variable_update_block(void)
void increment_function_number(const char *kind)
void increment_node_number(const char *kind)
void increment_alias_number(const char *kind)
void increment_declare_number(const char *kind)
void increment_assert_number(const char *kind)
long user_id(const char *identifier)
void increment_record_number(const char *kind)
void increment_IO_number(const char *kind)
int is_a_constant_or_a_macro_constant(const char *identifier)
long update_id(const char *identifier, long num)
long cmdline_id(const char *identifier)
#define IS_COMPILE_PREFIX()
void increment_comment_number(const char *kind)
void increment_cmdline_number(const char *kind)
void increment_tool_number(const char *kind)
long usertool_num(const char *nam)
void increment_inject_number(const char *kind)
void swap_records(long i, long j)
void strcpy_alloc(char **dest, const char *sour, const unsigned long *mlin, const unsigned long *mfil)
int is_an_instruction(const char *identifier)
long declare_id(const char *identifier)
int is_a_known_function(const char *identifier)
void increment_init_number(const char *kind)
int is_a_known_pure_function(const char *identifier)
long array_id(const char *identifier)
long directive_id(const char *identifier)
long node_kind(const char *identifier)
long op_id(const char *identifier)
void increment_export_number(const char *kind)
void swap_vars(long i, long j)
void increment_void_number(void)
int is_a_keyword(const char *identifier)
void increment_restart_number(const char *kind)
void increment_directive_number(const char *kind)
int time_output_block(void)
void increment_const_number(void)
long array_name_id(const char *identifier)
long node_id(const char *identifier)
long var_id(const char *identifier)
void increment_filecell_number(const char *kind)
void increment_usertool_number(const char *kind)
void swap_updates(long i, long j)
int is_node_flagged(long num)
long debug_id(const char *identifier)
void increment_common_number(const char *kind)
int sort_names(const void *a, const void *b)
void increment_var_number(const char *kind)
void increment_segment_number(const char *kind)
int node_update_block(void)
void increment_update_number(const char *kind)
long record_id(const char *identifier)
void increment_instance_number(const char *kind)
void increment_group_number(const char *kind)
void increment_stuck_number(const char *kind)
void swap_delay_inputs(long i, long j)
void strcpy_realloc(char **dest, const char *sour, const unsigned long *mlin, const unsigned long *mfil)
void increment_header_number(const char *kind)
void mark_constants(void)
EXTERN VAR_TYPE Var_List[2047L]
EXTERN RECORD_TYPE Record_List[127L]
EXTERN long Num_Functions
EXTERN ARRAY_TYPE Array_List[63L]
EXTERN DECLARE_TYPE Declare_List[1023L]
EXTERN POST_TYPE Post_List[63L]
EXTERN NODE_TYPE Node_List[4095L]
#define DIFFERENTIATOR_KIND
EXTERN long Num_UserTools
EXTERN USERTOOL_TYPE UserTool_List[511L]
EXTERN int Tool_Index_Flag
EXTERN ALIAS_TYPE Alias_List[127L]
EXTERN DIRECTIVE_TYPE Directive_List[255L]
EXTERN DEBUG_TYPE Debug_List[63L]
EXTERN long Num_Directives
#define MAXDECLARECOMMONS
EXTERN OPCODE_TYPE Opcode_List[127L]
EXTERN long Num_FileCells
EXTERN long Delay_Input[4095L]
EXTERN long Num_Instances
EXTERN CMDLINE_TYPE Cmdline_List[63L]
EXTERN SEGMENT_TYPE Segment_List[127L]
EXTERN long Num_Generators
EXTERN long Num_Declare_Commons
#define DIGITAL_DATA_TYPE
EXTERN UPDATE_TYPE Update_List[2047L]
void print_error_banner_and_exit(void)
char * get_token(char *str, char *tok, long keep_quotes)