Clean up pform_module_define_port in preparation for new tricks.
Get rid of the data_type, signed_flag, and range arguments to the pform_module_define_port because they add no value within the parse.y parser. Cleaning these out will hopefully ease the addition of new functionality.
This commit is contained in:
parent
aaee9989c2
commit
f8e33b12cd
82
parse.y
82
parse.y
|
|
@ -46,12 +46,8 @@ static ivl_variable_type_t param_active_type = IVL_VT_LOGIC;
|
||||||
static struct {
|
static struct {
|
||||||
NetNet::Type port_net_type;
|
NetNet::Type port_net_type;
|
||||||
NetNet::PortType port_type;
|
NetNet::PortType port_type;
|
||||||
ivl_variable_type_t var_type;
|
|
||||||
bool sign_flag;
|
|
||||||
data_type_t* data_type;
|
data_type_t* data_type;
|
||||||
list<pform_range_t>* range;
|
} port_declaration_context = {NetNet::NONE, NetNet::NOT_A_PORT, 0};
|
||||||
} port_declaration_context = {NetNet::NONE, NetNet::NOT_A_PORT,
|
|
||||||
IVL_VT_NO_TYPE, false, 0, 0};
|
|
||||||
|
|
||||||
/* The task and function rules need to briefly hold the pointer to the
|
/* The task and function rules need to briefly hold the pointer to the
|
||||||
task/function that is currently in progress. */
|
task/function that is currently in progress. */
|
||||||
|
|
@ -1900,27 +1896,16 @@ tf_port_item /* IEEE1800-2005: A.2.7 */
|
||||||
if ($4 != 0) {
|
if ($4 != 0) {
|
||||||
yyerror(@4, "internal error: How can there be an unpacked range here?\n");
|
yyerror(@4, "internal error: How can there be an unpacked range here?\n");
|
||||||
}
|
}
|
||||||
if (port_declaration_context.var_type == IVL_VT_NO_TYPE) {
|
|
||||||
tmp = pform_make_task_ports(@3, use_port_type,
|
tmp = pform_make_task_ports(@3, use_port_type,
|
||||||
port_declaration_context.data_type,
|
port_declaration_context.data_type,
|
||||||
ilist);
|
ilist);
|
||||||
} else {
|
|
||||||
tmp = pform_make_task_ports(@3, use_port_type,
|
|
||||||
port_declaration_context.var_type,
|
|
||||||
port_declaration_context.sign_flag,
|
|
||||||
copy_range(port_declaration_context.range),
|
|
||||||
ilist);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, the decorations for this identifier
|
// Otherwise, the decorations for this identifier
|
||||||
// indicate the type. Save the type for any right
|
// indicate the type. Save the type for any right
|
||||||
// context thta may come later.
|
// context thta may come later.
|
||||||
port_declaration_context.port_type = use_port_type;
|
port_declaration_context.port_type = use_port_type;
|
||||||
port_declaration_context.var_type = IVL_VT_NO_TYPE;
|
|
||||||
port_declaration_context.sign_flag = false;
|
|
||||||
delete port_declaration_context.range;
|
|
||||||
port_declaration_context.range = 0;
|
|
||||||
if ($2 == 0) {
|
if ($2 == 0) {
|
||||||
$2 = new vector_type_t(IVL_VT_LOGIC, false, 0);
|
$2 = new vector_type_t(IVL_VT_LOGIC, false, 0);
|
||||||
FILE_NAME($2, @3);
|
FILE_NAME($2, @3);
|
||||||
|
|
@ -3817,10 +3802,7 @@ list_of_port_declarations
|
||||||
pform_module_define_port(@3, name,
|
pform_module_define_port(@3, name,
|
||||||
port_declaration_context.port_type,
|
port_declaration_context.port_type,
|
||||||
port_declaration_context.port_net_type,
|
port_declaration_context.port_net_type,
|
||||||
port_declaration_context.var_type,
|
port_declaration_context.data_type, 0);
|
||||||
port_declaration_context.sign_flag,
|
|
||||||
port_declaration_context.data_type,
|
|
||||||
port_declaration_context.range, 0);
|
|
||||||
delete[]$3;
|
delete[]$3;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
|
@ -3841,14 +3823,9 @@ port_declaration
|
||||||
{ Module::port_t*ptmp;
|
{ Module::port_t*ptmp;
|
||||||
perm_string name = lex_strings.make($5);
|
perm_string name = lex_strings.make($5);
|
||||||
ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
|
ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
|
||||||
pform_module_define_port(@2, name, NetNet::PINPUT, $3, IVL_VT_NO_TYPE,
|
pform_module_define_port(@2, name, NetNet::PINPUT, $3, $4, $1);
|
||||||
false, $4, 0, $1);
|
|
||||||
port_declaration_context.port_type = NetNet::PINPUT;
|
port_declaration_context.port_type = NetNet::PINPUT;
|
||||||
port_declaration_context.port_net_type = $3;
|
port_declaration_context.port_net_type = $3;
|
||||||
port_declaration_context.var_type = IVL_VT_NO_TYPE;
|
|
||||||
port_declaration_context.sign_flag = false;
|
|
||||||
delete port_declaration_context.range;
|
|
||||||
port_declaration_context.range = 0;
|
|
||||||
port_declaration_context.data_type = $4;
|
port_declaration_context.data_type = $4;
|
||||||
delete[]$5;
|
delete[]$5;
|
||||||
if ($6) {
|
if ($6) {
|
||||||
|
|
@ -3863,15 +3840,13 @@ port_declaration
|
||||||
perm_string name = lex_strings.make($4);
|
perm_string name = lex_strings.make($4);
|
||||||
ptmp = pform_module_port_reference(name, @2.text,
|
ptmp = pform_module_port_reference(name, @2.text,
|
||||||
@2.first_line);
|
@2.first_line);
|
||||||
|
real_type_t*real_type = new real_type_t(real_type_t::REAL);
|
||||||
|
FILE_NAME(real_type, @3);
|
||||||
pform_module_define_port(@2, name, NetNet::PINPUT,
|
pform_module_define_port(@2, name, NetNet::PINPUT,
|
||||||
NetNet::WIRE, IVL_VT_REAL, true, 0, 0, $1);
|
NetNet::WIRE, real_type, $1);
|
||||||
port_declaration_context.port_type = NetNet::PINPUT;
|
port_declaration_context.port_type = NetNet::PINPUT;
|
||||||
port_declaration_context.port_net_type = NetNet::WIRE;
|
port_declaration_context.port_net_type = NetNet::WIRE;
|
||||||
port_declaration_context.var_type = IVL_VT_REAL;
|
port_declaration_context.data_type = real_type;
|
||||||
port_declaration_context.sign_flag = true;
|
|
||||||
delete port_declaration_context.range;
|
|
||||||
port_declaration_context.range = 0;
|
|
||||||
port_declaration_context.data_type = 0;
|
|
||||||
delete[]$4;
|
delete[]$4;
|
||||||
$$ = ptmp;
|
$$ = ptmp;
|
||||||
}
|
}
|
||||||
|
|
@ -3879,14 +3854,9 @@ port_declaration
|
||||||
{ Module::port_t*ptmp;
|
{ Module::port_t*ptmp;
|
||||||
perm_string name = lex_strings.make($5);
|
perm_string name = lex_strings.make($5);
|
||||||
ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
|
ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
|
||||||
pform_module_define_port(@2, name, NetNet::PINOUT, $3, IVL_VT_NO_TYPE,
|
pform_module_define_port(@2, name, NetNet::PINOUT, $3, $4, $1);
|
||||||
false, $4, 0, $1);
|
|
||||||
port_declaration_context.port_type = NetNet::PINOUT;
|
port_declaration_context.port_type = NetNet::PINOUT;
|
||||||
port_declaration_context.port_net_type = $3;
|
port_declaration_context.port_net_type = $3;
|
||||||
port_declaration_context.var_type = IVL_VT_NO_TYPE;
|
|
||||||
port_declaration_context.sign_flag = false;
|
|
||||||
delete port_declaration_context.range;
|
|
||||||
port_declaration_context.range = 0;
|
|
||||||
port_declaration_context.data_type = $4;
|
port_declaration_context.data_type = $4;
|
||||||
delete[]$5;
|
delete[]$5;
|
||||||
if ($6) {
|
if ($6) {
|
||||||
|
|
@ -3901,15 +3871,13 @@ port_declaration
|
||||||
perm_string name = lex_strings.make($4);
|
perm_string name = lex_strings.make($4);
|
||||||
ptmp = pform_module_port_reference(name, @2.text,
|
ptmp = pform_module_port_reference(name, @2.text,
|
||||||
@2.first_line);
|
@2.first_line);
|
||||||
|
real_type_t*real_type = new real_type_t(real_type_t::REAL);
|
||||||
|
FILE_NAME(real_type, @3);
|
||||||
pform_module_define_port(@2, name, NetNet::PINOUT,
|
pform_module_define_port(@2, name, NetNet::PINOUT,
|
||||||
NetNet::WIRE, IVL_VT_REAL, true, 0, 0, $1);
|
NetNet::WIRE, real_type, $1);
|
||||||
port_declaration_context.port_type = NetNet::PINOUT;
|
port_declaration_context.port_type = NetNet::PINOUT;
|
||||||
port_declaration_context.port_net_type = NetNet::WIRE;
|
port_declaration_context.port_net_type = NetNet::WIRE;
|
||||||
port_declaration_context.var_type = IVL_VT_REAL;
|
port_declaration_context.data_type = real_type;
|
||||||
port_declaration_context.sign_flag = true;
|
|
||||||
delete port_declaration_context.range;
|
|
||||||
port_declaration_context.range = 0;
|
|
||||||
port_declaration_context.data_type = 0;
|
|
||||||
delete[]$4;
|
delete[]$4;
|
||||||
$$ = ptmp;
|
$$ = ptmp;
|
||||||
}
|
}
|
||||||
|
|
@ -3937,14 +3905,9 @@ port_declaration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
|
ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
|
||||||
pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, IVL_VT_NO_TYPE,
|
pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, $4, $1);
|
||||||
false, $4, 0, $1);
|
|
||||||
port_declaration_context.port_type = NetNet::POUTPUT;
|
port_declaration_context.port_type = NetNet::POUTPUT;
|
||||||
port_declaration_context.port_net_type = use_type;
|
port_declaration_context.port_net_type = use_type;
|
||||||
port_declaration_context.var_type = IVL_VT_NO_TYPE;
|
|
||||||
port_declaration_context.sign_flag = false;
|
|
||||||
delete port_declaration_context.range;
|
|
||||||
port_declaration_context.range = 0;
|
|
||||||
port_declaration_context.data_type = $4;
|
port_declaration_context.data_type = $4;
|
||||||
delete[]$5;
|
delete[]$5;
|
||||||
if ($6) {
|
if ($6) {
|
||||||
|
|
@ -3959,15 +3922,13 @@ port_declaration
|
||||||
perm_string name = lex_strings.make($4);
|
perm_string name = lex_strings.make($4);
|
||||||
ptmp = pform_module_port_reference(name, @2.text,
|
ptmp = pform_module_port_reference(name, @2.text,
|
||||||
@2.first_line);
|
@2.first_line);
|
||||||
|
real_type_t*real_type = new real_type_t(real_type_t::REAL);
|
||||||
|
FILE_NAME(real_type, @3);
|
||||||
pform_module_define_port(@2, name, NetNet::POUTPUT,
|
pform_module_define_port(@2, name, NetNet::POUTPUT,
|
||||||
NetNet::WIRE, IVL_VT_REAL, true, 0, 0, $1);
|
NetNet::WIRE, real_type, $1);
|
||||||
port_declaration_context.port_type = NetNet::POUTPUT;
|
port_declaration_context.port_type = NetNet::POUTPUT;
|
||||||
port_declaration_context.port_net_type = NetNet::WIRE;
|
port_declaration_context.port_net_type = NetNet::WIRE;
|
||||||
port_declaration_context.var_type = IVL_VT_REAL;
|
port_declaration_context.data_type = real_type;
|
||||||
port_declaration_context.sign_flag = true;
|
|
||||||
delete port_declaration_context.range;
|
|
||||||
port_declaration_context.range = 0;
|
|
||||||
port_declaration_context.data_type = 0;
|
|
||||||
delete[]$4;
|
delete[]$4;
|
||||||
$$ = ptmp;
|
$$ = ptmp;
|
||||||
}
|
}
|
||||||
|
|
@ -3986,14 +3947,9 @@ port_declaration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
|
ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
|
||||||
pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, IVL_VT_NO_TYPE,
|
pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, $4, $1);
|
||||||
false, $4, 0, $1);
|
|
||||||
port_declaration_context.port_type = NetNet::PINOUT;
|
port_declaration_context.port_type = NetNet::PINOUT;
|
||||||
port_declaration_context.port_net_type = use_type;
|
port_declaration_context.port_net_type = use_type;
|
||||||
port_declaration_context.var_type = IVL_VT_NO_TYPE;
|
|
||||||
port_declaration_context.sign_flag = false;
|
|
||||||
delete port_declaration_context.range;
|
|
||||||
port_declaration_context.range = 0;
|
|
||||||
port_declaration_context.data_type = $4;
|
port_declaration_context.data_type = $4;
|
||||||
|
|
||||||
pform_make_reginit(@5, name, $7);
|
pform_make_reginit(@5, name, $7);
|
||||||
|
|
|
||||||
14
pform.cc
14
pform.cc
|
|
@ -2154,15 +2154,14 @@ void pform_make_reginit(const struct vlltype&li,
|
||||||
*/
|
*/
|
||||||
void pform_module_define_port(const struct vlltype&li,
|
void pform_module_define_port(const struct vlltype&li,
|
||||||
perm_string name,
|
perm_string name,
|
||||||
NetNet::PortType port_type,
|
NetNet::PortType port_kind,
|
||||||
NetNet::Type type,
|
NetNet::Type type,
|
||||||
ivl_variable_type_t data_type,
|
|
||||||
bool signed_flag,
|
|
||||||
data_type_t*vtype,
|
data_type_t*vtype,
|
||||||
list<pform_range_t>*range,
|
|
||||||
list<named_pexpr_t>*attr)
|
list<named_pexpr_t>*attr)
|
||||||
{
|
{
|
||||||
struct_type_t*struct_type = 0;
|
struct_type_t*struct_type = 0;
|
||||||
|
ivl_variable_type_t data_type = IVL_VT_NO_TYPE;
|
||||||
|
bool signed_flag = false;
|
||||||
|
|
||||||
PWire*cur = pform_get_wire_in_scope(name);
|
PWire*cur = pform_get_wire_in_scope(name);
|
||||||
if (cur) {
|
if (cur) {
|
||||||
|
|
@ -2174,10 +2173,7 @@ void pform_module_define_port(const struct vlltype&li,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vtype) {
|
list<pform_range_t>*range = 0;
|
||||||
ivl_assert(li, data_type == IVL_VT_NO_TYPE);
|
|
||||||
ivl_assert(li, range == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vector_type_t*vec_type = dynamic_cast<vector_type_t*> (vtype)) {
|
if (vector_type_t*vec_type = dynamic_cast<vector_type_t*> (vtype)) {
|
||||||
data_type = vec_type->base_type;
|
data_type = vec_type->base_type;
|
||||||
|
|
@ -2216,7 +2212,7 @@ void pform_module_define_port(const struct vlltype&li,
|
||||||
if (data_type == IVL_VT_NO_TYPE)
|
if (data_type == IVL_VT_NO_TYPE)
|
||||||
data_type = IVL_VT_LOGIC;
|
data_type = IVL_VT_LOGIC;
|
||||||
|
|
||||||
cur = new PWire(name, type, port_type, data_type);
|
cur = new PWire(name, type, port_kind, data_type);
|
||||||
FILE_NAME(cur, li);
|
FILE_NAME(cur, li);
|
||||||
|
|
||||||
cur->set_signed(signed_flag);
|
cur->set_signed(signed_flag);
|
||||||
|
|
|
||||||
3
pform.h
3
pform.h
|
|
@ -168,10 +168,7 @@ extern void pform_module_define_port(const struct vlltype&li,
|
||||||
perm_string name,
|
perm_string name,
|
||||||
NetNet::PortType,
|
NetNet::PortType,
|
||||||
NetNet::Type type,
|
NetNet::Type type,
|
||||||
ivl_variable_type_t data_type,
|
|
||||||
bool signed_flag,
|
|
||||||
data_type_t*vtype,
|
data_type_t*vtype,
|
||||||
list<pform_range_t>*range,
|
|
||||||
list<named_pexpr_t>*attr);
|
list<named_pexpr_t>*attr);
|
||||||
|
|
||||||
extern Module::port_t* pform_module_port_reference(perm_string name,
|
extern Module::port_t* pform_module_port_reference(perm_string name,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue