Parse support for SystemVerilog atom2 types.

This commit is contained in:
Stephen Williams 2010-10-02 10:13:11 -07:00
parent f7ce0f3b79
commit e03ff763fb
4 changed files with 88 additions and 13 deletions

65
parse.y
View File

@ -319,7 +319,8 @@ static PECallFunction*make_call_function(perm_string tn, PExpr*arg1, PExpr*arg2)
%type <flag> from_exclude
%type <number> number
%type <flag> signed_opt udp_reg_opt edge_operator automatic_opt
%type <flag> signed_opt signed_unsigned_opt
%type <flag> udp_reg_opt edge_operator automatic_opt
%type <drive> drive_strength drive_strength_opt dr_strength0 dr_strength1
%type <letter> udp_input_sym udp_output_sym
%type <text> 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

View File

@ -2430,6 +2430,38 @@ void pform_set_reg_time(list<perm_string>*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<perm_string>*names)
{
for (list<perm_string>::iterator cur = names->begin()
; cur != names->end()
; cur ++ ) {
perm_string txt = *cur;
pform_set_integer_2atom(width, signed_flag, txt);
}
delete names;
}
svector<PWire*>* pform_make_udp_input_ports(list<perm_string>*names)
{
svector<PWire*>*out = new svector<PWire*>(names->size());

View File

@ -275,6 +275,8 @@ extern void pform_set_reg_idx(perm_string name, PExpr*l, PExpr*r);
extern void pform_set_reg_integer(list<perm_string>*names);
extern void pform_set_reg_time(list<perm_string>*names);
extern void pform_set_integer_2atom(uint64_t width, bool signed_flag, list<perm_string>*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

View File

@ -6,7 +6,7 @@
#
# NOTE: DO NOT INSTALL THIS FILE!
#
generation:2005
generation:2009
generation:specify
generation:xtypes
generation:verilog-ams