diff --git a/parse.y b/parse.y index fe87b00e7..1d0e3c4a9 100644 --- a/parse.y +++ b/parse.y @@ -319,7 +319,8 @@ static PECallFunction*make_call_function(perm_string tn, PExpr*arg1, PExpr*arg2) %type from_exclude %type number -%type signed_opt udp_reg_opt edge_operator automatic_opt +%type signed_opt signed_unsigned_opt +%type udp_reg_opt edge_operator automatic_opt %type drive_strength drive_strength_opt dr_strength0 dr_strength1 %type udp_input_sym udp_output_sym %type udp_input_list udp_sequ_entry udp_comb_entry @@ -516,18 +517,39 @@ block_item_decl if ($1) delete $1; } - /* Integer declarations are simpler in that they do not have all the - trappings of a general variable declaration. All of that is - implicit in the "integer" of the declaration. */ + /* Integer atom declarations are simpler in that they do not have + all the trappings of a general variable declaration. All of that + is implicit in the "integer" of the declaration. */ - | attribute_list_opt K_integer register_variable_list ';' - { pform_set_reg_integer($3); - if ($1) delete $1; - } + | attribute_list_opt K_integer register_variable_list ';' + { pform_set_reg_integer($3); + if ($1) delete $1; + } - | attribute_list_opt K_time register_variable_list ';' - { pform_set_reg_time($3); - } + | attribute_list_opt K_time register_variable_list ';' + { pform_set_reg_time($3); + if ($1) delete $1; + } + + | attribute_list_opt K_byte signed_unsigned_opt register_variable_list ';' + { pform_set_integer_2atom(8, $3, $4); + if ($1) delete $1; + } + + | attribute_list_opt K_shortint signed_unsigned_opt register_variable_list ';' + { pform_set_integer_2atom(16, $3, $4); + if ($1) delete $1; + } + + | attribute_list_opt K_int signed_unsigned_opt register_variable_list ';' + { pform_set_integer_2atom(32, $3, $4); + if ($1) delete $1; + } + + | attribute_list_opt K_longint signed_unsigned_opt register_variable_list ';' + { pform_set_integer_2atom(64, $3, $4); + if ($1) delete $1; + } /* real declarations are fairly simple as there is no range of signed flag in the declaration. Create the real as a NetNet::REG @@ -1981,7 +2003,26 @@ net_type_opt | { $$ = NetNet::IMPLICIT; } ; -signed_opt : K_signed { $$ = true; } | {$$ = false; } ; + /* + * The signed_opt rule will return "true" if K_signed is present, + * for "false" otherwise. This rule corresponds to the declaration + * defaults for reg/bit/logic. + * + * The signed_unsigned_opt rule with match K_signed or K_unsigned + * and return true or false as appropriate. The default is + * "true". This corresponds to the declaration defaults for + * byte/shortint/int/longint. + */ +signed_opt + : K_signed { $$ = true; } + | {$$ = false; } + ; + +signed_unsigned_opt + : K_signed { $$ = true; } + | K_unsigned { $$ = false; } + | { $$ = true; } + ; /* An lpvalue is the expression that can go on the left side of a procedural assignment. This rule handles only procedural diff --git a/pform.cc b/pform.cc index 7b5566018..150887cf2 100644 --- a/pform.cc +++ b/pform.cc @@ -2430,6 +2430,38 @@ void pform_set_reg_time(list*names) delete names; } +static void pform_set_integer_2atom(uint64_t width, bool signed_flag, perm_string name) +{ + PWire*cur = pform_get_wire_in_scope(name); + if (cur == 0) { + cur = new PWire(name, NetNet::REG, NetNet::NOT_A_PORT, IVL_VT_BOOL); + pform_put_wire_in_scope(name, cur); + } else { + bool rc = cur->set_wire_type(NetNet::REG); + assert(rc); + rc = cur->set_data_type(IVL_VT_BOOL); + assert(rc); + } + + assert(cur); + + cur->set_signed(signed_flag); + cur->set_range(new PENumber(new verinum(width-1, integer_width)), + new PENumber(new verinum((uint64_t)0, integer_width)), + SR_NET, false); +} + +void pform_set_integer_2atom(uint64_t width, bool signed_flag, list*names) +{ + for (list::iterator cur = names->begin() + ; cur != names->end() + ; cur ++ ) { + perm_string txt = *cur; + pform_set_integer_2atom(width, signed_flag, txt); + } + delete names; +} + svector* pform_make_udp_input_ports(list*names) { svector*out = new svector(names->size()); diff --git a/pform.h b/pform.h index ea50b318a..fa5debc72 100644 --- a/pform.h +++ b/pform.h @@ -275,6 +275,8 @@ extern void pform_set_reg_idx(perm_string name, PExpr*l, PExpr*r); extern void pform_set_reg_integer(list*names); extern void pform_set_reg_time(list*names); +extern void pform_set_integer_2atom(uint64_t width, bool signed_flag, list*names); + /* pform_set_attrib and pform_set_type_attrib exist to support the $attribute syntax, which can only set string values to attributes. The functions keep the value strings that are diff --git a/scripts/devel-stub.conf b/scripts/devel-stub.conf index 315c22ba0..01009dc3d 100644 --- a/scripts/devel-stub.conf +++ b/scripts/devel-stub.conf @@ -6,7 +6,7 @@ # # NOTE: DO NOT INSTALL THIS FILE! # -generation:2005 +generation:2009 generation:specify generation:xtypes generation:verilog-ams