Basic elaboration of vhdl component instantiations.

This gets us as far as emiting a component instantiation. Very little
error checking/elaboration is done, so there is room for improvement,
but this is a working stub.
This commit is contained in:
Stephen Williams 2011-03-31 19:11:48 -07:00
commit 9fbcc895a8
3 changed files with 92 additions and 5 deletions

View File

@ -101,6 +101,11 @@ ExpName::~ExpName()
delete index_;
}
const char* ExpName::name() const
{
return name_;
}
ExpUAbs::ExpUAbs(Expression*op1)
: ExpUnary(op1)
{

View File

@ -163,6 +163,7 @@ class ExpName : public Expression {
int emit(ostream&out, Entity*ent, Architecture*arc);
bool is_primary(void) const;
void dump(ostream&out, int indent) const;
const char* name() const;
private:
perm_string name_;

View File

@ -30,8 +30,10 @@
# include "vsignal.h"
# include "vtype.h"
# include <cstdarg>
# include <cstring>
# include <list>
# include <map>
# include <vector>
# include "parse_types.h"
# include <assert.h>
@ -78,11 +80,13 @@ static map<perm_string, ComponentBase*> block_components;
char*text;
std::list<perm_string>* name_list;
std::vector<perm_string>* compound_name;
std::list<std::vector<perm_string>* >* compound_name_list;
bool flag;
int64_t uni_integer;
double uni_real;
Expression*expr;
std::list<Expression*>* expr_list;
@ -154,8 +158,10 @@ static map<perm_string, ComponentBase*> block_components;
%type <vtype> subtype_indication
%type <text> identifier_opt logical_name
%type <text> identifier_opt logical_name suffix
%type <name_list> logical_name_list identifier_list
%type <compound_name> prefix selected_name
%type <compound_name_list> selected_names use_clause
%%
@ -357,6 +363,9 @@ configuration_declaration
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 ';'
@ -422,7 +431,7 @@ context_clause : context_items | ;
context_item
: library_clause
| use_clause
| use_clause_lib
;
context_items
@ -446,8 +455,8 @@ direction : K_to { $$ = false; } | K_downto { $$ = true; } ;
/* As an entity is declared, add it to the map of design entities. */
entity_aspect
: K_entity IDENTIFIER {sorrymsg(@1, "Entity aspect not yet supported.\n"); delete $2;}
| K_configuration IDENTIFIER {sorrymsg(@1, "Instatiation lists not yet supported.\n"); delete $2;}
: 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_open
;
@ -814,6 +823,27 @@ port_map_aspect_opt
| { $$ = 0; }
;
prefix
: IDENTIFIER
{
std::vector<perm_string>* tmp = new std::vector<perm_string>();
tmp->push_back(lex_strings.make($1));
delete[] $1;
$$ = tmp;
}
| STRING_LITERAL
{
std::vector<perm_string>* tmp = new std::vector<perm_string>();
tmp->push_back(lex_strings.make($1));
delete[] $1;
$$ = tmp;
}
| selected_name
{
$$ = $1;
}
;
primary
: name
{ $$ = $1; }
@ -838,6 +868,32 @@ secondary_unit
: architecture_body
| package_body
;
selected_name
: prefix '.' suffix
{
std::vector<perm_string>* tmp = $1;
tmp->push_back(lex_strings.make($3));
delete[] $3;
$$ = tmp;
}
;
selected_names
: selected_names ',' selected_name
{
std::list<std::vector<perm_string>* >* tmp = $1;
tmp->push_back($3);
$$ = tmp;
}
| selected_name
{
std::list<std::vector<perm_string>* >* tmp = new std::list<std::vector<perm_string>* >();
tmp->push_back($1);
$$ = tmp;
}
;
/* The *_use variant of selected_name is used by the "use"
clause. It is syntactically identical to other selected_name
rules, but is a convenient place to attach use_clause actions. */
@ -888,6 +944,22 @@ subtype_indication
}
;
suffix
: IDENTIFIER
{
$$ = $1;
}
| CHARACTER_LITERAL
{
$$ = $1;
}
| K_all
{
//do not have now better idea than using char constant
$$ = strcpy(new char[strlen("all"+1)], "all");
}
;
term
: factor
{ $$ = $1; }
@ -914,6 +986,15 @@ term
;
use_clause
: K_use selected_names ';'
{
$$ = $2;
}
| K_use error ';'
{ errormsg(@1, "Syntax error in use clause.\n"); yyerrok; }
;
use_clause_lib
: K_use selected_names_use ';'
| K_use error ';'
{ errormsg(@1, "Syntax error in use clause.\n"); yyerrok; }