@@ -972,18 +972,6 @@ static void clear_current_scope()
972972 AST_INTERNAL::current_ast_mod = nullptr ;
973973}
974974
975- static void mark_as_unsigned (AST::AstNode *node, const UHDM::BaseClass *object)
976- {
977- if (node->children .empty () || node->children .size () == 1 ) {
978- node->is_signed = false ;
979- } else if (node->children .size () == 2 ) {
980- node->children [0 ]->is_signed = false ;
981- node->children [1 ]->is_signed = false ;
982- } else {
983- log_error (" %s:%d: Unsupported expression in mark_as_unsigned!\n " , object->VpiFile ().c_str (), object->VpiLineNo ());
984- }
985- }
986-
987975void UhdmAst::visit_one_to_many (const std::vector<int > child_node_types, vpiHandle parent_handle, const std::function<void (AST::AstNode *)> &f)
988976{
989977 for (auto child : child_node_types) {
@@ -2672,16 +2660,20 @@ void UhdmAst::process_operation(const UHDM::BaseClass *object)
26722660 case vpiBitXnorOp:
26732661 current_node->type = AST::AST_BIT_XNOR;
26742662 break ;
2675- case vpiLShiftOp:
2663+ case vpiLShiftOp: {
26762664 current_node->type = AST::AST_SHIFT_LEFT;
26772665 log_assert (current_node->children .size () == 2 );
2678- mark_as_unsigned (current_node->children [1 ], object);
2666+ auto unsigned_node = new AST::AstNode (AST::AST_TO_UNSIGNED, current_node->children [1 ]->clone ());
2667+ current_node->children [1 ] = unsigned_node;
26792668 break ;
2680- case vpiRShiftOp:
2669+ }
2670+ case vpiRShiftOp: {
26812671 current_node->type = AST::AST_SHIFT_RIGHT;
26822672 log_assert (current_node->children .size () == 2 );
2683- mark_as_unsigned (current_node->children [1 ], object);
2673+ auto unsigned_node = new AST::AstNode (AST::AST_TO_UNSIGNED, current_node->children [1 ]->clone ());
2674+ current_node->children [1 ] = unsigned_node;
26842675 break ;
2676+ }
26852677 case vpiNotOp:
26862678 current_node->type = AST::AST_LOGIC_NOT;
26872679 break ;
@@ -2733,16 +2725,20 @@ void UhdmAst::process_operation(const UHDM::BaseClass *object)
27332725 case vpiModOp:
27342726 current_node->type = AST::AST_MOD;
27352727 break ;
2736- case vpiArithLShiftOp:
2728+ case vpiArithLShiftOp: {
27372729 current_node->type = AST::AST_SHIFT_SLEFT;
27382730 log_assert (current_node->children .size () == 2 );
2739- mark_as_unsigned (current_node->children [1 ], object);
2731+ auto unsigned_node = new AST::AstNode (AST::AST_TO_UNSIGNED, current_node->children [1 ]->clone ());
2732+ current_node->children [1 ] = unsigned_node;
27402733 break ;
2741- case vpiArithRShiftOp:
2734+ }
2735+ case vpiArithRShiftOp: {
27422736 current_node->type = AST::AST_SHIFT_SRIGHT;
27432737 log_assert (current_node->children .size () == 2 );
2744- mark_as_unsigned (current_node->children [1 ], object);
2738+ auto unsigned_node = new AST::AstNode (AST::AST_TO_UNSIGNED, current_node->children [1 ]->clone ());
2739+ current_node->children [1 ] = unsigned_node;
27452740 break ;
2741+ }
27462742 case vpiPowerOp:
27472743 current_node->type = AST::AST_POW;
27482744 break ;
0 commit comments