From c1d0800d873af68a87df6f7ace0e656323d7fc0c Mon Sep 17 00:00:00 2001 From: Rutger Hofman Date: Sun, 3 May 2009 14:25:49 +0000 Subject: [PATCH] indent the C code in .y and .l files git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1553 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/src/bsdl/bsdl_bison.y | 844 ++++++++++++++++++----------------- urjtag/src/bsdl/bsdl_flex.l | 205 +++++---- urjtag/src/bsdl/vhdl_bison.y | 742 +++++++++++++++--------------- urjtag/src/bsdl/vhdl_flex.l | 422 +++++++++--------- urjtag/src/svf/svf.c | 2 +- urjtag/src/svf/svf_bison.y | 84 ++-- urjtag/src/svf/svf_flex.l | 283 ++++++------ 7 files changed, 1355 insertions(+), 1227 deletions(-) diff --git a/urjtag/src/bsdl/bsdl_bison.y b/urjtag/src/bsdl/bsdl_bison.y index 2498808a..fc0db6e9 100644 --- a/urjtag/src/bsdl/bsdl_bison.y +++ b/urjtag/src/bsdl/bsdl_bison.y @@ -148,38 +148,39 @@ int yylex (YYSTYPE *, void *); #define ERROR_LIMIT 0 #define BUMP_ERROR \ do { \ - if (urj_bsdl_flex_postinc_compile_errors( priv_data->scanner ) > ERROR_LIMIT) \ + if (urj_bsdl_flex_postinc_compile_errors (priv_data->scanner) > ERROR_LIMIT) \ { \ - Give_Up_And_Quit( priv_data ); \ + Give_Up_And_Quit (priv_data); \ YYABORT; \ } \ } while (0) #else #define BUMP_ERROR \ do { \ - Give_Up_And_Quit( priv_data ); \ + Give_Up_And_Quit (priv_data); \ YYABORT; \ } while (0) #endif -static void Print_Error( urj_bsdl_parser_priv_t *, const char * ); -static void Print_Warning( urj_bsdl_parser_priv_t *, const char * ); -static void Give_Up_And_Quit( urj_bsdl_parser_priv_t * ); +static void Print_Error (urj_bsdl_parser_priv_t *, const char *); +static void Print_Warning (urj_bsdl_parser_priv_t *, const char *); +static void Give_Up_And_Quit (urj_bsdl_parser_priv_t *); /* semantic functions */ -static void add_instruction( urj_bsdl_parser_priv_t *, char *, char * ); -static void ac_set_register( urj_bsdl_parser_priv_t *, char *, int ); -static void ac_add_instruction( urj_bsdl_parser_priv_t *, char * ); -static void ac_apply_assoc( urj_bsdl_parser_priv_t * ); -static void prt_add_name( urj_bsdl_parser_priv_t *, char * ); -static void prt_add_bit( urj_bsdl_parser_priv_t * ); -static void prt_add_range( urj_bsdl_parser_priv_t *, int, int ); -static void ci_no_disable( urj_bsdl_parser_priv_t * ); -static void ci_set_cell_spec_disable( urj_bsdl_parser_priv_t *, int, int, int ); -static void ci_set_cell_spec( urj_bsdl_parser_priv_t *, int, char * ); -static void ci_append_cell_info( urj_bsdl_parser_priv_t *, int ); - -void yyerror( urj_bsdl_parser_priv_t *, const char * ); +static void add_instruction (urj_bsdl_parser_priv_t *, char *, char *); +static void ac_set_register (urj_bsdl_parser_priv_t *, char *, int); +static void ac_add_instruction (urj_bsdl_parser_priv_t *, char *); +static void ac_apply_assoc (urj_bsdl_parser_priv_t *); +static void prt_add_name (urj_bsdl_parser_priv_t *, char *); +static void prt_add_bit (urj_bsdl_parser_priv_t *); +static void prt_add_range (urj_bsdl_parser_priv_t *, int, int); +static void ci_no_disable (urj_bsdl_parser_priv_t *); +static void ci_set_cell_spec_disable (urj_bsdl_parser_priv_t *, int, int, + int); +static void ci_set_cell_spec (urj_bsdl_parser_priv_t *, int, char *); +static void ci_append_cell_info (urj_bsdl_parser_priv_t *, int); + +void yyerror (urj_bsdl_parser_priv_t *, const char *); %} %union { @@ -264,7 +265,7 @@ BSDL_Statement : BSDL_Pin_Map | ISC_Extension | error { - Print_Error( priv_data, _("Unsupported BSDL construct found") ); + Print_Error (priv_data, _("Unsupported BSDL construct found")); BUMP_ERROR; YYABORT; } @@ -279,7 +280,7 @@ BSDL_Map_String : PIN_MAP_STRING Pin_Mapping | BSDL_Map_String COMMA Pin_Mapping ; Pin_Mapping : IDENTIFIER COLON Physical_Pin_Desc - { free( $1 ); } + { free ($1); } ; Physical_Pin_Desc : Physical_Pin | LPAREN Physical_Pin_List RPAREN @@ -288,9 +289,9 @@ Physical_Pin_List : Physical_Pin | Physical_Pin_List COMMA Physical_Pin ; Physical_Pin : IDENTIFIER - { free( $1 ); } + { free ($1); } | IDENTIFIER LPAREN DECIMAL_NUMBER RPAREN - { free( $1 ); } + { free ($1); } | DECIMAL_NUMBER ; @@ -326,23 +327,23 @@ BSDL_Opcode_Table : Opcode_Desc | BSDL_Opcode_Table COMMA Opcode_Desc | error { - Print_Error( priv_data, - _("Error in Instruction_Opcode attribute statement") ); + Print_Error (priv_data, + _("Error in Instruction_Opcode attribute statement")); BUMP_ERROR; YYABORT; } ; Opcode_Desc : IDENTIFIER LPAREN Binary_Pattern_List RPAREN - { add_instruction( priv_data, $1, $3 ); } + { add_instruction (priv_data, $1, $3); } ; Binary_Pattern_List : Binary_Pattern { $$ = $1; } | Binary_Pattern_List COMMA Binary_Pattern { - Print_Warning( priv_data, - _("Multiple opcode patterns are not supported, first pattern will be used") ); + Print_Warning (priv_data, + _("Multiple opcode patterns are not supported, first pattern will be used")); $$ = $1; - free( $3 ); + free ($3); } ; Binary_Pattern : BINARY_PATTERN @@ -351,17 +352,17 @@ Binary_Pattern : BINARY_PATTERN /****************************************************************************/ BSDL_Inst_Capture : INSTRUCTION_CAPTURE BIN_X_PATTERN - { free( $2 ); } + { free ($2); } ; /****************************************************************************/ BSDL_Inst_Disable : INSTRUCTION_DISABLE IDENTIFIER - { free( $2 ); } + { free ($2); } ; /****************************************************************************/ BSDL_Inst_Guard : INSTRUCTION_GUARD IDENTIFIER - { free( $2 ); } + { free ($2); } ; /****************************************************************************/ @@ -371,13 +372,13 @@ Private_Opcode_List : Private_Opcode | Private_Opcode_List COMMA Private_Opcode | error { - Print_Error( priv_data, _("Error in Opcode List") ); + Print_Error (priv_data, _("Error in Opcode List")); BUMP_ERROR; YYABORT; } ; Private_Opcode : IDENTIFIER - { free( $1 ); } + { free ($1); } ; /****************************************************************************/ @@ -397,52 +398,52 @@ Register_String : Register_Assoc | Register_String COMMA Register_Assoc ; Register_Assoc : Register_Decl LPAREN Reg_Opcode_List RPAREN - { ac_apply_assoc( priv_data ); } + { ac_apply_assoc (priv_data); } ; Register_Decl : Standard_Reg - { ac_set_register( priv_data, $1, 0 ); } + { ac_set_register (priv_data, $1, 0); } | IDENTIFIER LBRACKET DECIMAL_NUMBER RBRACKET - { ac_set_register( priv_data, $1, $3 ); } + { ac_set_register (priv_data, $1, $3); } ; Standard_Reg : BOUNDARY - { $$ = strdup( "BOUNDARY" ); } + { $$ = strdup ("BOUNDARY"); } | BYPASS - { $$ = strdup( "BYPASS" ); } + { $$ = strdup ("BYPASS"); } | IDCODE - { $$ = strdup( "IDCODE" ); } + { $$ = strdup ("IDCODE"); } | USERCODE - { $$ = strdup( "USERCODE" ); } + { $$ = strdup ("USERCODE"); } | DEVICE_ID - { $$ = strdup( "DEVICE_ID" ); } + { $$ = strdup ("DEVICE_ID"); } ; Reg_Opcode_List : Reg_Opcode | Reg_Opcode_List COMMA Reg_Opcode ; Instruction_Name : BYPASS - { $$ = strdup( "BYPASS" ); } + { $$ = strdup ("BYPASS"); } | CLAMP - { $$ = strdup( "CLAMP" ); } + { $$ = strdup ("CLAMP"); } | EXTEST - { $$ = strdup( "EXTEST" ); } + { $$ = strdup ("EXTEST"); } | HIGHZ - { $$ = strdup( "HIGHZ" ); } + { $$ = strdup ("HIGHZ"); } | IDCODE - { $$ = strdup( "IDCODE" ); } + { $$ = strdup ("IDCODE"); } | INTEST - { $$ = strdup( "INTEST" ); } + { $$ = strdup ("INTEST"); } | PRELOAD - { $$ = strdup( "PRELOAD" ); } + { $$ = strdup ("PRELOAD"); } | RUNBIST - { $$ = strdup( "RUNBIST" ); } + { $$ = strdup ("RUNBIST"); } | SAMPLE - { $$ = strdup( "SAMPLE" ); } + { $$ = strdup ("SAMPLE"); } | USERCODE - { $$ = strdup( "USERCODE" ); } + { $$ = strdup ("USERCODE"); } | IDENTIFIER { $$ = $1; } ; Reg_Opcode : Instruction_Name - { ac_add_instruction( priv_data, $1 ); } + { ac_add_instruction (priv_data, $1); } ; @@ -457,37 +458,37 @@ BSDL_Boundary_Register : BOUNDARY_REGISTER BSDL_Cell_Table BSDL_Cell_Table : Cell_Entry | BSDL_Cell_Table COMMA Cell_Entry | error - {Print_Error( priv_data, _("Error in Boundary Cell description") ); + {Print_Error (priv_data, _("Error in Boundary Cell description")); BUMP_ERROR; YYABORT; } ; Cell_Entry : DECIMAL_NUMBER LPAREN Cell_Info RPAREN - { ci_append_cell_info( priv_data, $1 ); } + { ci_append_cell_info (priv_data, $1); } ; Cell_Info : Cell_Spec - { ci_no_disable( priv_data ); } + { ci_no_disable (priv_data); } | Cell_Spec COMMA Disable_Spec ; Cell_Spec : IDENTIFIER COMMA Port_Name COMMA Cell_Function COMMA Safe_Value { - free( $1 ); - ci_set_cell_spec( priv_data, $5, $7 ); + free ($1); + ci_set_cell_spec (priv_data, $5, $7); } ; Port_Name : IDENTIFIER { - prt_add_name( priv_data, $1 ); - prt_add_bit( priv_data ); + prt_add_name (priv_data, $1); + prt_add_bit (priv_data); } | IDENTIFIER LPAREN DECIMAL_NUMBER RPAREN { - prt_add_name( priv_data, $1 ); - prt_add_range( priv_data, $3, $3 ); + prt_add_name (priv_data, $1); + prt_add_range (priv_data, $3, $3); } | ASTERISK { - prt_add_name( priv_data, strdup( "*" ) ); - prt_add_bit( priv_data ); + prt_add_name (priv_data, strdup ("*")); + prt_add_bit (priv_data); } ; Cell_Function : INPUT @@ -515,14 +516,14 @@ Safe_Value : IDENTIFIER { char *tmp; /* @@@@ ToDo check malloc result RFHH */ - tmp = malloc( 2 ); - snprintf( tmp, 2, "%i", $1 ); + tmp = malloc (2); + snprintf (tmp, 2, "%i", $1); tmp[1] = '\0'; $$ = tmp; } ; Disable_Spec : DECIMAL_NUMBER COMMA DECIMAL_NUMBER COMMA Disable_Value - { ci_set_cell_spec_disable( priv_data, $1, $3, $5 ); } + { ci_set_cell_spec_disable (priv_data, $1, $3, $5); } ; Disable_Value : Z { $$ = Z; } @@ -542,13 +543,13 @@ Disable_Value : Z BSDL_Compliance_Patterns : COMPLIANCE_PATTERNS BSDL_Compliance_Pattern ; BSDL_Compliance_Pattern : LPAREN Physical_Pin_List RPAREN - { urj_bsdl_flex_set_bin_x( priv_data->scanner ); } + { urj_bsdl_flex_set_bin_x (priv_data->scanner); } LPAREN Bin_X_Pattern_List RPAREN ; Bin_X_Pattern_List : BIN_X_PATTERN - { free( $1 ); } + { free ($1); } | Bin_X_Pattern_List COMMA BIN_X_PATTERN - { free( $3 ); } + { free ($3); } ; /****************************************************************************/ @@ -582,7 +583,7 @@ Pin_Behavior_Option : HIGHZ | CLAMP | error { - Print_Error( priv_data, _("Error in ISC_Pin_Behavior Definition") ); + Print_Error (priv_data, _("Error in ISC_Pin_Behavior Definition")); BUMP_ERROR; YYABORT; } @@ -594,26 +595,26 @@ Fixed_Pin_List : Port_Id | Fixed_Pin_List COMMA Port_Id | error { - Print_Error( priv_data, _("Error in ISC_Fixed_System_Pins Definition") ); + Print_Error (priv_data, _("Error in ISC_Fixed_System_Pins Definition")); BUMP_ERROR; YYABORT; } ; Port_Id : IDENTIFIER - { free( $1 ); } + { free ($1); } | IDENTIFIER LPAREN DECIMAL_NUMBER RPAREN - { free( $1 ); } + { free ($1); } ; /****************************************************************************/ ISC_Status : ISC_STATUS Status_Modifier IMPLEMENTED ; Status_Modifier : /* empty */ | IDENTIFIER - { free( $1 ); } + { free ($1); } ; /****************************************************************************/ ISC_Blank_Usercode : ISC_BLANK_USERCODE BIN_X_PATTERN - { free( $2 ); } + { free ($2); } ; /****************************************************************************/ ISC_Security : ISC_SECURITY Protection_Spec @@ -621,7 +622,7 @@ ISC_Security : ISC_SECURITY Protection_Spec Protection_Spec : Read_Spec COMMA Program_Spec COMMA Erase_Spec COMMA Key_Spec | error { - Print_Error( priv_data, _("Error in ISC_Security Definition") ); + Print_Error (priv_data, _("Error in ISC_Security Definition")); BUMP_ERROR; YYABORT; } @@ -655,29 +656,29 @@ Flow_Definition : Flow_Descriptor | Flow_Descriptor Terminate_Block | error { - Print_Error( priv_data, _("Error in ISC_Flow Definition") ); + Print_Error (priv_data, _("Error in ISC_Flow Definition")); BUMP_ERROR; YYABORT; } ; Flow_Descriptor : IDENTIFIER - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name UNPROCESSED - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name UNPROCESSED EXIT_ON_ERROR - { free( $1 ); } + { free ($1); } | IDENTIFIER UNPROCESSED - { free( $1 ); } + { free ($1); } | IDENTIFIER UNPROCESSED EXIT_ON_ERROR - { free( $1 ); } + { free ($1); } | IDENTIFIER EXIT_ON_ERROR - { free( $1 ); } + { free ($1); } ; Data_Name : LPAREN Standard_Data_Name RPAREN | LPAREN IDENTIFIER RPAREN - { free( $2 ); } + { free ($2); } ; Standard_Data_Name : ARRAY | USERCODE | SECURITY | IDCODE | PRELOAD ; @@ -704,25 +705,25 @@ Loop_Activity_List : Activity | Loop_Activity_List Activity ; Activity : LPAREN Instruction_Name Wait_Specification RPAREN - { free( $2 ); } + { free ($2); } | LPAREN Instruction_Name Update_Field_List Wait_Specification RPAREN - { free( $2 ); } + { free ($2); } | LPAREN Instruction_Name Wait_Specification Capture_Field_List RPAREN - { free( $2 ); } + { free ($2); } | LPAREN Instruction_Name Update_Field_List Wait_Specification Capture_Field_List RPAREN - { free( $2 ); } + { free ($2); } ; Update_Field_List : Update_Field | Update_Field_List COMMA Update_Field ; Update_Field : DECIMAL_NUMBER | DECIMAL_NUMBER COLON - { urj_bsdl_flex_set_hex( priv_data->scanner ); } + { urj_bsdl_flex_set_hex (priv_data->scanner); } Data_Expression - { urj_bsdl_flex_set_decimal( priv_data->scanner ); } + { urj_bsdl_flex_set_decimal (priv_data->scanner); } ; Data_Expression : HEX_STRING - { free( $1 ); } + { free ($1); } | Input_Specifier | Variable_Expression ; @@ -731,11 +732,11 @@ Variable_Expression : Variable | Variable_Update ; Variable_Assignment : Variable EQUAL - { urj_bsdl_flex_set_hex( priv_data->scanner ); } + { urj_bsdl_flex_set_hex (priv_data->scanner); } HEX_STRING { - free( $4 ); - urj_bsdl_flex_set_decimal( priv_data->scanner ); + free ($4); + urj_bsdl_flex_set_decimal (priv_data->scanner); } | Variable Input_Specifier ; @@ -749,9 +750,9 @@ Capture_Field_List : Capture_Field | Capture_Field_List COMMA Capture_Field ; Capture_Field : DECIMAL_NUMBER COLON - { urj_bsdl_flex_set_hex( priv_data->scanner ); } + { urj_bsdl_flex_set_hex (priv_data->scanner); } Capture_Field_Rest - { urj_bsdl_flex_set_decimal( priv_data->scanner ); } + { urj_bsdl_flex_set_decimal (priv_data->scanner); } ; Capture_Field_Rest : Capture_Specification | Capture_Specification CRC_Tag @@ -777,23 +778,23 @@ Wait_Specification : WAIT Duration_Specification ; Duration_Specification : Clock_Cycles | REAL_NUMBER - { free( $1 ); } + { free ($1); } | Clock_Cycles COMMA REAL_NUMBER - { free( $3 ); } + { free ($3); } ; Clock_Cycles : Port_Id DECIMAL_NUMBER ; Variable : DOLLAR IDENTIFIER - { free( $2 ); } + { free ($2); } ; Binary_Operator : PLUS - { urj_bsdl_flex_set_decimal( priv_data->scanner ); } + { urj_bsdl_flex_set_decimal (priv_data->scanner); } | MINUS - { urj_bsdl_flex_set_decimal( priv_data->scanner ); } + { urj_bsdl_flex_set_decimal (priv_data->scanner); } | SH_RIGHT - { urj_bsdl_flex_set_decimal( priv_data->scanner ); } + { urj_bsdl_flex_set_decimal (priv_data->scanner); } | SH_LEFT - { urj_bsdl_flex_set_decimal( priv_data->scanner ); } + { urj_bsdl_flex_set_decimal (priv_data->scanner); } ; Complement_Operator : TILDE ; @@ -814,12 +815,12 @@ Procedure_List : Procedure | Procedure_List COMMA Procedure ; Procedure : IDENTIFIER EQUAL LPAREN Flow_Descriptor_List RPAREN - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name EQUAL LPAREN Flow_Descriptor_List RPAREN - { free( $1 ); } + { free ($1); } | error { - Print_Error( priv_data, _("Error in ISC_Procedure Definition") ); + Print_Error (priv_data, _("Error in ISC_Procedure Definition")); BUMP_ERROR; YYABORT; } @@ -834,16 +835,16 @@ Action_List : Action | Action_List COMMA Action ; Action : IDENTIFIER EQUAL LPAREN Action_Specification_List RPAREN - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name EQUAL LPAREN Action_Specification_List RPAREN - { free( $1 ); } + { free ($1); } | IDENTIFIER PROPRIETARY EQUAL LPAREN Action_Specification_List RPAREN - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name PROPRIETARY EQUAL LPAREN Action_Specification_List RPAREN - { free( $1 ); } + { free ($1); } | error { - Print_Error( priv_data, _("Error in ISC_Action Definition") ); + Print_Error (priv_data, _("Error in ISC_Action Definition")); BUMP_ERROR; YYABORT; } @@ -852,21 +853,21 @@ Action_Specification_List : Action_Specification | Action_Specification_List COMMA Action_Specification ; Action_Specification : IDENTIFIER - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name PROPRIETARY - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name Option_Specification - { free( $1 ); } + { free ($1); } | IDENTIFIER Data_Name PROPRIETARY Option_Specification - { free( $1 ); } + { free ($1); } | IDENTIFIER PROPRIETARY - { free( $1 ); } + { free ($1); } | IDENTIFIER PROPRIETARY Option_Specification - { free( $1 ); } + { free ($1); } | IDENTIFIER Option_Specification - { free( $1 ); } + { free ($1); } ; Option_Specification : OPTIONAL | RECOMMENDED ; @@ -874,35 +875,42 @@ Option_Specification : OPTIONAL | RECOMMENDED ISC_Illegal_Exit : ISC_ILLEGAL_EXIT Exit_Instruction_List ; Exit_Instruction_List : IDENTIFIER - { free( $1 ); } + { free ($1); } | Exit_Instruction_List COMMA IDENTIFIER - { free( $3 ); } + { free ($3); } ; + %% /* End rules, begin programs */ + /*----------------------------------------------------------------------*/ -static void Print_Error( urj_bsdl_parser_priv_t *priv_data, const char *Errmess ) +static void +Print_Error (urj_bsdl_parser_priv_t *priv_data, const char *Errmess) { - urj_bsdl_msg( priv_data->jtag_ctrl->proc_mode, - BSDL_MSG_ERR, _("Line %d, %s.\n"), - priv_data->lineno, - Errmess ); + urj_bsdl_msg (priv_data->jtag_ctrl->proc_mode, + BSDL_MSG_ERR, _("Line %d, %s.\n"), + priv_data->lineno, Errmess); } + /*----------------------------------------------------------------------*/ -static void Print_Warning( urj_bsdl_parser_priv_t *priv_data, const char *Warnmess ) +static void +Print_Warning (urj_bsdl_parser_priv_t *priv_data, const char *Warnmess) { - urj_bsdl_msg( priv_data->jtag_ctrl->proc_mode, - BSDL_MSG_WARN, _("Line %d, %s.\n"), - priv_data->lineno, - Warnmess ); + urj_bsdl_msg (priv_data->jtag_ctrl->proc_mode, + BSDL_MSG_WARN, _("Line %d, %s.\n"), + priv_data->lineno, Warnmess); } + /*----------------------------------------------------------------------*/ -static void Give_Up_And_Quit( urj_bsdl_parser_priv_t *priv_data ) +static void +Give_Up_And_Quit (urj_bsdl_parser_priv_t *priv_data) { - //Print_Error( priv_data, "Too many errors" ); - urj_bsdl_flex_stop_buffer( priv_data->scanner ); + //Print_Error( priv_data, "Too many errors" ); + urj_bsdl_flex_stop_buffer (priv_data->scanner); } + /*----------------------------------------------------------------------*/ -void yyerror( urj_bsdl_parser_priv_t *priv_data, const char *error_string ) +void +yyerror (urj_bsdl_parser_priv_t *priv_data, const char *error_string) { } @@ -919,31 +927,32 @@ void yyerror( urj_bsdl_parser_priv_t *priv_data, const char *error_string ) * Returns * void ****************************************************************************/ -static void urj_bsdl_sem_init( urj_bsdl_parser_priv_t *priv ) +static void +urj_bsdl_sem_init (urj_bsdl_parser_priv_t *priv) { - urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; + urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; - jc->instr_len = -1; - jc->bsr_len = -1; - jc->conformance = URJ_BSDL_CONF_UNKNOWN; - jc->idcode = NULL; - jc->usercode = NULL; + jc->instr_len = -1; + jc->bsr_len = -1; + jc->conformance = URJ_BSDL_CONF_UNKNOWN; + jc->idcode = NULL; + jc->usercode = NULL; - jc->instr_list = NULL; + jc->instr_list = NULL; - priv->ainfo.next = NULL; - priv->ainfo.reg = NULL; - priv->ainfo.instr_list = NULL; - jc->ainfo_list = NULL; + priv->ainfo.next = NULL; + priv->ainfo.reg = NULL; + priv->ainfo.instr_list = NULL; + jc->ainfo_list = NULL; - priv->tmp_cell_info.next = NULL; - priv->tmp_cell_info.port_name = NULL; - priv->tmp_cell_info.basic_safe_value = NULL; - jc->cell_info_first = NULL; - jc->cell_info_last = NULL; + priv->tmp_cell_info.next = NULL; + priv->tmp_cell_info.port_name = NULL; + priv->tmp_cell_info.basic_safe_value = NULL; + jc->cell_info_first = NULL; + jc->cell_info_last = NULL; - priv->tmp_port_desc.names_list = NULL; - priv->tmp_port_desc.next = NULL; + priv->tmp_port_desc.names_list = NULL; + priv->tmp_port_desc.next = NULL; } @@ -958,17 +967,18 @@ static void urj_bsdl_sem_init( urj_bsdl_parser_priv_t *priv ) * Returns * void ****************************************************************************/ -static void free_instr_list( urj_bsdl_instr_elem_t *il ) +static void +free_instr_list (urj_bsdl_instr_elem_t *il) { - if (il) - { - if (il->instr) - free( il->instr ); - if (il->opcode) - free( il->opcode ); - free_instr_list( il->next ); - free( il ); - } + if (il) + { + if (il->instr) + free (il->instr); + if (il->opcode) + free (il->opcode); + free_instr_list (il->next); + free (il); + } } @@ -984,19 +994,20 @@ static void free_instr_list( urj_bsdl_instr_elem_t *il ) * Returns * void ****************************************************************************/ -static void free_ainfo_list( urj_bsdl_types_ainfo_elem_t *ai, int free_me ) +static void +free_ainfo_list (urj_bsdl_types_ainfo_elem_t *ai, int free_me) { - if (ai) - { - if (ai->reg) - free( ai->reg ); + if (ai) + { + if (ai->reg) + free (ai->reg); - free_instr_list( ai->instr_list ); - free_ainfo_list( ai->next, 1 ); + free_instr_list (ai->instr_list); + free_ainfo_list (ai->next, 1); - if (free_me) - free( ai ); - } + if (free_me) + free (ai); + } } @@ -1011,15 +1022,16 @@ static void free_ainfo_list( urj_bsdl_types_ainfo_elem_t *ai, int free_me ) * Returns * void ****************************************************************************/ -static void free_string_list( urj_bsdl_string_elem_t *sl) +static void +free_string_list (urj_bsdl_string_elem_t *sl) { - if (sl) - { - if (sl->string) - free( sl->string ); - free_string_list( sl->next ); - free( sl ); - } + if (sl) + { + if (sl->string) + free (sl->string); + free_string_list (sl->next); + free (sl); + } } @@ -1036,21 +1048,22 @@ static void free_string_list( urj_bsdl_string_elem_t *sl) * Returns * void ****************************************************************************/ -static void free_ci_list( urj_bsdl_cell_info_t *ci, int free_me ) +static void +free_ci_list (urj_bsdl_cell_info_t *ci, int free_me) { - if (ci) - { - free_ci_list( ci->next, 1 ); + if (ci) + { + free_ci_list (ci->next, 1); - if (ci->port_name) - free( ci->port_name ); + if (ci->port_name) + free (ci->port_name); - if (ci->basic_safe_value) - free( ci->basic_safe_value ); + if (ci->basic_safe_value) + free (ci->basic_safe_value); - if (free_me) - free( ci ); - } + if (free_me) + free (ci); + } } @@ -1066,39 +1079,40 @@ static void free_ci_list( urj_bsdl_cell_info_t *ci, int free_me ) * Returns * void ****************************************************************************/ -static void urj_bsdl_sem_deinit( urj_bsdl_parser_priv_t *priv ) +static void +urj_bsdl_sem_deinit (urj_bsdl_parser_priv_t *priv) { - urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; - - if (jc->idcode) - { - free( jc->idcode ); - jc->idcode = NULL; - } - - if (jc->usercode) - { - free( jc->usercode ); - jc->usercode = NULL; - } - - /* free cell_info list */ - free_ci_list( jc->cell_info_first, 1 ); - jc->cell_info_first = jc->cell_info_last = NULL; - free_ci_list( &(priv->tmp_cell_info), 0 ); - - /* free instr_list */ - free_instr_list( jc->instr_list ); - jc->instr_list = NULL; - - /* free ainfo_list */ - free_ainfo_list( jc->ainfo_list, 1 ); - jc->ainfo_list = NULL; - free_ainfo_list( &(priv->ainfo), 0 ); - - /* free string list in temporary port descritor */ - free_string_list( priv->tmp_port_desc.names_list ); - priv->tmp_port_desc.names_list = NULL; + urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; + + if (jc->idcode) + { + free (jc->idcode); + jc->idcode = NULL; + } + + if (jc->usercode) + { + free (jc->usercode); + jc->usercode = NULL; + } + + /* free cell_info list */ + free_ci_list (jc->cell_info_first, 1); + jc->cell_info_first = jc->cell_info_last = NULL; + free_ci_list (&(priv->tmp_cell_info), 0); + + /* free instr_list */ + free_instr_list (jc->instr_list); + jc->instr_list = NULL; + + /* free ainfo_list */ + free_ainfo_list (jc->ainfo_list, 1); + jc->ainfo_list = NULL; + free_ainfo_list (&(priv->ainfo), 0); + + /* free string list in temporary port descritor */ + free_string_list (priv->tmp_port_desc.names_list); + priv->tmp_port_desc.names_list = NULL; } @@ -1116,26 +1130,32 @@ static void urj_bsdl_sem_deinit( urj_bsdl_parser_priv_t *priv ) * Returns * pointer to private parser structure ****************************************************************************/ -urj_bsdl_parser_priv_t *urj_bsdl_parser_init( urj_bsdl_jtag_ctrl_t *jtag_ctrl ) +urj_bsdl_parser_priv_t * +urj_bsdl_parser_init (urj_bsdl_jtag_ctrl_t *jtag_ctrl) { - urj_bsdl_parser_priv_t *new_priv; + urj_bsdl_parser_priv_t *new_priv; - if (!(new_priv = (urj_bsdl_parser_priv_t *)malloc( sizeof( urj_bsdl_parser_priv_t ) ))) { - urj_bsdl_msg( jtag_ctrl->proc_mode, - BSDL_MSG_ERR, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); - return NULL; - } + if (! + (new_priv = + (urj_bsdl_parser_priv_t *) malloc (sizeof (urj_bsdl_parser_priv_t)))) + { + urj_bsdl_msg (jtag_ctrl->proc_mode, + BSDL_MSG_ERR, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); + return NULL; + } - new_priv->jtag_ctrl = jtag_ctrl; + new_priv->jtag_ctrl = jtag_ctrl; - if (!(new_priv->scanner = urj_bsdl_flex_init( jtag_ctrl->proc_mode ))) { - free(new_priv); - new_priv = NULL; - } + if (!(new_priv->scanner = urj_bsdl_flex_init (jtag_ctrl->proc_mode))) + { + free (new_priv); + new_priv = NULL; + } - urj_bsdl_sem_init( new_priv ); + urj_bsdl_sem_init (new_priv); - return new_priv; + return new_priv; } @@ -1153,11 +1173,12 @@ urj_bsdl_parser_priv_t *urj_bsdl_parser_init( urj_bsdl_jtag_ctrl_t *jtag_ctrl ) * Returns * void ****************************************************************************/ -void urj_bsdl_parser_deinit( urj_bsdl_parser_priv_t *priv_data ) +void +urj_bsdl_parser_deinit (urj_bsdl_parser_priv_t *priv_data) { - urj_bsdl_sem_deinit( priv_data ); - urj_bsdl_flex_deinit( priv_data->scanner ); - free( priv_data ); + urj_bsdl_sem_deinit (priv_data); + urj_bsdl_flex_deinit (priv_data->scanner); + free (priv_data); } @@ -1175,22 +1196,25 @@ void urj_bsdl_parser_deinit( urj_bsdl_parser_priv_t *priv_data ) * Returns * void ****************************************************************************/ -static void add_instruction( urj_bsdl_parser_priv_t *priv, char *instr, char *opcode ) +static void +add_instruction (urj_bsdl_parser_priv_t *priv, char *instr, char *opcode) { - urj_bsdl_instr_elem_t *new_instr; - - new_instr = (urj_bsdl_instr_elem_t *)malloc( sizeof( urj_bsdl_instr_elem_t ) ); - if (new_instr) - { - new_instr->next = priv->jtag_ctrl->instr_list; - new_instr->instr = instr; - new_instr->opcode = opcode; - - priv->jtag_ctrl->instr_list = new_instr; - } - else - urj_bsdl_msg( priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_instr_elem_t *new_instr; + + new_instr = + (urj_bsdl_instr_elem_t *) malloc (sizeof (urj_bsdl_instr_elem_t)); + if (new_instr) + { + new_instr->next = priv->jtag_ctrl->instr_list; + new_instr->instr = instr; + new_instr->opcode = opcode; + + priv->jtag_ctrl->instr_list = new_instr; + } + else + urj_bsdl_msg (priv->jtag_ctrl->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } @@ -1209,12 +1233,13 @@ static void add_instruction( urj_bsdl_parser_priv_t *priv, char *instr, char *op * Returns * void ****************************************************************************/ -static void ac_set_register( urj_bsdl_parser_priv_t *priv, char *reg, int reg_len ) +static void +ac_set_register (urj_bsdl_parser_priv_t *priv, char *reg, int reg_len) { - urj_bsdl_types_ainfo_elem_t *tmp_ai = &(priv->ainfo); + urj_bsdl_types_ainfo_elem_t *tmp_ai = &(priv->ainfo); - tmp_ai->reg = reg; - tmp_ai->reg_len = reg_len; + tmp_ai->reg = reg; + tmp_ai->reg_len = reg_len; } @@ -1233,23 +1258,26 @@ static void ac_set_register( urj_bsdl_parser_priv_t *priv, char *reg, int reg_le * Returns * void ****************************************************************************/ -static void ac_add_instruction( urj_bsdl_parser_priv_t *priv, char *instr ) +static void +ac_add_instruction (urj_bsdl_parser_priv_t *priv, char *instr) { - urj_bsdl_types_ainfo_elem_t *tmp_ai = &(priv->ainfo); - urj_bsdl_instr_elem_t *new_instr; - - new_instr = (urj_bsdl_instr_elem_t *)malloc( sizeof( urj_bsdl_instr_elem_t ) ); - if (new_instr) - { - new_instr->next = tmp_ai->instr_list; - new_instr->instr = instr; - new_instr->opcode = NULL; - - tmp_ai->instr_list = new_instr; - } - else - urj_bsdl_msg( priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_types_ainfo_elem_t *tmp_ai = &(priv->ainfo); + urj_bsdl_instr_elem_t *new_instr; + + new_instr = + (urj_bsdl_instr_elem_t *) malloc (sizeof (urj_bsdl_instr_elem_t)); + if (new_instr) + { + new_instr->next = tmp_ai->instr_list; + new_instr->instr = instr; + new_instr->opcode = NULL; + + tmp_ai->instr_list = new_instr; + } + else + urj_bsdl_msg (priv->jtag_ctrl->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } @@ -1266,30 +1294,34 @@ static void ac_add_instruction( urj_bsdl_parser_priv_t *priv, char *instr ) * Returns * void ****************************************************************************/ -static void ac_apply_assoc( urj_bsdl_parser_priv_t *priv ) +static void +ac_apply_assoc (urj_bsdl_parser_priv_t *priv) { - urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; - urj_bsdl_types_ainfo_elem_t *tmp_ai = &(priv->ainfo); - urj_bsdl_types_ainfo_elem_t *new_ai; - - new_ai = (urj_bsdl_types_ainfo_elem_t *)malloc( sizeof( urj_bsdl_types_ainfo_elem_t ) ); - if (new_ai) - { - new_ai->next = jc->ainfo_list; - new_ai->reg = tmp_ai->reg; - new_ai->reg_len = tmp_ai->reg_len; - new_ai->instr_list = tmp_ai->instr_list; - - jc->ainfo_list = new_ai; - } - else - urj_bsdl_msg( jc->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); - - /* clean up obsolete temporary entries */ - tmp_ai->reg = NULL; - tmp_ai->reg_len = 0; - tmp_ai->instr_list = NULL; + urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; + urj_bsdl_types_ainfo_elem_t *tmp_ai = &(priv->ainfo); + urj_bsdl_types_ainfo_elem_t *new_ai; + + new_ai = + (urj_bsdl_types_ainfo_elem_t *) + malloc (sizeof (urj_bsdl_types_ainfo_elem_t)); + if (new_ai) + { + new_ai->next = jc->ainfo_list; + new_ai->reg = tmp_ai->reg; + new_ai->reg_len = tmp_ai->reg_len; + new_ai->instr_list = tmp_ai->instr_list; + + jc->ainfo_list = new_ai; + } + else + urj_bsdl_msg (jc->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); + + /* clean up obsolete temporary entries */ + tmp_ai->reg = NULL; + tmp_ai->reg_len = 0; + tmp_ai->instr_list = NULL; } @@ -1307,22 +1339,25 @@ static void ac_apply_assoc( urj_bsdl_parser_priv_t *priv ) * Returns * void ****************************************************************************/ -static void prt_add_name( urj_bsdl_parser_priv_t *priv, char *name ) +static void +prt_add_name (urj_bsdl_parser_priv_t *priv, char *name) { - urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); - urj_bsdl_string_elem_t *new_string; - - new_string = (urj_bsdl_string_elem_t *)malloc( sizeof( urj_bsdl_string_elem_t ) ); - if (new_string) - { - new_string->next = pd->names_list; - new_string->string = name; - - pd->names_list = new_string; - } - else - urj_bsdl_msg( priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); + urj_bsdl_string_elem_t *new_string; + + new_string = + (urj_bsdl_string_elem_t *) malloc (sizeof (urj_bsdl_string_elem_t)); + if (new_string) + { + new_string->next = pd->names_list; + new_string->string = name; + + pd->names_list = new_string; + } + else + urj_bsdl_msg (priv->jtag_ctrl->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } @@ -1340,13 +1375,14 @@ static void prt_add_name( urj_bsdl_parser_priv_t *priv, char *name ) * Returns * void ****************************************************************************/ -static void prt_add_bit( urj_bsdl_parser_priv_t *priv ) +static void +prt_add_bit (urj_bsdl_parser_priv_t *priv) { - urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); + urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); - pd->is_vector = 0; - pd->low_idx = 0; - pd->high_idx = 0; + pd->is_vector = 0; + pd->low_idx = 0; + pd->high_idx = 0; } @@ -1365,13 +1401,14 @@ static void prt_add_bit( urj_bsdl_parser_priv_t *priv ) * Returns * void ****************************************************************************/ -static void prt_add_range( urj_bsdl_parser_priv_t *priv, int low, int high ) +static void +prt_add_range (urj_bsdl_parser_priv_t *priv, int low, int high) { - urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); + urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); - pd->is_vector = 1; - pd->low_idx = low; - pd->high_idx = high; + pd->is_vector = 1; + pd->low_idx = low; + pd->high_idx = high; } @@ -1387,9 +1424,10 @@ static void prt_add_range( urj_bsdl_parser_priv_t *priv, int low, int high ) * Returns * void ****************************************************************************/ -static void ci_no_disable( urj_bsdl_parser_priv_t *priv ) +static void +ci_no_disable (urj_bsdl_parser_priv_t *priv) { - priv->tmp_cell_info.ctrl_bit_num = -1; + priv->tmp_cell_info.ctrl_bit_num = -1; } @@ -1410,14 +1448,15 @@ static void ci_no_disable( urj_bsdl_parser_priv_t *priv ) * Returns * void ****************************************************************************/ -static void ci_set_cell_spec_disable( urj_bsdl_parser_priv_t *priv, int ctrl_bit_num, - int safe_value, int disable_value ) +static void +ci_set_cell_spec_disable (urj_bsdl_parser_priv_t *priv, int ctrl_bit_num, + int safe_value, int disable_value) { - urj_bsdl_cell_info_t *ci = &(priv->tmp_cell_info); + urj_bsdl_cell_info_t *ci = &(priv->tmp_cell_info); - ci->ctrl_bit_num = ctrl_bit_num; - ci->disable_safe_value = safe_value; - /* disable value is ignored at the moment */ + ci->ctrl_bit_num = ctrl_bit_num; + ci->disable_safe_value = safe_value; + /* disable value is ignored at the moment */ } @@ -1439,45 +1478,48 @@ static void ci_set_cell_spec_disable( urj_bsdl_parser_priv_t *priv, int ctrl_bit * Returns * void ****************************************************************************/ -static void ci_set_cell_spec( urj_bsdl_parser_priv_t *priv, - int function, char *safe_value ) +static void +ci_set_cell_spec (urj_bsdl_parser_priv_t *priv, + int function, char *safe_value) { - urj_bsdl_cell_info_t *ci = &(priv->tmp_cell_info); - urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); - urj_bsdl_string_elem_t *name = priv->tmp_port_desc.names_list; - char *port_string; - size_t str_len, name_len; - - ci->cell_function = function; - ci->basic_safe_value = safe_value; - - /* handle indexed port name: - - names of scalar ports are simply copied from the port_desc structure - to the final string that goes into ci - - names of vectored ports are expanded with their decimal index as - collected earlier earlier in rule Port_Name - */ - name_len = strlen( name->string ); - str_len = name_len + 1 + 10 + 1 + 1; - if ((port_string = (char *)malloc( str_len )) != NULL) - { - if (pd->is_vector) - snprintf( port_string, str_len-1, "%s(%d)", name->string, pd->low_idx ); + urj_bsdl_cell_info_t *ci = &(priv->tmp_cell_info); + urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); + urj_bsdl_string_elem_t *name = priv->tmp_port_desc.names_list; + char *port_string; + size_t str_len, name_len; + + ci->cell_function = function; + ci->basic_safe_value = safe_value; + + /* handle indexed port name: + - names of scalar ports are simply copied from the port_desc structure + to the final string that goes into ci + - names of vectored ports are expanded with their decimal index as + collected earlier earlier in rule Port_Name + */ + name_len = strlen (name->string); + str_len = name_len + 1 + 10 + 1 + 1; + if ((port_string = (char *) malloc (str_len)) != NULL) + { + if (pd->is_vector) + snprintf (port_string, str_len - 1, "%s(%d)", name->string, + pd->low_idx); + else + strncpy (port_string, name->string, str_len - 1); + port_string[str_len - 1] = '\0'; + + ci->port_name = port_string; + } else - strncpy( port_string, name->string, str_len-1 ); - port_string[str_len-1] = '\0'; - - ci->port_name = port_string; - } - else - { - urj_bsdl_msg( priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); - ci->port_name = NULL; - } - - free_string_list( priv->tmp_port_desc.names_list ); - priv->tmp_port_desc.names_list = NULL; + { + urj_bsdl_msg (priv->jtag_ctrl->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); + ci->port_name = NULL; + } + + free_string_list (priv->tmp_port_desc.names_list); + priv->tmp_port_desc.names_list = NULL; } @@ -1494,35 +1536,37 @@ static void ci_set_cell_spec( urj_bsdl_parser_priv_t *priv, * Returns * void ****************************************************************************/ -static void ci_append_cell_info( urj_bsdl_parser_priv_t *priv, int bit_num ) +static void +ci_append_cell_info (urj_bsdl_parser_priv_t *priv, int bit_num) { - urj_bsdl_cell_info_t *tmp_ci = &(priv->tmp_cell_info); - urj_bsdl_cell_info_t *ci; - urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; - - ci = (urj_bsdl_cell_info_t *)malloc( sizeof( urj_bsdl_cell_info_t ) ); - if (ci) - { - ci->next = NULL; - if (jc->cell_info_last) - jc->cell_info_last->next = ci; + urj_bsdl_cell_info_t *tmp_ci = &(priv->tmp_cell_info); + urj_bsdl_cell_info_t *ci; + urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; + + ci = (urj_bsdl_cell_info_t *) malloc (sizeof (urj_bsdl_cell_info_t)); + if (ci) + { + ci->next = NULL; + if (jc->cell_info_last) + jc->cell_info_last->next = ci; + else + jc->cell_info_first = ci; + jc->cell_info_last = ci; + + ci->bit_num = bit_num; + ci->port_name = tmp_ci->port_name; + ci->cell_function = tmp_ci->cell_function; + ci->basic_safe_value = tmp_ci->basic_safe_value; + ci->ctrl_bit_num = tmp_ci->ctrl_bit_num; + ci->disable_safe_value = tmp_ci->disable_safe_value; + + tmp_ci->port_name = NULL; + tmp_ci->basic_safe_value = NULL; + } else - jc->cell_info_first = ci; - jc->cell_info_last = ci; - - ci->bit_num = bit_num; - ci->port_name = tmp_ci->port_name; - ci->cell_function = tmp_ci->cell_function; - ci->basic_safe_value = tmp_ci->basic_safe_value; - ci->ctrl_bit_num = tmp_ci->ctrl_bit_num; - ci->disable_safe_value = tmp_ci->disable_safe_value; - - tmp_ci->port_name = NULL; - tmp_ci->basic_safe_value = NULL; - } - else - urj_bsdl_msg( jc->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_msg (jc->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } diff --git a/urjtag/src/bsdl/bsdl_flex.l b/urjtag/src/bsdl/bsdl_flex.l index 953c4926..30b3431c 100644 --- a/urjtag/src/bsdl/bsdl_flex.l +++ b/urjtag/src/bsdl/bsdl_flex.l @@ -140,7 +140,7 @@ LEGAL NOTICES: #define YY_EXTRA_TYPE urj_bsdl_scan_extra_t * -static char *new_string( urj_bsdl_scan_extra_t *, const char * ); +static char *new_string (urj_bsdl_scan_extra_t *, const char *); #define BINARY 0 #define DECIMAL 1 @@ -412,7 +412,9 @@ ISC_Illegal_Exit ISC_ILLEGAL_EXIT if ( !YY_CURRENT_BUFFER ) yyterminate(); } + %% + /***************************************************************************** * void *urj_bsdl_flex_init( int proc_mode ) * @@ -424,33 +426,37 @@ ISC_Illegal_Exit ISC_ILLEGAL_EXIT * Returns * pointer to newly initialized scanner structure ****************************************************************************/ -void *urj_bsdl_flex_init( int proc_mode ) +void * +urj_bsdl_flex_init (int proc_mode) { - urj_bsdl_scan_extra_t *extra; - yyscan_t scanner; - - /* get our scanner structure */ - if (yylex_init(&scanner) != 0) - { - urj_bsdl_msg( proc_mode, - BSDL_MSG_FATAL, _("Scanner could not be initialized\n") ); - return NULL; - } - - if (!(extra = malloc( sizeof( urj_bsdl_scan_extra_t ) ))) { - urj_bsdl_msg( proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); - yylex_destroy( scanner ); - return NULL; - } - - extra->proc_mode = proc_mode; - extra->Compile_Errors = 0; - extra->Base = DECIMAL; - - yyset_extra( extra, scanner ); - - return scanner; + urj_bsdl_scan_extra_t *extra; + yyscan_t scanner; + + /* get our scanner structure */ + if (yylex_init (&scanner) != 0) + { + urj_bsdl_msg (proc_mode, + BSDL_MSG_FATAL, + _("Scanner could not be initialized\n")); + return NULL; + } + + if (!(extra = malloc (sizeof (urj_bsdl_scan_extra_t)))) + { + urj_bsdl_msg (proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); + yylex_destroy (scanner); + return NULL; + } + + extra->proc_mode = proc_mode; + extra->Compile_Errors = 0; + extra->Base = DECIMAL; + + yyset_extra (extra, scanner); + + return scanner; } @@ -465,17 +471,18 @@ void *urj_bsdl_flex_init( int proc_mode ) * Returns * void ****************************************************************************/ -void urj_bsdl_flex_deinit( void *scanner ) +void +urj_bsdl_flex_deinit (void *scanner) { - if (yyget_in( scanner )) - { - /* file might still be open so close it in any case - e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */ - fclose( yyget_in( scanner ) ); - yyset_in( NULL, scanner ); - } - free( yyget_extra( scanner ) ); - yylex_destroy( scanner ); + if (yyget_in (scanner)) + { + /* file might still be open so close it in any case + e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */ + fclose (yyget_in (scanner)); + yyset_in (NULL, scanner); + } + free (yyget_extra (scanner)); + yylex_destroy (scanner); } @@ -490,13 +497,15 @@ void urj_bsdl_flex_deinit( void *scanner ) * Returns * 1 ****************************************************************************/ -int yywrap( yyscan_t scanner ) +int +yywrap (yyscan_t scanner) { - if (yyget_in( scanner )) { - fclose( yyget_in( scanner ) ); - yyset_in( NULL, scanner ); - } - return 1; + if (yyget_in (scanner)) + { + fclose (yyget_in (scanner)); + yyset_in (NULL, scanner); + } + return 1; } @@ -512,22 +521,24 @@ int yywrap( yyscan_t scanner ) * Returns * pointer to allocated and initialized string memory ****************************************************************************/ -static char *new_string( urj_bsdl_scan_extra_t *extra, const char *str ) +static char * +new_string (urj_bsdl_scan_extra_t *extra, const char *str) { - char *n_str; - size_t n_str_size; - - n_str_size = strlen( str ) + 1; - if ((n_str = malloc( n_str_size ))) - { - strncpy( n_str, str, n_str_size-1 ); - n_str[n_str_size-1] = '\0'; /* set very last element to EOS */ - } - else - urj_bsdl_msg( extra->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); - - return(n_str); + char *n_str; + size_t n_str_size; + + n_str_size = strlen (str) + 1; + if ((n_str = malloc (n_str_size))) + { + strncpy (n_str, str, n_str_size - 1); + n_str[n_str_size - 1] = '\0'; /* set very last element to EOS */ + } + else + urj_bsdl_msg (extra->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); + + return (n_str); } @@ -544,21 +555,22 @@ static char *new_string( urj_bsdl_scan_extra_t *extra, const char *str ) * Returns * void ****************************************************************************/ -void urj_bsdl_flex_switch_buffer( yyscan_t scanner, const char *buffer, int lineno ) +void +urj_bsdl_flex_switch_buffer (yyscan_t scanner, const char *buffer, int lineno) { - /* ugly, ulgy, ugly - prepare yyg for later use of YY_CURRENT_BUFFER */ - struct yyguts_t * yyg = (struct yyguts_t*)scanner; - - /* yy_scan_string() switches to the string buffer internally, - so we must save the current buffer state explicitly by pushing the stack - and setting top of stack to the current buffer state again. - yy_scan_string() can then savely switch YY_CURRENT_BUFFER to the string buffer. - yypop_buffer_state() will delete the string buffer afterwards and pop the saved - current buffer state. */ - yypush_buffer_state( YY_CURRENT_BUFFER, scanner ); - yy_scan_string( buffer, scanner ); - yyset_lineno( lineno, scanner ); + /* ugly, ulgy, ugly + prepare yyg for later use of YY_CURRENT_BUFFER */ + struct yyguts_t *yyg = (struct yyguts_t *) scanner; + + /* yy_scan_string() switches to the string buffer internally, + so we must save the current buffer state explicitly by pushing the stack + and setting top of stack to the current buffer state again. + yy_scan_string() can then savely switch YY_CURRENT_BUFFER to the string buffer. + yypop_buffer_state() will delete the string buffer afterwards and pop the saved + current buffer state. */ + yypush_buffer_state (YY_CURRENT_BUFFER, scanner); + yy_scan_string (buffer, scanner); + yyset_lineno (lineno, scanner); } @@ -573,9 +585,10 @@ void urj_bsdl_flex_switch_buffer( yyscan_t scanner, const char *buffer, int line * Returns * void ****************************************************************************/ -void urj_bsdl_flex_stop_buffer( yyscan_t scanner ) +void +urj_bsdl_flex_stop_buffer (yyscan_t scanner) { - yypop_buffer_state( scanner ); + yypop_buffer_state (scanner); // if ( !YY_CURRENT_BUFFER ) // yyterminate(); } @@ -592,10 +605,11 @@ void urj_bsdl_flex_stop_buffer( yyscan_t scanner ) * Returns * number of compile errors ****************************************************************************/ -int urj_bsdl_flex_get_compile_errors( yyscan_t scanner ) +int +urj_bsdl_flex_get_compile_errors (yyscan_t scanner) { - urj_bsdl_scan_extra_t *extra = yyget_extra( scanner ); - return extra->Compile_Errors; + urj_bsdl_scan_extra_t *extra = yyget_extra (scanner); + return extra->Compile_Errors; } @@ -611,10 +625,11 @@ int urj_bsdl_flex_get_compile_errors( yyscan_t scanner ) * Returns * void ****************************************************************************/ -static void urj_bsdl_flex_set_compile_errors( int n, yyscan_t scanner ) +static void +urj_bsdl_flex_set_compile_errors (int n, yyscan_t scanner) { - urj_bsdl_scan_extra_t *extra = yyget_extra( scanner ); - extra->Compile_Errors = n; + urj_bsdl_scan_extra_t *extra = yyget_extra (scanner); + extra->Compile_Errors = n; } @@ -629,12 +644,13 @@ static void urj_bsdl_flex_set_compile_errors( int n, yyscan_t scanner ) * Returns * number of compile errors before increment ****************************************************************************/ -int urj_bsdl_flex_postinc_compile_errors( yyscan_t scanner ) +int +urj_bsdl_flex_postinc_compile_errors (yyscan_t scanner) { - int errors = urj_bsdl_flex_get_compile_errors( scanner ); + int errors = urj_bsdl_flex_get_compile_errors (scanner); - urj_bsdl_flex_set_compile_errors( errors+1, scanner ); - return errors; + urj_bsdl_flex_set_compile_errors (errors + 1, scanner); + return errors; } @@ -649,10 +665,11 @@ int urj_bsdl_flex_postinc_compile_errors( yyscan_t scanner ) * Returns * void ****************************************************************************/ -void urj_bsdl_flex_set_bin_x( yyscan_t scanner ) +void +urj_bsdl_flex_set_bin_x (yyscan_t scanner) { - urj_bsdl_scan_extra_t *extra = yyget_extra( scanner ); - extra->Base = BIN_X; + urj_bsdl_scan_extra_t *extra = yyget_extra (scanner); + extra->Base = BIN_X; } @@ -667,10 +684,11 @@ void urj_bsdl_flex_set_bin_x( yyscan_t scanner ) * Returns * void ****************************************************************************/ -void urj_bsdl_flex_set_hex( yyscan_t scanner ) +void +urj_bsdl_flex_set_hex (yyscan_t scanner) { - urj_bsdl_scan_extra_t *extra = yyget_extra( scanner ); - extra->Base = HEX; + urj_bsdl_scan_extra_t *extra = yyget_extra (scanner); + extra->Base = HEX; } @@ -685,10 +703,11 @@ void urj_bsdl_flex_set_hex( yyscan_t scanner ) * Returns * void ****************************************************************************/ -void urj_bsdl_flex_set_decimal( yyscan_t scanner ) +void +urj_bsdl_flex_set_decimal (yyscan_t scanner) { - urj_bsdl_scan_extra_t *extra = yyget_extra( scanner ); - extra->Base = DECIMAL; + urj_bsdl_scan_extra_t *extra = yyget_extra (scanner); + extra->Base = DECIMAL; } diff --git a/urjtag/src/bsdl/vhdl_bison.y b/urjtag/src/bsdl/vhdl_bison.y index f3af3381..cb99e0c7 100644 --- a/urjtag/src/bsdl/vhdl_bison.y +++ b/urjtag/src/bsdl/vhdl_bison.y @@ -150,39 +150,39 @@ int yylex (YYSTYPE *, void *); #define ERROR_LIMIT 15 #define BUMP_ERROR \ do { \ - if (urj_vhdl_flex_postinc_compile_errors( priv_data->scanner ) > ERROR_LIMIT) \ + if (urj_vhdl_flex_postinc_compile_errors (priv_data->scanner) > ERROR_LIMIT) \ { \ - Give_Up_And_Quit( priv_data ); \ + Give_Up_And_Quit (priv_data); \ YYABORT; \ } \ } while (0) #else #define BUMP_ERROR \ do { \ - Give_Up_And_Quit( priv_data ); \ + Give_Up_And_Quit (priv_data); \ YYABORT; \ } while (0) #endif -static void Init_Text( urj_bsdl_vhdl_parser_priv_t * ); -static void Store_Text( urj_bsdl_vhdl_parser_priv_t *, char * ); -static void Print_Error( urj_bsdl_vhdl_parser_priv_t *, const char * ); -static void Give_Up_And_Quit( urj_bsdl_vhdl_parser_priv_t * ); +static void Init_Text (urj_bsdl_vhdl_parser_priv_t *); +static void Store_Text (urj_bsdl_vhdl_parser_priv_t *, char *); +static void Print_Error (urj_bsdl_vhdl_parser_priv_t *, const char *); +static void Give_Up_And_Quit (urj_bsdl_vhdl_parser_priv_t *); /* VHDL semantic action interface */ -static void urj_vhdl_set_entity( urj_bsdl_vhdl_parser_priv_t *, char * ); -static void urj_vhdl_port_add_name( urj_bsdl_vhdl_parser_priv_t *, char * ); -static void urj_vhdl_port_add_bit( urj_bsdl_vhdl_parser_priv_t * ); -static void urj_vhdl_port_add_range( urj_bsdl_vhdl_parser_priv_t *, int, int ); -static void urj_vhdl_port_apply_port( urj_bsdl_vhdl_parser_priv_t * ); - -//static void set_attr_bool( urj_bsdl_vhdl_parser_priv_t *, char *, int ); -static void set_attr_decimal( urj_bsdl_vhdl_parser_priv_t *, char *, int ); -static void set_attr_string( urj_bsdl_vhdl_parser_priv_t *, char *, char * ); -//static void set_attr_real( urj_bsdl_vhdl_parser_priv_t *, char *, char * ); -//static void set_attr_const( urj_bsdl_vhdl_parser_priv_t *, char *, char * ); - -void yyerror( urj_bsdl_vhdl_parser_priv_t *, const char * ); +static void urj_vhdl_set_entity (urj_bsdl_vhdl_parser_priv_t *, char *); +static void urj_vhdl_port_add_name (urj_bsdl_vhdl_parser_priv_t *, char *); +static void urj_vhdl_port_add_bit (urj_bsdl_vhdl_parser_priv_t *); +static void urj_vhdl_port_add_range (urj_bsdl_vhdl_parser_priv_t *, int, int); +static void urj_vhdl_port_apply_port (urj_bsdl_vhdl_parser_priv_t *); + +//static void set_attr_bool (urj_bsdl_vhdl_parser_priv_t *, char *, int); +static void set_attr_decimal (urj_bsdl_vhdl_parser_priv_t *, char *, int); +static void set_attr_string (urj_bsdl_vhdl_parser_priv_t *, char *, char *); +//static void set_attr_real (urj_bsdl_vhdl_parser_priv_t *, char *, char *); +//static void set_attr_const (urj_bsdl_vhdl_parser_priv_t *, char *, char *); + +void yyerror (urj_bsdl_vhdl_parser_priv_t *, const char *); %} %union @@ -225,12 +225,12 @@ void yyerror( urj_bsdl_vhdl_parser_priv_t *, const char * ); BSDL_Program : Begin_BSDL BSDL_Body End_BSDL ; Begin_BSDL : ENTITY IDENTIFIER IS - { urj_vhdl_set_entity( priv_data, $2 ); } + { urj_vhdl_set_entity (priv_data, $2); } | error { - Print_Error( priv_data, _("Improper Entity declaration") ); - Print_Error( priv_data, _("Check if source file is BSDL") ); - BUMP_ERROR; YYABORT; /* Probably not a BSDL source file */ + Print_Error (priv_data, _("Improper Entity declaration")); + Print_Error (priv_data, _("Check if source file is BSDL")); + BUMP_ERROR; YYABORT; /* Probably not a BSDL source file */ } ; BSDL_Body : VHDL_Generic @@ -239,15 +239,15 @@ BSDL_Body : VHDL_Generic VHDL_Elements | error { - Print_Error( priv_data, _("Syntax Error") ); + Print_Error (priv_data, _("Syntax Error")); BUMP_ERROR; YYABORT; } ; End_BSDL : END IDENTIFIER SEMICOLON - { free( $2 ); } + { free ($2); } | error { - Print_Error( priv_data, _("Syntax Error") ); + Print_Error (priv_data, _("Syntax Error")); BUMP_ERROR; YYABORT; } ; @@ -257,7 +257,7 @@ VHDL_Generic : GENERIC LPAREN PHYSICAL_PIN_MAP COLON STRING COLON_EQUAL VHDL_Port : PORT LPAREN Port_Specifier_List RPAREN SEMICOLON | error { - Print_Error( priv_data, _("Improper Port declaration") ); + Print_Error (priv_data, _("Improper Port declaration")); BUMP_ERROR; YYABORT; } ; @@ -265,23 +265,23 @@ Port_Specifier_List : Port_Specifier | Port_Specifier_List SEMICOLON Port_Specifier ; Port_Specifier : Port_List COLON Function Scaler_Or_Vector - { urj_vhdl_port_apply_port( priv_data ); } + { urj_vhdl_port_apply_port (priv_data); } ; Port_List : IDENTIFIER - { urj_vhdl_port_add_name( priv_data, $1 ); } + { urj_vhdl_port_add_name (priv_data, $1); } | Port_List COMMA IDENTIFIER - { urj_vhdl_port_add_name( priv_data, $3 ); } + { urj_vhdl_port_add_name (priv_data, $3); } ; Function : IN | OUT | INOUT | BUFFER | LINKAGE ; Scaler_Or_Vector : BIT - { urj_vhdl_port_add_bit( priv_data ); } + { urj_vhdl_port_add_bit (priv_data); } | BIT_VECTOR LPAREN Vector_Range RPAREN ; Vector_Range : DECIMAL_NUMBER TO DECIMAL_NUMBER - { urj_vhdl_port_add_range( priv_data, $1, $3 ); } + { urj_vhdl_port_add_range (priv_data, $1, $3); } | DECIMAL_NUMBER DOWNTO DECIMAL_NUMBER - { urj_vhdl_port_add_range( priv_data, $3, $1 ); } + { urj_vhdl_port_add_range (priv_data, $3, $1); } ; VHDL_Use_Part : ISC_Use | Standard_Use @@ -289,20 +289,20 @@ VHDL_Use_Part : ISC_Use | Standard_Use VHDL_Use_List | error { - Print_Error( priv_data, _("Error in Package declaration(s)") ); + Print_Error (priv_data, _("Error in Package declaration(s)")); BUMP_ERROR; YYABORT; } ; Standard_Use : USE IDENTIFIER {/* Parse Standard 1149.1 Package */ - strcpy( priv_data->Package_File_Name, $2 ); - free( $2 ); + strcpy (priv_data->Package_File_Name, $2); + free ($2); } PERIOD ALL SEMICOLON { priv_data->Reading_Package = 1; - urj_vhdl_flex_switch_file( priv_data->scanner, - priv_data->Package_File_Name ); + urj_vhdl_flex_switch_file (priv_data->scanner, + priv_data->Package_File_Name); } Standard_Package { @@ -311,10 +311,10 @@ Standard_Use : USE IDENTIFIER ; Standard_Package : PACKAGE IDENTIFIER IS Standard_Decls Defered_Constants Standard_Decls END IDENTIFIER SEMICOLON Package_Body - { free( $2 ); free( $8 ); } + { free ($2); free ($8); } | error { - Print_Error( priv_data, _("Error in Standard Package") ); + Print_Error (priv_data, _("Error in Standard Package")); BUMP_ERROR; YYABORT; } ; @@ -322,28 +322,28 @@ Standard_Decls : Standard_Decl | Standard_Decls Standard_Decl ; Standard_Decl : ATTRIBUTE IDENTIFIER COLON Attribute_Type SEMICOLON - { free( $2 ); } + { free ($2); } | TYPE IDENTIFIER IS Type_Body SEMICOLON - { free( $2 ); } + { free ($2); } | TYPE CELL_INFO IS ARRAY LPAREN POSITIVE RANGE BOX RPAREN OF IDENTIFIER SEMICOLON - { free( $11 ); } + { free ($11); } | SUBTYPE PIN_MAP_STRING IS STRING SEMICOLON | SUBTYPE BSDL_EXTENSION IS STRING SEMICOLON | error { - Print_Error( priv_data, _("Error in Standard Declarations") ); + Print_Error (priv_data, _("Error in Standard Declarations")); BUMP_ERROR; YYABORT; } ; Attribute_Type : IDENTIFIER - { free( $1 ); } + { free ($1); } | STRING | DECIMAL_NUMBER | BSDL_EXTENSION | error { - Print_Error( priv_data, _("Error in Attribute type identification") ); + Print_Error (priv_data, _("Error in Attribute type identification")); BUMP_ERROR; YYABORT; } ; @@ -352,14 +352,14 @@ Type_Body : LPAREN ID_Bits RPAREN | LPAREN LOW COMMA BOTH RPAREN | ARRAY LPAREN DECIMAL_NUMBER TO DECIMAL_NUMBER RPAREN OF IDENTIFIER - { free( $8 ); } + { free ($8); } | ARRAY LPAREN DECIMAL_NUMBER DOWNTO DECIMAL_NUMBER RPAREN OF IDENTIFIER - { free( $8 ); } + { free ($8); } | RECORD Record_Body END RECORD | error { - Print_Error( priv_data, _("Error in Type definition") ); + Print_Error (priv_data, _("Error in Type definition")); BUMP_ERROR; YYABORT; } ; @@ -367,15 +367,15 @@ ID_Bits : ID_Bit | ID_Bits COMMA ID_Bit ; ID_List : IDENTIFIER - { free( $1 ); } + { free ($1); } | ID_List COMMA IDENTIFIER - { free( $3 ); } + { free ($3); } ; ID_Bit : SINGLE_QUOTE BIN_X_PATTERN SINGLE_QUOTE - { free( $2 ); } + { free ($2); } | error { - Print_Error( priv_data, _("Error in Bit definition") ); + Print_Error (priv_data, _("Error in Bit definition")); BUMP_ERROR; YYABORT; } ; @@ -383,10 +383,10 @@ Record_Body : Record_Element | Record_Body Record_Element ; Record_Element : IDENTIFIER COLON IDENTIFIER SEMICOLON - { free( $1 ); free( $3 ); } + { free ($1); free ($3); } | error { - Print_Error( priv_data, _("Error in Record Definition") ); + Print_Error (priv_data, _("Error in Record Definition")); BUMP_ERROR; YYABORT; } ; @@ -396,10 +396,10 @@ Defered_Constants : Defered_Constant Defered_Constant : CONSTANT Constant_Body ; Constant_Body : IDENTIFIER COLON CELL_INFO SEMICOLON - { free( $1 ); } + { free ($1); } | error { - Print_Error( priv_data, _("Error in defered constant") ); + Print_Error (priv_data, _("Error in defered constant")); BUMP_ERROR; YYABORT; } ; @@ -407,11 +407,11 @@ VHDL_Use_List : VHDL_Use | VHDL_Use_List VHDL_Use ; Package_Body : PACKAGE BODY IDENTIFIER IS Constant_List END IDENTIFIER - { free( $3 ); free( $7 ); } + { free ($3); free ($7); } SEMICOLON | error { - Print_Error( priv_data, _("Error in Package Body definition") ); + Print_Error (priv_data, _("Error in Package Body definition")); BUMP_ERROR; YYABORT; } ; @@ -420,10 +420,10 @@ Constant_List : Cell_Constant ; Cell_Constant : CONSTANT IDENTIFIER COLON CELL_INFO COLON_EQUAL LPAREN Triples_List RPAREN SEMICOLON - { free( $2 ); } + { free ($2); } | error { - Print_Error( priv_data, _("Error in Cell Constant definition") ); + Print_Error (priv_data, _("Error in Cell Constant definition")); BUMP_ERROR; YYABORT; } ; @@ -434,7 +434,7 @@ Triple : LPAREN Triple_Function COMMA Triple_Inst COMMA CAP_Data RPAREN | error { - Print_Error( priv_data, _("Error in Cell Data Record") ); + Print_Error (priv_data, _("Error in Cell Data Record")); BUMP_ERROR; YYABORT; } ; @@ -443,21 +443,21 @@ Triple_Function : INPUT | OUTPUT2 | OUTPUT3 | INTERNAL | CONTROL | OBSERVE_ONLY | error { - Print_Error( priv_data, _("Error in Cell_Type Function field") ); + Print_Error (priv_data, _("Error in Cell_Type Function field")); BUMP_ERROR; YYABORT; } ; Triple_Inst : EXTEST | SAMPLE | INTEST | RUNBIST | error { - Print_Error( priv_data, _("Error in BScan_Inst Instruction field") ); + Print_Error (priv_data, _("Error in BScan_Inst Instruction field")); BUMP_ERROR; YYABORT; } ; CAP_Data : PI | PO | UPD | CAP | X | ZERO | ONE | error { - Print_Error( priv_data, _("Error in Constant CAP data source field") ); + Print_Error (priv_data, _("Error in Constant CAP data source field")); BUMP_ERROR; YYABORT; } ; @@ -469,8 +469,8 @@ VHDL_Use : USE IDENTIFIER PERIOD ALL SEMICOLON { priv_data->Reading_Package = 1; - urj_vhdl_flex_switch_file(priv_data->scanner, - priv_data->Package_File_Name); + urj_vhdl_flex_switch_file (priv_data->scanner, + priv_data->Package_File_Name); } User_Package { @@ -488,7 +488,7 @@ VHDL_Elements : VHDL_Element | VHDL_Elements VHDL_Element | error { - Print_Error( priv_data, _("Unknown VHDL statement") ); + Print_Error (priv_data, _("Unknown VHDL statement")); BUMP_ERROR; YYABORT; } ; @@ -499,8 +499,8 @@ VHDL_Constant : CONSTANT VHDL_Constant_Part ; VHDL_Constant_Part : IDENTIFIER COLON PIN_MAP_STRING COLON_EQUAL Quoted_String SEMICOLON - // { set_attr_const( priv_data, $1, strdup( "PIN_MAP_STRING" ) ); } - { free( $1 ); } + // { set_attr_const (priv_data, $1, strdup ("PIN_MAP_STRING")); } + { free ($1); } ; VHDL_Attribute : ATTRIBUTE VHDL_Attribute_Types ; @@ -511,16 +511,16 @@ VHDL_Attribute_Types : VHDL_Attr_Boolean | VHDL_Attr_PhysicalPinMap | error { - Print_Error( priv_data, _("Error in Attribute specification") ); + Print_Error (priv_data, _("Error in Attribute specification")); BUMP_ERROR; YYABORT; } ; VHDL_Attr_Boolean : IDENTIFIER OF IDENTIFIER COLON SIGNAL IS Boolean SEMICOLON { - //set_attr_bool( priv_data, $1, $7 ); - //free( $3 ); + //set_attr_bool (priv_data, $1, $7); + //free ($3); /* skip boolean attributes for the time being */ - free( $1 ); free( $3 ); + free ($1); free ($3); } ; Boolean : TRUE @@ -530,46 +530,46 @@ Boolean : TRUE ; VHDL_Attr_Decimal : IDENTIFIER OF IDENTIFIER COLON ENTITY IS DECIMAL_NUMBER SEMICOLON { - set_attr_decimal( priv_data, $1, $7 ); - free( $3 ); + set_attr_decimal (priv_data, $1, $7); + free ($3); } ; VHDL_Attr_Real : IDENTIFIER OF IDENTIFIER COLON SIGNAL IS LPAREN REAL_NUMBER COMMA Stop RPAREN SEMICOLON { - //set_attr_real( priv_data, $1, $8 ); - //free( $3 ); + //set_attr_real (priv_data, $1, $8); + //free ($3); /* skip real attributes for the time being */ - free( $1 ); free( $3 ); free( $8 ); + free ($1); free ($3); free ($8); } ; Stop : LOW | BOTH ; VHDL_Attr_String : IDENTIFIER OF IDENTIFIER COLON ENTITY IS Quoted_String SEMICOLON { - set_attr_string( priv_data, $1, strdup( priv_data->buffer ) ); - free( $3 ); + set_attr_string (priv_data, $1, strdup (priv_data->buffer)); + free ($3); } ; VHDL_Attr_PhysicalPinMap : IDENTIFIER OF IDENTIFIER COLON ENTITY IS PHYSICAL_PIN_MAP SEMICOLON - { free( $1 ); free( $3 ); } + { free ($1); free ($3); } ; Quoted_String : QUOTED_STRING { - Init_Text( priv_data ); - Store_Text( priv_data, $1 ); - free( $1 ); + Init_Text (priv_data); + Store_Text (priv_data, $1); + free ($1); } | Quoted_String CONCATENATE QUOTED_STRING { - Store_Text( priv_data, $3 ); - free( $3 ); + Store_Text (priv_data, $3); + free ($3); } ; ISC_Use : USE ISC_Packages PERIOD ALL SEMICOLON { priv_data->Reading_Package = 1; - urj_vhdl_flex_switch_file( priv_data->scanner, - priv_data->Package_File_Name ); + urj_vhdl_flex_switch_file (priv_data->scanner, + priv_data->Package_File_Name); } ISC_Package { @@ -578,11 +578,11 @@ ISC_Use : USE ISC_Packages PERIOD ALL SEMICOLON ; ISC_Packages : STD_1532_2001 { - strcpy( priv_data->Package_File_Name, "STD_1532_2001" ); + strcpy (priv_data->Package_File_Name, "STD_1532_2001"); } | STD_1532_2002 { - strcpy( priv_data->Package_File_Name, "STD_1532_2002" ); + strcpy (priv_data->Package_File_Name, "STD_1532_2002"); } ; ISC_Package : ISC_Package_Header ISC_Package_Body @@ -610,15 +610,16 @@ ISC_Package_Body : PACKAGE BODY ISC_Packages IS * Returns * void ****************************************************************************/ -static void Init_Text( urj_bsdl_vhdl_parser_priv_t *priv ) +static void +Init_Text (urj_bsdl_vhdl_parser_priv_t *priv) { - if (priv->len_buffer == 0) - { - /* @@@@ ToDo check malloc result RFHH */ - priv->buffer = malloc( 160 ); - priv->len_buffer = 160; - } - priv->buffer[0] = '\0'; + if (priv->len_buffer == 0) + { + /* @@@@ ToDo check malloc result RFHH */ + priv->buffer = malloc (160); + priv->len_buffer = 160; + } + priv->buffer[0] = '\0'; } @@ -635,50 +636,55 @@ static void Init_Text( urj_bsdl_vhdl_parser_priv_t *priv ) * Returns * void ****************************************************************************/ -static void Store_Text( urj_bsdl_vhdl_parser_priv_t *priv, char *Source ) -{ /* Save characters from VHDL string in local string buffer. */ - size_t req_len; - char *SourceEnd; - - SourceEnd = ++Source; /* skip leading '"' */ - while (*SourceEnd && (*SourceEnd != '"') && (*SourceEnd != '\n')) - SourceEnd++; - /* terminate Source string with NUL character */ - *SourceEnd = '\0'; - - req_len = strlen( priv->buffer ) + strlen( Source ) + 1; - if (req_len > priv->len_buffer) - { - /* @@@@ ToDo check realloc result RFHH */ - priv->buffer = realloc( priv->buffer, req_len ); - priv->len_buffer = req_len; - } - strcat( priv->buffer, Source ); +static void +Store_Text (urj_bsdl_vhdl_parser_priv_t *priv, char *Source) +{ /* Save characters from VHDL string in local string buffer. */ + size_t req_len; + char *SourceEnd; + + SourceEnd = ++Source; /* skip leading '"' */ + while (*SourceEnd && (*SourceEnd != '"') && (*SourceEnd != '\n')) + SourceEnd++; + /* terminate Source string with NUL character */ + *SourceEnd = '\0'; + + req_len = strlen (priv->buffer) + strlen (Source) + 1; + if (req_len > priv->len_buffer) + { + /* @@@@ ToDo check realloc result RFHH */ + priv->buffer = realloc (priv->buffer, req_len); + priv->len_buffer = req_len; + } + strcat (priv->buffer, Source); } + /*----------------------------------------------------------------------*/ -static void Print_Error( urj_bsdl_vhdl_parser_priv_t *priv_data, const char *Errmess ) +static void +Print_Error (urj_bsdl_vhdl_parser_priv_t *priv_data, const char *Errmess) { - urj_bsdl_jtag_ctrl_t *jc = priv_data->jtag_ctrl; - - if (priv_data->Reading_Package) - urj_bsdl_msg( jc->proc_mode, - BSDL_MSG_ERR, _("In Package %s, Line %d, %s.\n"), - priv_data->Package_File_Name, - urj_vhdl_flex_get_lineno( priv_data->scanner ), - Errmess ); - else - urj_bsdl_msg( jc->proc_mode, - BSDL_MSG_ERR, _("Line %d, %s.\n"), - urj_vhdl_flex_get_lineno( priv_data->scanner ), - Errmess ); + urj_bsdl_jtag_ctrl_t *jc = priv_data->jtag_ctrl; + + if (priv_data->Reading_Package) + urj_bsdl_msg (jc->proc_mode, + BSDL_MSG_ERR, _("In Package %s, Line %d, %s.\n"), + priv_data->Package_File_Name, + urj_vhdl_flex_get_lineno (priv_data->scanner), Errmess); + else + urj_bsdl_msg (jc->proc_mode, + BSDL_MSG_ERR, _("Line %d, %s.\n"), + urj_vhdl_flex_get_lineno (priv_data->scanner), Errmess); } + /*----------------------------------------------------------------------*/ -static void Give_Up_And_Quit( urj_bsdl_vhdl_parser_priv_t *priv_data ) +static void +Give_Up_And_Quit (urj_bsdl_vhdl_parser_priv_t *priv_data) { - Print_Error( priv_data, _("Too many errors") ); + Print_Error (priv_data, _("Too many errors")); } + /*----------------------------------------------------------------------*/ -void yyerror( urj_bsdl_vhdl_parser_priv_t *priv_data, const char *error_string ) +void +yyerror (urj_bsdl_vhdl_parser_priv_t *priv_data, const char *error_string) { } @@ -695,15 +701,16 @@ void yyerror( urj_bsdl_vhdl_parser_priv_t *priv_data, const char *error_string ) * Returns * void ****************************************************************************/ -static void urj_vhdl_sem_init( urj_bsdl_vhdl_parser_priv_t *priv ) +static void +urj_vhdl_sem_init (urj_bsdl_vhdl_parser_priv_t *priv) { - priv->tmp_port_desc.names_list = NULL; - priv->tmp_port_desc.next = NULL; + priv->tmp_port_desc.names_list = NULL; + priv->tmp_port_desc.next = NULL; - priv->jtag_ctrl->port_desc = NULL; + priv->jtag_ctrl->port_desc = NULL; - priv->jtag_ctrl->vhdl_elem_first = NULL; - priv->jtag_ctrl->vhdl_elem_last = NULL; + priv->jtag_ctrl->vhdl_elem_first = NULL; + priv->jtag_ctrl->vhdl_elem_last = NULL; } @@ -718,15 +725,16 @@ static void urj_vhdl_sem_init( urj_bsdl_vhdl_parser_priv_t *priv ) * Returns * void ****************************************************************************/ -static void free_string_list( urj_bsdl_string_elem_t *sl ) +static void +free_string_list (urj_bsdl_string_elem_t *sl) { - if (sl) - { - if (sl->string) - free( sl->string ); - free_string_list( sl->next ); - free( sl ); - } + if (sl) + { + if (sl->string) + free (sl->string); + free_string_list (sl->next); + free (sl); + } } @@ -742,16 +750,17 @@ static void free_string_list( urj_bsdl_string_elem_t *sl ) * Returns * void ****************************************************************************/ -static void free_port_list( urj_bsdl_port_desc_t *pl, int free_me ) +static void +free_port_list (urj_bsdl_port_desc_t *pl, int free_me) { - if (pl) - { - free_string_list( pl->names_list ); - free_port_list( pl->next, 1 ); - - if (free_me) - free( pl ); - } + if (pl) + { + free_string_list (pl->names_list); + free_port_list (pl->next, 1); + + if (free_me) + free (pl); + } } @@ -766,19 +775,20 @@ static void free_port_list( urj_bsdl_port_desc_t *pl, int free_me ) * Returns * void ****************************************************************************/ -static void free_elem_list( urj_bsdl_vhdl_elem_t *el ) +static void +free_elem_list (urj_bsdl_vhdl_elem_t *el) { - if (el) - { - free_elem_list( el->next ); + if (el) + { + free_elem_list (el->next); - if (el->name) - free( el->name ); + if (el->name) + free (el->name); - if (el->payload) - free( el->payload ); - free( el ); - } + if (el->payload) + free (el->payload); + free (el); + } } @@ -794,19 +804,20 @@ static void free_elem_list( urj_bsdl_vhdl_elem_t *el ) * Returns * void ****************************************************************************/ -static void urj_vhdl_sem_deinit( urj_bsdl_vhdl_parser_priv_t *priv_data ) +static void +urj_vhdl_sem_deinit (urj_bsdl_vhdl_parser_priv_t *priv_data) { - urj_bsdl_port_desc_t *pd = priv_data->jtag_ctrl->port_desc; - urj_bsdl_vhdl_elem_t *el = priv_data->jtag_ctrl->vhdl_elem_first; + urj_bsdl_port_desc_t *pd = priv_data->jtag_ctrl->port_desc; + urj_bsdl_vhdl_elem_t *el = priv_data->jtag_ctrl->vhdl_elem_first; - /* free port_desc list */ - free_port_list( pd, 1 ); - free_port_list( &(priv_data->tmp_port_desc), 0 ); + /* free port_desc list */ + free_port_list (pd, 1); + free_port_list (&(priv_data->tmp_port_desc), 0); - /* free VHDL element list */ - free_elem_list( el ); + /* free VHDL element list */ + free_elem_list (el); - priv_data->jtag_ctrl = NULL; + priv_data->jtag_ctrl = NULL; } @@ -825,32 +836,34 @@ static void urj_vhdl_sem_deinit( urj_bsdl_vhdl_parser_priv_t *priv_data ) * Returns * pointer to private parser structure ****************************************************************************/ -urj_bsdl_vhdl_parser_priv_t *urj_vhdl_parser_init( FILE *f, urj_bsdl_jtag_ctrl_t *jtag_ctrl ) +urj_bsdl_vhdl_parser_priv_t * +urj_vhdl_parser_init (FILE *f, urj_bsdl_jtag_ctrl_t *jtag_ctrl) { - urj_bsdl_vhdl_parser_priv_t *new_priv; + urj_bsdl_vhdl_parser_priv_t *new_priv; - if (!(new_priv = malloc( sizeof( urj_bsdl_vhdl_parser_priv_t ) ))) - { - urj_bsdl_msg( jtag_ctrl->proc_mode, - BSDL_MSG_ERR, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); - return NULL; - } + if (!(new_priv = malloc (sizeof (urj_bsdl_vhdl_parser_priv_t)))) + { + urj_bsdl_msg (jtag_ctrl->proc_mode, + BSDL_MSG_ERR, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); + return NULL; + } - new_priv->jtag_ctrl = jtag_ctrl; + new_priv->jtag_ctrl = jtag_ctrl; - new_priv->Reading_Package = 0; - new_priv->buffer = NULL; - new_priv->len_buffer = 0; + new_priv->Reading_Package = 0; + new_priv->buffer = NULL; + new_priv->len_buffer = 0; - if (!(new_priv->scanner = urj_vhdl_flex_init( f, jtag_ctrl->proc_mode ))) - { - free( new_priv ); - new_priv = NULL; - } + if (!(new_priv->scanner = urj_vhdl_flex_init (f, jtag_ctrl->proc_mode))) + { + free (new_priv); + new_priv = NULL; + } - urj_vhdl_sem_init( new_priv ); + urj_vhdl_sem_init (new_priv); - return new_priv; + return new_priv; } @@ -868,17 +881,18 @@ urj_bsdl_vhdl_parser_priv_t *urj_vhdl_parser_init( FILE *f, urj_bsdl_jtag_ctrl_t * Returns * void ****************************************************************************/ -void urj_vhdl_parser_deinit( urj_bsdl_vhdl_parser_priv_t *priv_data ) +void +urj_vhdl_parser_deinit (urj_bsdl_vhdl_parser_priv_t *priv_data) { - if (priv_data->buffer) - { - free( priv_data->buffer ); - priv_data->buffer = NULL; - } - - urj_vhdl_sem_deinit( priv_data ); - urj_vhdl_flex_deinit( priv_data->scanner ); - free( priv_data ); + if (priv_data->buffer) + { + free (priv_data->buffer); + priv_data->buffer = NULL; + } + + urj_vhdl_sem_deinit (priv_data); + urj_vhdl_flex_deinit (priv_data->scanner); + free (priv_data); } /***************************************************************************** @@ -893,15 +907,17 @@ void urj_vhdl_parser_deinit( urj_bsdl_vhdl_parser_priv_t *priv_data ) * Returns * void ****************************************************************************/ -static void urj_vhdl_set_entity( urj_bsdl_vhdl_parser_priv_t *priv, char *entityname ) +static void +urj_vhdl_set_entity (urj_bsdl_vhdl_parser_priv_t *priv, char *entityname) { - if (priv->jtag_ctrl->proc_mode & URJ_BSDL_MODE_INSTR_EXEC) - { - strncpy( priv->jtag_ctrl->part->part, entityname, URJ_PART_PART_MAXLEN ); - priv->jtag_ctrl->part->part[URJ_PART_PART_MAXLEN] = '\0'; - } - - free( entityname ); + if (priv->jtag_ctrl->proc_mode & URJ_BSDL_MODE_INSTR_EXEC) + { + strncpy (priv->jtag_ctrl->part->part, entityname, + URJ_PART_PART_MAXLEN); + priv->jtag_ctrl->part->part[URJ_PART_PART_MAXLEN] = '\0'; + } + + free (entityname); } /***************************************************************************** @@ -918,22 +934,24 @@ static void urj_vhdl_set_entity( urj_bsdl_vhdl_parser_priv_t *priv, char *entity * Returns * void ****************************************************************************/ -static void urj_vhdl_port_add_name( urj_bsdl_vhdl_parser_priv_t *priv, char *name ) +static void +urj_vhdl_port_add_name (urj_bsdl_vhdl_parser_priv_t *priv, char *name) { - urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); - urj_bsdl_string_elem_t *new_string; - - new_string = malloc( sizeof( urj_bsdl_string_elem_t ) ); - if (new_string) - { - new_string->next = pd->names_list; - new_string->string = name; - - pd->names_list = new_string; - } - else - urj_bsdl_msg( priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); + urj_bsdl_string_elem_t *new_string; + + new_string = malloc (sizeof (urj_bsdl_string_elem_t)); + if (new_string) + { + new_string->next = pd->names_list; + new_string->string = name; + + pd->names_list = new_string; + } + else + urj_bsdl_msg (priv->jtag_ctrl->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } @@ -951,13 +969,14 @@ static void urj_vhdl_port_add_name( urj_bsdl_vhdl_parser_priv_t *priv, char *nam * Returns * void ****************************************************************************/ -static void urj_vhdl_port_add_bit( urj_bsdl_vhdl_parser_priv_t *priv ) +static void +urj_vhdl_port_add_bit (urj_bsdl_vhdl_parser_priv_t *priv) { - urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); + urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); - pd->is_vector = 0; - pd->low_idx = 0; - pd->high_idx = 0; + pd->is_vector = 0; + pd->low_idx = 0; + pd->high_idx = 0; } @@ -976,13 +995,15 @@ static void urj_vhdl_port_add_bit( urj_bsdl_vhdl_parser_priv_t *priv ) * Returns * void ****************************************************************************/ -static void urj_vhdl_port_add_range( urj_bsdl_vhdl_parser_priv_t *priv, int low, int high ) +static void +urj_vhdl_port_add_range (urj_bsdl_vhdl_parser_priv_t *priv, int low, + int high) { - urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); + urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc); - pd->is_vector = 1; - pd->low_idx = low; - pd->high_idx = high; + pd->is_vector = 1; + pd->low_idx = low; + pd->high_idx = high; } /***************************************************************************** @@ -998,147 +1019,160 @@ static void urj_vhdl_port_add_range( urj_bsdl_vhdl_parser_priv_t *priv, int low, * Returns * void ****************************************************************************/ -static void urj_vhdl_port_apply_port( urj_bsdl_vhdl_parser_priv_t *priv ) +static void +urj_vhdl_port_apply_port (urj_bsdl_vhdl_parser_priv_t *priv) { - urj_bsdl_port_desc_t *tmp_pd = &(priv->tmp_port_desc); - urj_bsdl_port_desc_t *pd = malloc( sizeof( urj_bsdl_port_desc_t ) ); - - if (pd) - { - /* insert at top of list */ - pd->next = priv->jtag_ctrl->port_desc; - priv->jtag_ctrl->port_desc = pd; - - /* copy information from temporary port descriptor */ - pd->names_list = tmp_pd->names_list; - pd->is_vector = tmp_pd->is_vector; - pd->low_idx = tmp_pd->low_idx; - pd->high_idx = tmp_pd->high_idx; - - /* and reset temporary port descriptor */ - tmp_pd->names_list = NULL; - tmp_pd->next = NULL; - } - else - urj_bsdl_msg( priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_port_desc_t *tmp_pd = &(priv->tmp_port_desc); + urj_bsdl_port_desc_t *pd = malloc (sizeof (urj_bsdl_port_desc_t)); + + if (pd) + { + /* insert at top of list */ + pd->next = priv->jtag_ctrl->port_desc; + priv->jtag_ctrl->port_desc = pd; + + /* copy information from temporary port descriptor */ + pd->names_list = tmp_pd->names_list; + pd->is_vector = tmp_pd->is_vector; + pd->low_idx = tmp_pd->low_idx; + pd->high_idx = tmp_pd->high_idx; + + /* and reset temporary port descriptor */ + tmp_pd->names_list = NULL; + tmp_pd->next = NULL; + } + else + urj_bsdl_msg (priv->jtag_ctrl->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } -static void add_elem( urj_bsdl_vhdl_parser_priv_t *priv, urj_bsdl_vhdl_elem_t *el ) +static void +add_elem (urj_bsdl_vhdl_parser_priv_t *priv, urj_bsdl_vhdl_elem_t *el) { - urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; + urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl; - el->next = NULL; - if (jc->vhdl_elem_last) - jc->vhdl_elem_last->next = el; - jc->vhdl_elem_last = el; + el->next = NULL; + if (jc->vhdl_elem_last) + jc->vhdl_elem_last->next = el; + jc->vhdl_elem_last = el; - if (!jc->vhdl_elem_first) - jc->vhdl_elem_first = el; + if (!jc->vhdl_elem_first) + jc->vhdl_elem_first = el; - el->line = urj_vhdl_flex_get_lineno( priv->scanner ); + el->line = urj_vhdl_flex_get_lineno (priv->scanner); } #if 0 -static void set_attr_bool( urj_bsdl_vhdl_parser_priv_t *priv, char *name, int value ) +static void +set_attr_bool (urj_bsdl_vhdl_parser_priv_t *priv, char *name, int value) { - urj_bsdl_vhdl_elem_t *el = malloc( sizeof( urj_bsdl_vhdl_elem_t ) ); - - if (el) - { - el->type = VET_ATTRIBUTE_BOOL; - el->name = name; - el->payload.bool = value; - - add_elem( priv, el ); - } - else - urj_bsdl_msg( BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_vhdl_elem_t *el = malloc (sizeof (urj_bsdl_vhdl_elem_t)); + + if (el) + { + el->type = VET_ATTRIBUTE_BOOL; + el->name = name; + el->payload.bool = value; + + add_elem (priv, el); + } + else + urj_bsdl_msg (BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } #endif -static void set_attr_decimal( urj_bsdl_vhdl_parser_priv_t *priv, char *name, int value ) +static void +set_attr_decimal (urj_bsdl_vhdl_parser_priv_t *priv, char *name, int value) { - urj_bsdl_vhdl_elem_t *el = malloc( sizeof( urj_bsdl_vhdl_elem_t ) ); - char *string = malloc( 10 ); - - if (el && string) - { - el->type = URJ_BSDL_VET_ATTRIBUTE_DECIMAL; - el->name = name; - snprintf( string, 10, "%d", value ); - el->payload = string; - - add_elem( priv, el ); - } - else - urj_bsdl_msg( priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_vhdl_elem_t *el = malloc (sizeof (urj_bsdl_vhdl_elem_t)); + char *string = malloc (10); + + if (el && string) + { + el->type = URJ_BSDL_VET_ATTRIBUTE_DECIMAL; + el->name = name; + snprintf (string, 10, "%d", value); + el->payload = string; + + add_elem (priv, el); + } + else + urj_bsdl_msg (priv->jtag_ctrl->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } -static void set_attr_string( urj_bsdl_vhdl_parser_priv_t *priv, char *name, char *string ) +static void +set_attr_string (urj_bsdl_vhdl_parser_priv_t *priv, char *name, char *string) { - urj_bsdl_vhdl_elem_t *el = malloc( sizeof( urj_bsdl_vhdl_elem_t ) ); - - /* skip certain attributes */ - if ( (strcasecmp( name, "DESIGN_WARNING" ) == 0) - || (strcasecmp( name, "BOUNDARY_CELLS" ) == 0) - || (strcasecmp( name, "INSTRUCTION_SEQUENCE" ) == 0) - || (strcasecmp( name, "INSTRUCTION_USAGE" ) == 0) - || (strcasecmp( name, "ISC_DESIGN_WARNING" ) == 0)) - { - free( name ); - free( string ); - free( el ); - return; - } - - if (el) - { - el->type = URJ_BSDL_VET_ATTRIBUTE_STRING; - el->name = name; - el->payload = string; - - add_elem(priv, el); - } - else - urj_bsdl_msg( priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_vhdl_elem_t *el = malloc (sizeof (urj_bsdl_vhdl_elem_t)); + + /* skip certain attributes */ + if ((strcasecmp (name, "DESIGN_WARNING") == 0) + || (strcasecmp (name, "BOUNDARY_CELLS") == 0) + || (strcasecmp (name, "INSTRUCTION_SEQUENCE") == 0) + || (strcasecmp (name, "INSTRUCTION_USAGE") == 0) + || (strcasecmp (name, "ISC_DESIGN_WARNING") == 0)) + { + free (name); + free (string); + free (el); + return; + } + + if (el) + { + el->type = URJ_BSDL_VET_ATTRIBUTE_STRING; + el->name = name; + el->payload = string; + + add_elem (priv, el); + } + else + urj_bsdl_msg (priv->jtag_ctrl->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } #if 0 -static void set_attr_real( urj_bsdl_vhdl_parser_priv_t *priv, char *name, char *string ) +static void +set_attr_real (urj_bsdl_vhdl_parser_priv_t *priv, char *name, char *string) { - urj_bsdl_vhdl_elem_t *el = malloc( sizeof( urj_bsdl_vhdl_elem_t ) ); - - if (el) - { - el->type = VET_ATTRIBUTE_REAL; - el->name = name; - el->payload.real = string; - - add_elem( priv, el ); - } - else - urj_bsdl_msg( BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_vhdl_elem_t *el = malloc (sizeof (urj_bsdl_vhdl_elem_t)); + + if (el) + { + el->type = VET_ATTRIBUTE_REAL; + el->name = name; + el->payload.real = string; + + add_elem (priv, el); + } + else + urj_bsdl_msg (BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } #endif #if 0 -static void set_attr_const( urj_bsdl_vhdl_parser_priv_t *priv, char *name, char *string ) +static void +set_attr_const (urj_bsdl_vhdl_parser_priv_t *priv, char *name, char *string) { - urj_bsdl_vhdl_elem_t *el = malloc( sizeof( urj_bsdl_vhdl_elem_t ) ); - - if (el) - { - el->type = URJ_BSDL_VET_CONSTANT; - el->name = name; - el->payload = string; - - add_elem( priv, el ); - } - else - urj_bsdl_msg( BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); + urj_bsdl_vhdl_elem_t *el = malloc (sizeof (urj_bsdl_vhdl_elem_t)); + + if (el) + { + el->type = URJ_BSDL_VET_CONSTANT; + el->name = name; + el->payload = string; + + add_elem (priv, el); + } + else + urj_bsdl_msg (BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); } #endif diff --git a/urjtag/src/bsdl/vhdl_flex.l b/urjtag/src/bsdl/vhdl_flex.l index 4339cd7e..56072779 100644 --- a/urjtag/src/bsdl/vhdl_flex.l +++ b/urjtag/src/bsdl/vhdl_flex.l @@ -142,7 +142,7 @@ LEGAL NOTICES: #define YY_EXTRA_TYPE urj_bsdl_scan_extra_t * -static char *new_string( urj_bsdl_scan_extra_t *, const char * ); +static char *new_string (urj_bsdl_scan_extra_t *, const char *); #define BINARY 0 #define DECIMAL 1 @@ -240,109 +240,111 @@ Bsdl_Extension BSDL_EXTENSION Std_1532_2001 STD_1532_2001 Std_1532_2002 STD_1532_2002 %% -{Entity} {return( ENTITY ); } +{Entity} {return (ENTITY); } {Port} {yyextra->Base = DECIMAL; /* Default number base */ - return( PORT ); } -{Generic} {yyextra->Base = DECIMAL; return( GENERIC ); } -{Use} {yyextra->Base = DECIMAL; return( USE ); } -{Attribute} {yyextra->Base = DECIMAL; return( ATTRIBUTE ); } -{Is} {return( IS ); } -{Constant} {yyextra->Base = DECIMAL; return( CONSTANT ); } -{String} {return( STRING ); } + return (PORT); } +{Generic} {yyextra->Base = DECIMAL; return (GENERIC); } +{Use} {yyextra->Base = DECIMAL; return (USE); } +{Attribute} {yyextra->Base = DECIMAL; return (ATTRIBUTE); } +{Is} {return (IS); } +{Constant} {yyextra->Base = DECIMAL; return (CONSTANT); } +{String} {return (STRING); } {End} {yyextra->Base = DECIMAL; BEGIN INITIAL; /* Turn off start conditions */ - return( END ); } -{All} {return( ALL ); } -{Of} {return( OF ); } -{Physical_Pin_Map} {return( PHYSICAL_PIN_MAP ); } -{Pin_Map_String} {return( PIN_MAP_STRING ); } -{True} {return( TRUE ); } -{False} {return( FALSE ); } -{Signal} {return( SIGNAL ); } -{Low} {return( LOW ); } -{Both} {return( BOTH ); } -{In} {return( IN ); } -{Out} {return( OUT ); } -{Inout} {return( INOUT ); } -{Buffer} {return( BUFFER ); } -{Linkage} {return( LINKAGE ); } -{Bit} {return( BIT ); } -{Bit_Vector} {return( BIT_VECTOR ); } -{To} {return( TO ); } -{Downto} {return( DOWNTO ); } -{Package} {return( PACKAGE ); } -{Body} {return( BODY ); } -{Type} {return( TYPE ); } -{Subtype} {return( SUBTYPE ); } -{Record} {return( RECORD ); } -{Array} {yyextra->Base = DECIMAL; return( ARRAY ); } -{Positive} {return( POSITIVE ); } -{Range} {return( RANGE ); } -{Cell_Info} {BEGIN PAC; return( CELL_INFO ); } -{Bsdl_Extension} {return( BSDL_EXTENSION ); } -{Std_1532_2001} {return( STD_1532_2001 ); } -{Std_1532_2002} {return( STD_1532_2002 ); } -{Input} {return( INPUT ); } -{Output2} {return( OUTPUT2 ); } -{Output3} {return( OUTPUT3 ); } -{Controlr} {return( CONTROLR ); } -{Control} {return( CONTROL ); } -{Internal} {return( INTERNAL ); } -{Clock} {return( CLOCK ); } -{Observe_Only} {return( OBSERVE_ONLY ); } -{Bidir} {return( BIDIR ); } -{Bidir_In} {return( BIDIR_IN ); } -{Bidir_Out} {return( BIDIR_OUT ); } -{Extest} {return( EXTEST ); } -{Sample} {return( SAMPLE ); } -{Intest} {return( INTEST ); } -{Runbist} {return( RUNBIST ); } -{Pi} {return( PI ); } -{Po} {return( PO ); } -{Upd} {return( UPD ); } -{Cap} {return( CAP ); } -{X} {return( X ); } -{Zero} {return( ZERO ); } -{One} {return( ONE ); } -{Z} {return( Z ); } + return (END); } +{All} {return (ALL); } +{Of} {return (OF); } +{Physical_Pin_Map} {return (PHYSICAL_PIN_MAP); } +{Pin_Map_String} {return (PIN_MAP_STRING); } +{True} {return (TRUE); } +{False} {return (FALSE); } +{Signal} {return (SIGNAL); } +{Low} {return (LOW); } +{Both} {return (BOTH); } +{In} {return (IN); } +{Out} {return (OUT); } +{Inout} {return (INOUT); } +{Buffer} {return (BUFFER); } +{Linkage} {return (LINKAGE); } +{Bit} {return (BIT); } +{Bit_Vector} {return (BIT_VECTOR); } +{To} {return (TO); } +{Downto} {return (DOWNTO); } +{Package} {return (PACKAGE); } +{Body} {return (BODY); } +{Type} {return (TYPE); } +{Subtype} {return (SUBTYPE); } +{Record} {return (RECORD); } +{Array} {yyextra->Base = DECIMAL; return (ARRAY); } +{Positive} {return (POSITIVE); } +{Range} {return (RANGE); } +{Cell_Info} {BEGIN PAC; return (CELL_INFO); } +{Bsdl_Extension} {return (BSDL_EXTENSION); } +{Std_1532_2001} {return (STD_1532_2001); } +{Std_1532_2002} {return (STD_1532_2002); } +{Input} {return (INPUT); } +{Output2} {return (OUTPUT2); } +{Output3} {return (OUTPUT3); } +{Controlr} {return (CONTROLR); } +{Control} {return (CONTROL); } +{Internal} {return (INTERNAL); } +{Clock} {return (CLOCK); } +{Observe_Only} {return (OBSERVE_ONLY); } +{Bidir} {return (BIDIR); } +{Bidir_In} {return (BIDIR_IN); } +{Bidir_Out} {return (BIDIR_OUT); } +{Extest} {return (EXTEST); } +{Sample} {return (SAMPLE); } +{Intest} {return (INTEST); } +{Runbist} {return (RUNBIST); } +{Pi} {return (PI); } +{Po} {return (PO); } +{Upd} {return (UPD); } +{Cap} {return (CAP); } +{X} {return (X); } +{Zero} {return (ZERO); } +{One} {return (ONE); } +{Z} {return (Z); } {Eol} {yylineno++; /* Count lines */} -{Comma} {return( COMMA ); } -{Lparen} {return( LPAREN );} -{Rparen} {return( RPAREN );} -{Period} {return( PERIOD ); } -{Colon} {return( COLON ); } -{Box} {return( BOX ); } -{Single_Quote} {yyextra->Base = BIN_X; return( SINGLE_QUOTE ); } -{Colon_Equal} {return( COLON_EQUAL ); } +{Comma} {return (COMMA); } +{Lparen} {return (LPAREN);} +{Rparen} {return (RPAREN);} +{Period} {return (PERIOD); } +{Colon} {return (COLON); } +{Box} {return (BOX); } +{Single_Quote} {yyextra->Base = BIN_X; return (SINGLE_QUOTE); } +{Colon_Equal} {return (COLON_EQUAL); } {White} { /* Do Nothing on White Space */ } {VHDL_Comment} { /* Do Nothing on Comments */ } {Bin_X_Pattern} {if (yyextra->Base != BIN_X) REJECT; - yylval->str = new_string( yyextra, yytext ); - return( BIN_X_PATTERN );} -{Identifier} {yylval->str = new_string( yyextra, yytext ); - return( IDENTIFIER ); } -{Quoted_String} {yylval->str = new_string( yyextra, yytext ); - return( QUOTED_STRING ); } + yylval->str = new_string (yyextra, yytext); + return (BIN_X_PATTERN);} +{Identifier} {yylval->str = new_string (yyextra, yytext); + return (IDENTIFIER); } +{Quoted_String} {yylval->str = new_string (yyextra, yytext); + return (QUOTED_STRING); } {Decimal_Number} {if (yyextra->Base != DECIMAL) REJECT; - yylval->integer = atoi( (char *)yytext ); - return( DECIMAL_NUMBER );} -{Real_Number} {yylval->str = new_string( yyextra, yytext ); - return( REAL_NUMBER );} -{Concatenate} {return( CONCATENATE );} -{Semicolon} {return( SEMICOLON );} -{Illegal} {urj_bsdl_msg( yyextra->proc_mode, + yylval->integer = atoi ((char *)yytext); + return (DECIMAL_NUMBER);} +{Real_Number} {yylval->str = new_string (yyextra, yytext); + return (REAL_NUMBER);} +{Concatenate} {return (CONCATENATE);} +{Semicolon} {return (SEMICOLON);} +{Illegal} {urj_bsdl_msg (yyextra->proc_mode, BSDL_MSG_ERR, _("Illegal character %c (/%03o) at line %d:\n"), (char)yytext[yyleng-1], (int)yytext[yyleng-1], - yylineno ); + yylineno); yyextra->Compile_Errors++; - return( ILLEGAL ); /* Will cause syntax error */} + return (ILLEGAL); /* Will cause syntax error */} <> { - yypop_buffer_state( yyscanner ); - if ( !YY_CURRENT_BUFFER ) + yypop_buffer_state (yyscanner); + if (!YY_CURRENT_BUFFER) yyterminate(); } + %% + /***************************************************************************** * void *urj_vhdl_flex_init( FILE *f, int mode ) * @@ -355,34 +357,37 @@ Std_1532_2002 STD_1532_2002 * Returns * pointer to newly initialized scanner structure ****************************************************************************/ -void *urj_vhdl_flex_init( FILE *f, int proc_mode ) +void * +urj_vhdl_flex_init (FILE *f, int proc_mode) { - urj_bsdl_scan_extra_t *extra; - yyscan_t scanner; - - /* get our scanner structure */ - if (yylex_init( &scanner ) != 0) - { - urj_bsdl_msg( proc_mode, BSDL_MSG_FATAL, _("Scanner could not be initialized\n") ); - return NULL; - } - yyset_in( f, scanner ); - - if (!(extra = malloc( sizeof( urj_bsdl_scan_extra_t ) ))) - { - urj_bsdl_msg( proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); - yylex_destroy( scanner ); - return NULL; - } - - extra->proc_mode = proc_mode; - extra->Compile_Errors = 0; - extra->Base = DECIMAL; - - yyset_extra( extra, scanner ); - - return scanner; + urj_bsdl_scan_extra_t *extra; + yyscan_t scanner; + + /* get our scanner structure */ + if (yylex_init (&scanner) != 0) + { + urj_bsdl_msg (proc_mode, BSDL_MSG_FATAL, + _("Scanner could not be initialized\n")); + return NULL; + } + yyset_in (f, scanner); + + if (!(extra = malloc (sizeof (urj_bsdl_scan_extra_t)))) + { + urj_bsdl_msg (proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); + yylex_destroy (scanner); + return NULL; + } + + extra->proc_mode = proc_mode; + extra->Compile_Errors = 0; + extra->Base = DECIMAL; + + yyset_extra (extra, scanner); + + return scanner; } @@ -397,17 +402,18 @@ void *urj_vhdl_flex_init( FILE *f, int proc_mode ) * Returns * void ****************************************************************************/ -void urj_vhdl_flex_deinit( void *scanner ) +void +urj_vhdl_flex_deinit (void *scanner) { - if (yyget_in( scanner )) - { - /* file might still be open so close it in any case - e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */ - fclose( yyget_in( scanner ) ); - yyset_in( NULL, scanner ); - } - free( yyget_extra( scanner ) ); - yylex_destroy( scanner ); + if (yyget_in (scanner)) + { + /* file might still be open so close it in any case + e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */ + fclose (yyget_in (scanner)); + yyset_in (NULL, scanner); + } + free (yyget_extra (scanner)); + yylex_destroy (scanner); } @@ -422,14 +428,15 @@ void urj_vhdl_flex_deinit( void *scanner ) * Returns * 1 ****************************************************************************/ -int yywrap( yyscan_t scanner ) +int +yywrap (yyscan_t scanner) { - if (yyget_in( scanner )) - { - fclose( yyget_in( scanner ) ); - yyset_in( NULL, scanner ); - } - return 1; + if (yyget_in (scanner)) + { + fclose (yyget_in (scanner)); + yyset_in (NULL, scanner); + } + return 1; } @@ -445,22 +452,24 @@ int yywrap( yyscan_t scanner ) * Returns * pointer to allocated and initialized string memory ****************************************************************************/ -static char *new_string( urj_bsdl_scan_extra_t *extra, const char *str ) +static char * +new_string (urj_bsdl_scan_extra_t * extra, const char *str) { - char *n_str; - size_t n_str_size; - - n_str_size = strlen( str ) + 1; - if ((n_str = malloc( n_str_size ))) - { - strncpy( n_str, str, n_str_size-1 ); - n_str[n_str_size-1] = '\0'; /* set very last element to EOS */ - } - else - urj_bsdl_msg( extra->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); - - return n_str; + char *n_str; + size_t n_str_size; + + n_str_size = strlen (str) + 1; + if ((n_str = malloc (n_str_size))) + { + strncpy (n_str, str, n_str_size - 1); + n_str[n_str_size - 1] = '\0'; /* set very last element to EOS */ + } + else + urj_bsdl_msg (extra->proc_mode, + BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), + __FILE__, __LINE__); + + return n_str; } @@ -476,55 +485,56 @@ static char *new_string( urj_bsdl_scan_extra_t *extra, const char *str ) * Returns * void ****************************************************************************/ -void urj_vhdl_flex_switch_file( yyscan_t scanner, char *filename ) +void +urj_vhdl_flex_switch_file (yyscan_t scanner, char *filename) { - urj_bsdl_scan_extra_t *extra; - FILE *f; - char *s; - - /* convert filename to all upper case */ - s = filename; - while (*s) - { - if (islower( *s )) - *s = toupper( *s ); - s++; - } - - extra = yyget_extra( scanner ); - - /* file in current directory has precedence */ - f = fopen( filename, "r" ); - if (!f) - { - const char *db_path = urj_get_data_dir(); - char *db_file; - - if ((db_file = malloc( strlen( db_path ) + - 1 + /* "/" */ - 4 + /* "bsdl" */ - 1 + /* "/" */ - strlen( filename ) + - 1 ))) + urj_bsdl_scan_extra_t *extra; + FILE *f; + char *s; + + /* convert filename to all upper case */ + s = filename; + while (*s) + { + if (islower (*s)) + *s = toupper (*s); + s++; + } + + extra = yyget_extra (scanner); + + /* file in current directory has precedence */ + f = fopen (filename, "r"); + if (!f) { - strcpy( db_file, db_path ); - strcat( db_file, "/" ); - strcat( db_file, "bsdl" ); - strcat( db_file, "/" ); - strcat( db_file, filename ); - f = fopen( db_file, "r" ); - - if (!f) - urj_bsdl_msg( extra->proc_mode, - BSDL_MSG_FATAL, _("Cannot open file %s or %s.\n"), filename, db_file ); - free( db_file ); - if (!f) - return; + const char *db_path = urj_get_data_dir (); + char *db_file; + + if ((db_file = malloc (strlen (db_path) + 1 + /* "/" */ + 4 + /* "bsdl" */ + 1 + /* "/" */ + strlen (filename) + 1))) + { + strcpy (db_file, db_path); + strcat (db_file, "/"); + strcat (db_file, "bsdl"); + strcat (db_file, "/"); + strcat (db_file, filename); + f = fopen (db_file, "r"); + + if (!f) + urj_bsdl_msg (extra->proc_mode, + BSDL_MSG_FATAL, + _("Cannot open file %s or %s.\n"), filename, + db_file); + free (db_file); + if (!f) + return; + } } - } - yypush_buffer_state( yy_create_buffer( f, YY_BUF_SIZE, scanner ), scanner ); - yyset_lineno( 1, scanner ); + yypush_buffer_state (yy_create_buffer (f, YY_BUF_SIZE, scanner), scanner); + yyset_lineno (1, scanner); } @@ -539,10 +549,11 @@ void urj_vhdl_flex_switch_file( yyscan_t scanner, char *filename ) * Returns * number of compile errors ****************************************************************************/ -int urj_vhdl_flex_get_compile_errors( yyscan_t scanner ) +int +urj_vhdl_flex_get_compile_errors (yyscan_t scanner) { - urj_bsdl_scan_extra_t *extra = yyget_extra( scanner ); - return extra->Compile_Errors; + urj_bsdl_scan_extra_t *extra = yyget_extra (scanner); + return extra->Compile_Errors; } @@ -558,10 +569,11 @@ int urj_vhdl_flex_get_compile_errors( yyscan_t scanner ) * Returns * void ****************************************************************************/ -static void urj_vhdl_flex_set_compile_errors( int n, yyscan_t scanner ) +static void +urj_vhdl_flex_set_compile_errors (int n, yyscan_t scanner) { - urj_bsdl_scan_extra_t *extra = yyget_extra( scanner ); - extra->Compile_Errors = n; + urj_bsdl_scan_extra_t *extra = yyget_extra (scanner); + extra->Compile_Errors = n; } @@ -576,12 +588,13 @@ static void urj_vhdl_flex_set_compile_errors( int n, yyscan_t scanner ) * Returns * number of compile errors before increment ****************************************************************************/ -int urj_vhdl_flex_postinc_compile_errors( yyscan_t scanner ) +int +urj_vhdl_flex_postinc_compile_errors (yyscan_t scanner) { - int errors = urj_vhdl_flex_get_compile_errors( scanner ); + int errors = urj_vhdl_flex_get_compile_errors (scanner); - urj_vhdl_flex_set_compile_errors( errors+1, scanner ); - return errors; + urj_vhdl_flex_set_compile_errors (errors + 1, scanner); + return errors; } @@ -596,9 +609,10 @@ int urj_vhdl_flex_postinc_compile_errors( yyscan_t scanner ) * Returns * current line number ****************************************************************************/ -int urj_vhdl_flex_get_lineno( yyscan_t scanner ) +int +urj_vhdl_flex_get_lineno (yyscan_t scanner) { - return yyget_lineno( scanner ); + return yyget_lineno (scanner); } diff --git a/urjtag/src/svf/svf.c b/urjtag/src/svf/svf.c index 99fa18da..3a3c5ded 100644 --- a/urjtag/src/svf/svf.c +++ b/urjtag/src/svf/svf.c @@ -1123,7 +1123,7 @@ urj_svf_txr (enum URJ_SVF_generic_irdr_coding ir_dr, * 0 : error occurred * ***************************************************************************/ void -urj_svf_run (urj_chain_t *chain, FILE * SVF_FILE, int stop_on_mismatch, +urj_svf_run (urj_chain_t *chain, FILE *SVF_FILE, int stop_on_mismatch, int print_progress, uint32_t ref_freq) { const urj_svf_sxr_t sxr_default = { {0.0, NULL, NULL, NULL, NULL}, diff --git a/urjtag/src/svf/svf_bison.y b/urjtag/src/svf/svf_bison.y index ca13f675..98d6a96b 100644 --- a/urjtag/src/svf/svf_bison.y +++ b/urjtag/src/svf/svf_bison.y @@ -405,60 +405,64 @@ direction | INOUT ; -%% - - -void -yyerror(YYLTYPE *locp, urj_svf_parser_priv_t *priv_data, urj_chain_t *chain, const char *error_string) +%% void +yyerror (YYLTYPE *locp, urj_svf_parser_priv_t *priv_data, urj_chain_t *chain, + const char *error_string) { - printf("Error occurred for SVF command %s.\n", error_string); + printf ("Error occurred for SVF command %s.\n", error_string); } static void -urj_svf_free_ths_params(struct ths_params *params) +urj_svf_free_ths_params (struct ths_params *params) { - params->number = 0.0; - - if (params->tdi) { - free(params->tdi); - params->tdi = NULL; - } - if (params->tdo) { - free(params->tdo); - params->tdo = NULL; - } - if (params->mask) { - free(params->mask); - params->mask = NULL; - } - if (params->smask) { - free(params->smask); - params->smask = NULL; - } + params->number = 0.0; + + if (params->tdi) + { + free (params->tdi); + params->tdi = NULL; + } + if (params->tdo) + { + free (params->tdo); + params->tdo = NULL; + } + if (params->mask) + { + free (params->mask); + params->mask = NULL; + } + if (params->smask) + { + free (params->smask); + params->smask = NULL; + } } int -urj_svf_bison_init(urj_svf_parser_priv_t *priv_data, FILE *f, int num_lines, int print_progress) +urj_svf_bison_init (urj_svf_parser_priv_t *priv_data, FILE *f, int num_lines, + int print_progress) { - const struct svf_parser_params params = { - {0.0, NULL, NULL, NULL, NULL}, - {{}, 0}, - {0, 0.0, 0, 0, 0, 0} - }; - - priv_data->parser_params = params; - - if ((priv_data->scanner = urj_svf_flex_init(f, num_lines, print_progress)) == NULL) - return 0; - else - return 1; + const struct svf_parser_params params = { + {0.0, NULL, NULL, NULL, NULL}, + {{}, 0}, + {0, 0.0, 0, 0, 0, 0} + }; + + priv_data->parser_params = params; + + if ((priv_data->scanner = + urj_svf_flex_init (f, num_lines, print_progress)) == NULL) + return 0; + else + return 1; } void -urj_svf_bison_deinit(urj_svf_parser_priv_t *priv_data) +urj_svf_bison_deinit (urj_svf_parser_priv_t *priv_data) { - urj_svf_flex_deinit(priv_data->scanner); + urj_svf_flex_deinit (priv_data->scanner); } diff --git a/urjtag/src/svf/svf_flex.l b/urjtag/src/svf/svf_flex.l index 7f1cb498..aa1ed852 100644 --- a/urjtag/src/svf/svf_flex.l +++ b/urjtag/src/svf/svf_flex.l @@ -217,185 +217,198 @@ COMMENT (!.*)|("//".*)[^\n] *===========================================================================*/ static struct rwtable { - char *rw_name; - int rw_yylex; -} rwtable[] = { - {"ABSENT", ABSENT}, - {"D", D}, - {"DRCAPTURE", DRCAPTURE}, - {"DREXIT1", DREXIT1}, - {"DREXIT2", DREXIT2}, - {"DRPAUSE", DRPAUSE}, - {"DRSELECT", DRSELECT}, - {"DRSHIFT", DRSHIFT}, - {"DRUPDATE", DRUPDATE}, - {"EMPTY", EMPTY}, - {"ENDDR", ENDDR}, - {"ENDIR", ENDIR}, - {"ENDSTATE", ENDSTATE}, - {"FREQUENCY", FREQUENCY}, - {"H", H}, - {"HDR", HDR}, - {"HIR", HIR}, - {"HZ", HZ}, - {"URJ_JIM_IDLE", URJ_JIM_IDLE}, - {"IN", IN}, - {"INOUT", INOUT}, - {"IRCAPTURE", IRCAPTURE}, - {"IREXIT1", IREXIT1}, - {"IREXIT2", IREXIT2}, - {"IRPAUSE", IRPAUSE}, - {"IRSELECT", IRSELECT}, - {"IRSHIFT", IRSHIFT}, - {"IRUPDATE", IRUPDATE}, - {"L", L}, - {"MASK", MASK}, - {"MAXIMUM", MAXIMUM}, - {"OFF", OFF}, - {"ON", ON}, - {"OUT", OUT}, - {"PIO", PIO}, - {"PIOMAP", PIOMAP}, - {"URJ_JIM_RESET", URJ_JIM_RESET}, - {"RUNTEST", RUNTEST}, - {"SCK", SCK}, - {"SDR", SDR}, - {"SEC", SEC}, - {"SIR", SIR}, - {"SMASK", SMASK}, - {"STATE", STATE}, - {"TCK", TCK}, - {"TDI", TDI}, - {"TDO", TDO}, - {"TDR", TDR}, - {"TIR", TIR}, - {"TRST", TRST}, - {"U", U}, - {"X", X}, - {"Z", Z} -};//end of rwtable struct - -#define END(v) (sizeof(v) / sizeof(v[0]) - 1) + char *rw_name; + int rw_yylex; +} rwtable[] = +{ + { "ABSENT", ABSENT }, + { "D", D }, + { "DRCAPTURE", DRCAPTURE }, + { "DREXIT1", DREXIT1 }, + { "DREXIT2", DREXIT2 }, + { "DRPAUSE", DRPAUSE }, + { "DRSELECT", DRSELECT }, + { "DRSHIFT", DRSHIFT }, + { "DRUPDATE", DRUPDATE }, + { "EMPTY", EMPTY }, + { "ENDDR", ENDDR }, + { "ENDIR", ENDIR }, + { "ENDSTATE", ENDSTATE }, + { "FREQUENCY", FREQUENCY }, + { "H", H }, + { "HDR", HDR }, + { "HIR", HIR }, + { "HZ", HZ }, + { "URJ_JIM_IDLE", URJ_JIM_IDLE }, + { "IN", IN }, + { "INOUT", INOUT }, + { "IRCAPTURE", IRCAPTURE }, + { "IREXIT1", IREXIT1 }, + { "IREXIT2", IREXIT2 }, + { "IRPAUSE", IRPAUSE }, + { "IRSELECT", IRSELECT }, + { "IRSHIFT", IRSHIFT }, + { "IRUPDATE", IRUPDATE }, + { "L", L }, + { "MASK", MASK }, + { "MAXIMUM", MAXIMUM }, + { "OFF", OFF }, + { "ON", ON }, + { "OUT", OUT }, + { "PIO", PIO }, + { "PIOMAP", PIOMAP }, + { "URJ_JIM_RESET", URJ_JIM_RESET }, + { "RUNTEST", RUNTEST }, + { "SCK", SCK }, + { "SDR", SDR }, + { "SEC", SEC }, + { "SIR", SIR }, + { "SMASK", SMASK }, + { "STATE", STATE }, + { "TCK", TCK }, + { "TDI", TDI }, + { "TDO", TDO }, + { "TDR", TDR }, + { "TIR", TIR }, + { "TRST", TRST }, + { "U", U }, + { "X", X }, + { "Z", Z } +}; //end of rwtable struct + +#define END(v) (sizeof(v) / sizeof((v)[0]) - 1) static int -map_keyw_ident(YYSTYPE * mylval, char *str) +map_keyw_ident (YYSTYPE *mylval, char *str) { - int idx; - int rw = IDENTIFIER; - - mylval->cvalue = str; - - for (idx = 0; idx <= END(rwtable); idx++) { - if (strcasecmp(rwtable[idx].rw_name, str) == 0) { - /* always return terminal value as semantic value */ - rw = rwtable[idx].rw_yylex; - mylval->token = rw; + int idx; + int rw = IDENTIFIER; + + mylval->cvalue = str; + + for (idx = 0; idx <= END (rwtable); idx++) + { + if (strcasecmp (rwtable[idx].rw_name, str) == 0) + { + /* always return terminal value as semantic value */ + rw = rwtable[idx].rw_yylex; + mylval->token = rw; + } } - } - return(rw); + return (rw); } static void -align_string(char *str) +align_string (char *str) { - int src, dst, len; + int src, dst, len; - dst = 0; - len = strlen(str); + dst = 0; + len = strlen (str); - for (src = 0; src < len; src++) { - if (isxdigit(str[src])) - str[dst++] = str[src]; - } - str[dst] = '\0'; + for (src = 0; src < len; src++) + { + if (isxdigit (str[src])) + str[dst++] = str[src]; + } + str[dst] = '\0'; } static void -fix_yylloc(YYLTYPE * mylloc, char *str) +fix_yylloc (YYLTYPE *mylloc, char *str) { - mylloc->first_line = mylloc->last_line; - mylloc->first_column = mylloc->last_column; - mylloc->last_column += strlen(str); + mylloc->first_line = mylloc->last_line; + mylloc->first_column = mylloc->last_column; + mylloc->last_column += strlen (str); } static void -fix_yylloc_nl(YYLTYPE * mylloc, char *str, YY_EXTRA_TYPE extra) +fix_yylloc_nl (YYLTYPE *mylloc, char *str, YY_EXTRA_TYPE extra) { - char *p; - - mylloc->first_line = mylloc->last_line; - mylloc->first_column = mylloc->last_column; - for (p = str; *p; ++p) { - if (*p == '\n') { - mylloc->last_column = 0; - ++mylloc->last_line; - progress_nl(mylloc, extra); - } else { - ++mylloc->last_column; + char *p; + + mylloc->first_line = mylloc->last_line; + mylloc->first_column = mylloc->last_column; + for (p = str; *p; ++p) + { + if (*p == '\n') + { + mylloc->last_column = 0; + ++mylloc->last_line; + progress_nl (mylloc, extra); + } + else + { + ++mylloc->last_column; + } } - } } static void -progress_nl(YYLTYPE * mylloc, YY_EXTRA_TYPE extra) +progress_nl (YYLTYPE *mylloc, YY_EXTRA_TYPE extra) { - int percent; - - if ((extra->print_progress) && (mylloc->last_line % 10==0)) { - percent = ((mylloc->last_line * 100) + 1) / extra->num_lines; - if (percent <= 1) return; // dont bother printing < 1 % - printf( "\r" ); - printf( _("Parsing %6d/%d (%3.0d%%)"), - mylloc->last_line, extra->num_lines, percent); - } + int percent; + + if ((extra->print_progress) && (mylloc->last_line % 10 == 0)) + { + percent = ((mylloc->last_line * 100) + 1) / extra->num_lines; + if (percent <= 1) + return; // dont bother printing < 1 % + printf ("\r"); + printf (_("Parsing %6d/%d (%3.0d%%)"), + mylloc->last_line, extra->num_lines, percent); + } } -void *urj_svf_flex_init(FILE *f, int num_lines, int print_progress) +void * +urj_svf_flex_init (FILE *f, int num_lines, int print_progress) { - YY_EXTRA_TYPE extra; - yyscan_t scanner; + YY_EXTRA_TYPE extra; + yyscan_t scanner; - /* get our scanner structure */ - if (yylex_init(&scanner) != 0) - return NULL; + /* get our scanner structure */ + if (yylex_init (&scanner) != 0) + return NULL; - yyset_in(f, scanner); + yyset_in (f, scanner); - if (!(extra = malloc(sizeof(urj_svf_scanner_extra_t)))) { - printf( _("Out of memory, %s line %i\n"), __FILE__, __LINE__ ); - yylex_destroy(scanner); - return NULL; - } + if (!(extra = malloc (sizeof (urj_svf_scanner_extra_t)))) + { + printf (_("Out of memory, %s line %i\n"), __FILE__, __LINE__); + yylex_destroy (scanner); + return NULL; + } - extra->num_lines = num_lines; - extra->print_progress = print_progress; + extra->num_lines = num_lines; + extra->print_progress = print_progress; #ifdef ENABLE_NLS - { - struct lconv *lc = localeconv(); - extra->decimal_point = lc->decimal_point[0]; - } + { + struct lconv *lc = localeconv (); + extra->decimal_point = lc->decimal_point[0]; + } #else - extra->decimal_point = '.'; + extra->decimal_point = '.'; #endif - yyset_extra(extra, scanner); + yyset_extra (extra, scanner); - return scanner; + return scanner; } -void urj_svf_flex_deinit(void *scanner) +void +urj_svf_flex_deinit (void *scanner) { - YY_EXTRA_TYPE extra = yyget_extra(scanner); - if (extra->print_progress) - printf("\n"); - free(extra); - yylex_destroy(scanner); + YY_EXTRA_TYPE extra = yyget_extra (scanner); + if (extra->print_progress) + printf ("\n"); + free (extra); + yylex_destroy (scanner); }