Merge pull request #67 from orsonmmz/boolean
Boolean & asserts for vhdlpp
This commit is contained in:
commit
7442c14689
|
|
@ -1027,19 +1027,18 @@ const VType* ExpName::probe_type(Entity*ent, ScopeBase*scope) const
|
|||
if (Variable*var = scope->find_variable(name_))
|
||||
return var->peek_type();
|
||||
|
||||
const VType*ctype = 0;
|
||||
const VType*type = 0;
|
||||
Expression*cval = 0;
|
||||
if (scope->find_constant(name_, ctype, cval))
|
||||
return ctype;
|
||||
if (scope->find_constant(name_, type, cval))
|
||||
return type;
|
||||
|
||||
const VType*gtype = 0;
|
||||
Architecture*arc = dynamic_cast<Architecture*>(scope);
|
||||
if (arc && (gtype = arc->probe_genvar_type(name_))) {
|
||||
return gtype;
|
||||
if (arc && (type = arc->probe_genvar_type(name_))) {
|
||||
return type;
|
||||
}
|
||||
|
||||
if (scope->is_enum_name(name_)) {
|
||||
return &primitive_INTEGER;
|
||||
if ((type = scope->is_enum_name(name_))) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -404,11 +404,19 @@ void generate_global_types(ActiveScope*res)
|
|||
res->use_name(perm_string::literal("real"), &primitive_REAL);
|
||||
res->use_name(perm_string::literal("std_logic"), &primitive_STDLOGIC);
|
||||
res->use_name(perm_string::literal("character"), &primitive_CHARACTER);
|
||||
res->use_name(perm_string::literal("bit_vector"),&primitive_BOOL_VECTOR);
|
||||
res->use_name(perm_string::literal("bit_vector"),&primitive_BIT_VECTOR);
|
||||
res->use_name(perm_string::literal("string"), &primitive_STRING);
|
||||
res->use_name(perm_string::literal("natural"), &primitive_NATURAL);
|
||||
}
|
||||
|
||||
void emit_std_types(ostream&out)
|
||||
{
|
||||
out << "`ifndef __VHDL_STD_TYPES" << endl;
|
||||
out << "`define __VHDL_STD_TYPES" << endl;
|
||||
out << "typedef enum bit { \\false , \\true } boolean ;" << endl;
|
||||
out << "`endif" << endl;
|
||||
}
|
||||
|
||||
bool is_global_type(perm_string name)
|
||||
{
|
||||
if (name == "boolean") return true;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ extern void library_add_directory(const char*directory);
|
|||
|
||||
extern Subprogram*library_find_subprogram(perm_string name);
|
||||
|
||||
extern void emit_std_types(ostream&out);
|
||||
extern int emit_packages(void);
|
||||
|
||||
#endif /* IVL_library_H */
|
||||
|
|
|
|||
|
|
@ -232,6 +232,8 @@ int main(int argc, char*argv[])
|
|||
return 3;
|
||||
}
|
||||
|
||||
emit_std_types(cout);
|
||||
|
||||
errors = emit_packages();
|
||||
if (errors > 0) {
|
||||
fprintf(stderr, "%d errors emitting packages.\n", errors);
|
||||
|
|
|
|||
|
|
@ -188,15 +188,15 @@ Subprogram* ScopeBase::find_subprogram(perm_string name) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool ScopeBase::is_enum_name(perm_string name) const
|
||||
const VTypeEnum* ScopeBase::is_enum_name(perm_string name) const
|
||||
{
|
||||
for(list<const VTypeEnum*>::const_iterator it = use_enums_.begin();
|
||||
it != use_enums_.end(); ++it) {
|
||||
if((*it)->has_name(name))
|
||||
return true;
|
||||
return *it;
|
||||
}
|
||||
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@ class ScopeBase {
|
|||
Variable* find_variable(perm_string by_name) const;
|
||||
virtual const InterfacePort* find_param(perm_string by_name) const;
|
||||
Subprogram* find_subprogram(perm_string by_name) const;
|
||||
bool is_enum_name(perm_string name) const;
|
||||
// Checks if a string is one of possible enum values. If so, the enum
|
||||
// type is returned, otherwise NULL.
|
||||
const VTypeEnum* is_enum_name(perm_string name) const;
|
||||
|
||||
// Moves signals, variables and components from another scope to
|
||||
// this one. After the transfer new_* maps are cleared in the source scope.
|
||||
|
|
|
|||
|
|
@ -149,8 +149,10 @@ int VTypePrimitive::emit_primitive_type(ostream&out) const
|
|||
int errors = 0;
|
||||
switch (type_) {
|
||||
case BOOLEAN:
|
||||
out << "boolean";
|
||||
break;
|
||||
case BIT:
|
||||
out << "bool";
|
||||
out << "bit";
|
||||
break;
|
||||
case STDLOGIC:
|
||||
out << "logic";
|
||||
|
|
|
|||
Loading…
Reference in New Issue