From 26e6865bef50dad03398d243ba4b43385a0c9649 Mon Sep 17 00:00:00 2001 From: Pawel Szostek Date: Thu, 31 Mar 2011 15:19:42 +0200 Subject: [PATCH 1/5] Add entity aspects to VHDL parsing Entity aspects are now recognized and parsed into corresponding objects. A new class (entity_aspect) has been added. --- vhdlpp/parse.y | 29 ++++++++++++++++++++++++----- vhdlpp/parse_types.h | 14 ++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index cea3be383..2cf077eaf 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -92,6 +92,7 @@ static map block_components; named_expr_t*named_expr; std::list*named_expr_list; + entity_aspect_t* entity_aspect; const VType* vtype; @@ -142,6 +143,8 @@ static map block_components; %type port_clause port_clause_opt %type mode +%type entity_aspect entity_aspect_opt + %type concurrent_statement component_instantiation_statement concurrent_signal_assignment_statement %type architecture_statement_part @@ -240,11 +243,13 @@ association_list } ; -//TODO: this list is only a sketch binding_indication : K_use entity_aspect_opt port_map_aspect_opt generic_map_aspect_opt + { + sorrymsg(@1, "Binding indication is not supported.\n"); + } ; binding_indication_semicolon_opt @@ -455,14 +460,28 @@ direction : K_to { $$ = false; } | K_downto { $$ = true; } ; /* As an entity is declared, add it to the map of design entities. */ entity_aspect - : K_entity name {sorrymsg(@1, "Entity aspect not yet supported.\n"); delete $2;} - | K_configuration name {sorrymsg(@1, "Entity aspect not yet supported.\n"); delete $2;} + : K_entity name + { + ExpName* name = dynamic_cast($2); + entity_aspect_t* tmp = new entity_aspect_t(entity_aspect_t::ENTITY, name); + $$ = tmp; + } + | K_configuration name + { + ExpName* name = dynamic_cast($2); + entity_aspect_t* tmp = new entity_aspect_t(entity_aspect_t::CONFIGURATION, name); + $$ = tmp; + } | K_open + { + entity_aspect_t* tmp = new entity_aspect_t(entity_aspect_t::OPEN, 0); + $$ = tmp; + } ; entity_aspect_opt - : entity_aspect - | + : entity_aspect { $$ = $1; } + | { $$ = 0; } ; entity_declaration diff --git a/vhdlpp/parse_types.h b/vhdlpp/parse_types.h index 71120d7d1..5256e997d 100644 --- a/vhdlpp/parse_types.h +++ b/vhdlpp/parse_types.h @@ -38,4 +38,18 @@ class named_expr_t { named_expr_t& operator = (const named_expr_t&); }; +class entity_aspect_t { + public: + typedef enum { ENTITY = 0, CONFIGURATION, OPEN } entity_aspect_type_t; + + entity_aspect_t(entity_aspect_type_t t, ExpName* n) : type_(t), name_(n) {} + ~entity_aspect_t() { delete name_; } + + ExpName* name() const { return name_; } + entity_aspect_type_t type() const {return type_; } + + entity_aspect_type_t type_; + ExpName* name_; +}; + #endif From 2af35040cc92537fd7e43d23a0b3ea0e10d6d7a2 Mon Sep 17 00:00:00 2001 From: Pawel Szostek Date: Thu, 31 Mar 2011 15:22:55 +0200 Subject: [PATCH 2/5] Fix constructs sequence in bison file for VHDL --- vhdlpp/parse.y | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index 2cf077eaf..2ceec9511 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -362,24 +362,6 @@ component_specification } ; -configuration_declaration - : K_configuration IDENTIFIER K_of IDENTIFIER K_is - configuration_declarative_part - block_configuration - K_end K_configuration_opt identifier_opt ';' - { - if(design_entities.find(lex_strings.make($4)) == design_entities.end()) - errormsg(@4, "Couldn't find entity %s used in configuration declaration", $4); - //choose_architecture_for_entity(); - sorrymsg(@1, "Configuration declaration is not yet supported.\n"); - } - | K_configuration error K_end K_configuration_opt identifier_opt ';' - { errormsg(@2, "Too many errors, giving up on configuration declaration.\n"); - if($5) delete $5; - yyerrok; - } - ; - concurrent_signal_assignment_statement : name LEQ waveform ';' { ExpName*name = dynamic_cast ($1); @@ -402,6 +384,24 @@ concurrent_statement : component_instantiation_statement | concurrent_signal_assignment_statement ; + +configuration_declaration + : K_configuration IDENTIFIER K_of IDENTIFIER K_is + configuration_declarative_part + block_configuration + K_end K_configuration_opt identifier_opt ';' + { + if(design_entities.find(lex_strings.make($4)) == design_entities.end()) + errormsg(@4, "Couldn't find entity %s used in configuration declaration", $4); + //choose_architecture_for_entity(); + sorrymsg(@1, "Configuration declaration is not yet supported.\n"); + } + | K_configuration error K_end K_configuration_opt identifier_opt ';' + { errormsg(@2, "Too many errors, giving up on configuration declaration.\n"); + if($5) delete $5; + yyerrok; + } + ; //TODO: this list is only a sketch. It must be filled out later configuration_declarative_item : use_clause From 830b7cf122905055c8ab4427f8060c6cd4714ac3 Mon Sep 17 00:00:00 2001 From: Pawel Szostek Date: Thu, 31 Mar 2011 17:02:44 +0200 Subject: [PATCH 3/5] Add basic instantiation list handling in VHDL A class for representing instantiation list has been added. --- vhdlpp/parse.y | 29 ++++++++++++++++++----------- vhdlpp/parse_types.h | 13 +++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index 2ceec9511..72e632fe8 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -93,6 +93,7 @@ static map block_components; named_expr_t*named_expr; std::list*named_expr_list; entity_aspect_t* entity_aspect; + instant_list_t* instantiation_list; const VType* vtype; @@ -143,7 +144,8 @@ static map block_components; %type port_clause port_clause_opt %type mode -%type entity_aspect entity_aspect_opt +%type entity_aspect entity_aspect_opt binding_indication binding_indication_semicolon_opt +%type instantiation_list %type concurrent_statement component_instantiation_statement concurrent_signal_assignment_statement %type architecture_statement_part @@ -247,14 +249,14 @@ binding_indication : K_use entity_aspect_opt port_map_aspect_opt generic_map_aspect_opt - { - sorrymsg(@1, "Binding indication is not supported.\n"); - } + { //TODO: do sth with generic map aspect + $$ = $2; + } ; binding_indication_semicolon_opt - : binding_indication ';' - | + : binding_indication ';' { $$ = $1; } + | { $$ = 0; } ; block_configuration @@ -665,14 +667,19 @@ identifier_opt : IDENTIFIER { $$ = $1; } | { $$ = 0; } ; instantiation_list : identifier_list - { - sorrymsg(@1, "Instatiation lists not yet supported"); - delete $1; - } + { + instant_list_t* tmp = new instant_list_t(instant_list_t::NONE, $1); + $$ = tmp; + } | K_others + { + instant_list_t* tmp = new instant_list_t(instant_list_t::OTHERS, 0); + $$ = tmp; + } | K_all { - sorrymsg(@1, "Instatiation lists not yet supported"); + instant_list_t* tmp = new instant_list_t(instant_list_t::ALL, 0); + $$ = tmp; } ; diff --git a/vhdlpp/parse_types.h b/vhdlpp/parse_types.h index 5256e997d..48af8654b 100644 --- a/vhdlpp/parse_types.h +++ b/vhdlpp/parse_types.h @@ -52,4 +52,17 @@ class entity_aspect_t { ExpName* name_; }; +class instant_list_t { + public: + typedef enum { ALL = 0, OTHERS, NONE } application_domain_t; + + instant_list_t(application_domain_t d, std::list* l) : domain_(d), labels_(l) {} + ~instant_list_t() { delete labels_; } + + std::list* labels() const { return labels_; } + application_domain_t domain() const { return domain_; } + + application_domain_t domain_; + std::list* labels_; +}; #endif From cef37e0a4bc3b460d7f42346769952e2c5195d84 Mon Sep 17 00:00:00 2001 From: Pawel Szostek Date: Fri, 1 Apr 2011 09:50:04 +0200 Subject: [PATCH 4/5] Add component specification parsing A class for component specification has been added --- vhdlpp/parse.y | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index 72e632fe8..4a2ca20bf 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -94,6 +94,7 @@ static map block_components; std::list*named_expr_list; entity_aspect_t* entity_aspect; instant_list_t* instantiation_list; + std::pair* component_specification; const VType* vtype; @@ -146,6 +147,7 @@ static map block_components; %type entity_aspect entity_aspect_opt binding_indication binding_indication_semicolon_opt %type instantiation_list +%type component_specification %type concurrent_statement component_instantiation_statement concurrent_signal_assignment_statement %type architecture_statement_part @@ -337,6 +339,10 @@ component_configuration binding_indication_semicolon_opt block_configuration_opt K_end K_for ';' + | K_for component_specification error K_end K_for + { + errormsg(@1, "Error in component configuration statement.\n"); + } ; component_instantiation_statement @@ -358,9 +364,11 @@ component_instantiation_statement ; component_specification - : instantiation_list ':' IDENTIFIER - { sorrymsg(@1, "Component specifications are not supported.\n"); - delete[] $3 + : instantiation_list ':' name + { + ExpName* name = dynamic_cast($3); + std::pair* tmp = new std::pair($1, name); + $$ = tmp; } ; From 9bdc040520e25dc9c3d93390aae5e51f3d05d8d8 Mon Sep 17 00:00:00 2001 From: Pawel Szostek Date: Fri, 1 Apr 2011 16:29:47 +0200 Subject: [PATCH 5/5] Add missing ``sorry'' messages in VHDL parsing --- vhdlpp/parse.y | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index 4a2ca20bf..f42e217c1 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -339,9 +339,15 @@ component_configuration binding_indication_semicolon_opt block_configuration_opt K_end K_for ';' + { + sorrymsg(@1, "Component configuration in not yet supported"); + if($3) delete $3; + delete $2; + } | K_for component_specification error K_end K_for { errormsg(@1, "Error in component configuration statement.\n"); + delete $2; } ; @@ -653,6 +659,9 @@ generic_map_aspect_opt generic_map_aspect : K_generic K_map '(' association_list ')' + { + sorrymsg(@1, "Generic map aspect not yet supported.\n"); + } ; identifier_list @@ -789,7 +798,7 @@ package_declaration } delete $2; } - | K_package error K_end K_package_opt identifier_opt ';' + | K_package IDENTIFIER K_is error K_end K_package_opt identifier_opt ';' { errormsg(@2, "Syntax error in package clause.\n"); yyerrok; } @@ -830,9 +839,17 @@ package_body package_body_declarative_part_opt K_end K_package_opt identifier_opt ';' { + sorrymsg(@1, "Package body is not yet supported.\n"); delete[] $3; if($8) delete[] $8; } + + | K_package K_body IDENTIFIER K_is + error + K_end K_package_opt identifier_opt ';' + { + errormsg(@1, "Errors in package body.\n"); + } ; port_clause @@ -850,6 +867,10 @@ port_clause_opt : port_clause {$$ = $1;} | {$$ = 0;} ; port_map_aspect : K_port K_map '(' association_list ')' { $$ = $4; } + | K_port K_map '(' error ')' + { + errormsg(@1, "Syntax error in port map aspect.\n"); + } ; port_map_aspect_opt @@ -976,6 +997,10 @@ subtype_indication delete[]$1; $$ = tmp; } + | IDENTIFIER '(' error ')' + { + errormsg(@1, "Syntax error in subtype indication.\n"); + } ; suffix