vhdlpp: Basic support for unbounded array types.

Once a signal/variable of unbounded array type becomes limited in its size, it
is emitted as a packed array. Therefore currently it works only for
bit/logic/reg/wire types.
This commit is contained in:
Maciej Suminski 2014-08-08 17:17:47 +02:00
parent 9031f392ba
commit c92dea77fc
3 changed files with 13 additions and 9 deletions

View File

@ -684,8 +684,8 @@ composite_type_definition
/* unbounded_array_definition IEEE 1076-2008 P5.3.2.1 */ /* unbounded_array_definition IEEE 1076-2008 P5.3.2.1 */
| K_array '(' index_subtype_definition_list ')' K_of subtype_indication | K_array '(' index_subtype_definition_list ')' K_of subtype_indication
{ sorrymsg(@1, "unbounded_array_definition not supported.\n"); { std::list<prange_t*> r;
std::list<prange_t*> r; r.push_back(new prange_t(NULL, NULL, true)); // NULL boundaries indicate unbounded array type
VTypeArray*tmp = new VTypeArray($6, &r); VTypeArray*tmp = new VTypeArray($6, &r);
$$ = tmp; $$ = tmp;
} }

View File

@ -82,6 +82,12 @@ static const VType* calculate_subtype_array(const YYLTYPE&loc, const char*base_n
assert(array_left==0 || array_right!=0); assert(array_left==0 || array_right!=0);
// unfold typedef, if it is the case
const VTypeDef*type_def = dynamic_cast<const VTypeDef*> (base_type);
if (type_def) {
base_type = type_def->peek_definition();
}
const VTypeArray*base_array = dynamic_cast<const VTypeArray*> (base_type); const VTypeArray*base_array = dynamic_cast<const VTypeArray*> (base_type);
if (base_array) { if (base_array) {
assert(array_left && array_right); assert(array_left && array_right);

View File

@ -88,16 +88,14 @@ int VTypeArray::emit_def(ostream&out) const
while (! dims.empty()) { while (! dims.empty()) {
cur = dims.front(); cur = dims.front();
dims.pop_front(); dims.pop_front();
out << "["; out << "[";
if (cur->dimension(0).msb()) if (cur->dimension(0).msb() && cur->dimension(0).lsb()) {
// bounded array, unbounded arrays have msb() & lsb() nullified
errors += cur->dimension(0).msb()->emit(out, 0, 0); errors += cur->dimension(0).msb()->emit(out, 0, 0);
else out << ":";
out << "?error?";
out << ":";
if (cur->dimension(0).lsb())
errors += cur->dimension(0).lsb()->emit(out, 0, 0); errors += cur->dimension(0).lsb()->emit(out, 0, 0);
else }
out << "?error?";
out << "]"; out << "]";
} }