@@ -423,9 +423,18 @@ static AST::AstNode *expand_dot(const AST::AstNode *current_struct, const AST::A
423423 AST::AST_ADD, left,
424424 new AST::AstNode (AST::AST_ADD, struct_range->children [1 ]->clone (), new AST::AstNode (AST::AST_SUB, range_size, elem_size->clone ())));
425425 } else if (struct_range->children .size () == 1 ) {
426- right = new AST::AstNode (AST::AST_ADD, right, struct_range->children [0 ]->clone ());
427- delete left;
428- left = right->clone ();
426+ if (!current_struct_elem->multirange_dimensions .empty ()) {
427+ right = new AST::AstNode (AST::AST_ADD, right,
428+ new AST::AstNode (AST::AST_MUL, struct_range->children [0 ]->clone (),
429+ AST::AstNode::mkconst_int (current_struct_elem->multirange_dimensions .back (), true )));
430+ delete left;
431+ left = new AST::AstNode (AST::AST_ADD, right->clone (),
432+ AST::AstNode::mkconst_int (current_struct_elem->multirange_dimensions .back () - 1 , true ));
433+ } else {
434+ right = new AST::AstNode (AST::AST_ADD, right, struct_range->children [0 ]->clone ());
435+ delete left;
436+ left = right->clone ();
437+ }
429438 } else {
430439 struct_range->dumpAst (NULL , " range >" );
431440 log_error (" Unhandled range select (AST_STRUCT_ITEM) in AST_DOT!\n " );
@@ -792,6 +801,7 @@ void UhdmAst::process_packed_array_typespec()
792801 std::vector<AST::AstNode *> packed_ranges;
793802 std::vector<AST::AstNode *> unpacked_ranges;
794803 current_node = make_ast_node (AST::AST_WIRE);
804+ visit_one_to_many ({vpiRange}, obj_h, [&](AST::AstNode *node) { packed_ranges.push_back (node); });
795805 visit_one_to_one ({vpiElemTypespec}, obj_h, [&](AST::AstNode *node) {
796806 if (node && node->type == AST::AST_STRUCT) {
797807 auto str = current_node->str ;
@@ -803,13 +813,12 @@ void UhdmAst::process_packed_array_typespec()
803813 if (node->type == AST::AST_ENUM && !node->children .empty ()) {
804814 for (auto c : node->children [0 ]->children ) {
805815 if (c->type == AST::AST_RANGE && c->str .empty ())
806- unpacked_ranges .push_back (c->clone ());
816+ packed_ranges .push_back (c->clone ());
807817 }
808818 }
809819 delete node;
810820 }
811821 });
812- visit_one_to_many ({vpiRange}, obj_h, [&](AST::AstNode *node) { packed_ranges.push_back (node); });
813822 add_multirange_wire (current_node, packed_ranges, unpacked_ranges);
814823}
815824
@@ -3075,9 +3084,7 @@ void UhdmAst::process_parameter()
30753084 break ;
30763085 }
30773086 case vpiIntTypespec: {
3078- #ifdef BUILD_UPSTREAM
30793087 packed_ranges.push_back (make_range (31 , 0 ));
3080- #endif
30813088 shared.report .mark_handled (typespec_h);
30823089 break ;
30833090 }
0 commit comments