Merge pull request #691 from larsclausen/cleanup-pform-makewire

Small cleanups for `pform_makewire()`
This commit is contained in:
Stephen Williams 2022-04-17 18:38:15 -07:00 committed by GitHub
commit 66a5cfe660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 41 deletions

View File

@ -5833,9 +5833,7 @@ dimensions
net_variable net_variable
: IDENTIFIER dimensions_opt : IDENTIFIER dimensions_opt
{ perm_string name = lex_strings.make($1); { perm_string name = lex_strings.make($1);
pform_makewire(@1, name, NetNet::IMPLICIT, pform_makewire(@1, name, NetNet::IMPLICIT, IVL_VT_NO_TYPE, $2);
NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, 0);
pform_set_reg_idx(name, $2);
$$ = $1; $$ = $1;
} }
; ;

View File

@ -2741,12 +2741,11 @@ static PWire* pform_get_or_make_wire(const vlltype&li, perm_string name,
* the variable/net. Other forms of pform_makewire ultimately call * the variable/net. Other forms of pform_makewire ultimately call
* this one to create the wire and stash it. * this one to create the wire and stash it.
*/ */
void pform_makewire(const vlltype&li, perm_string name, void pform_makewire(const vlltype&li, perm_string name, NetNet::Type type,
NetNet::Type type, NetNet::PortType pt, ivl_variable_type_t dt, std::list<pform_range_t> *indices)
ivl_variable_type_t dt,
list<named_pexpr_t>*attr)
{ {
PWire*cur = pform_get_or_make_wire(li, name, type, pt, dt); PWire*cur = pform_get_or_make_wire(li, name, type, NetNet::NOT_A_PORT,
dt);
assert(cur); assert(cur);
bool flag; bool flag;
@ -2767,12 +2766,8 @@ void pform_makewire(const vlltype&li, perm_string name,
break; break;
} }
if (attr) { if (indices && !indices->empty())
for (list<named_pexpr_t>::iterator attr_cur = attr->begin() cur->set_unpacked_idx(*indices);
; attr_cur != attr->end() ; ++attr_cur) {
cur->attributes[attr_cur->name] = attr_cur->parm;
}
}
} }
void pform_makewire(const struct vlltype&li, void pform_makewire(const struct vlltype&li,
@ -2793,8 +2788,7 @@ void pform_makewire(const struct vlltype&li,
for (list<decl_assignment_t*>::iterator cur = assign_list->begin() for (list<decl_assignment_t*>::iterator cur = assign_list->begin()
; cur != assign_list->end() ; ++ cur) { ; cur != assign_list->end() ; ++ cur) {
decl_assignment_t* curp = *cur; decl_assignment_t* curp = *cur;
pform_makewire(li, curp->name, type, NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, 0); pform_makewire(li, curp->name, type, IVL_VT_NO_TYPE, &curp->index);
pform_set_reg_idx(curp->name, &curp->index);
names->push_back(curp->name); names->push_back(curp->name);
} }
@ -3076,22 +3070,6 @@ void pform_set_type_attrib(perm_string name, const string&key,
(*udp).second ->attributes[key] = new PEString(value); (*udp).second ->attributes[key] = new PEString(value);
} }
/*
* This function attaches a memory index range to an existing
* register. (The named wire must be a register.
*/
void pform_set_reg_idx(perm_string name, list<pform_range_t>*indices)
{
PWire*cur = lexical_scope->wires_find(name);
if (cur == 0) {
VLerror("internal error: name is not a valid memory for index.");
return;
}
if (indices && !indices->empty())
cur->set_unpacked_idx(*indices);
}
LexicalScope::range_t* pform_parameter_value_range(bool exclude_flag, LexicalScope::range_t* pform_parameter_value_range(bool exclude_flag,
bool low_open, PExpr*low_expr, bool low_open, PExpr*low_expr,
bool hig_open, PExpr*hig_expr) bool hig_open, PExpr*hig_expr)

View File

@ -144,7 +144,6 @@ extern PWire* pform_get_wire_in_scope(perm_string name);
extern PWire* pform_get_make_wire_in_scope(const struct vlltype&li, extern PWire* pform_get_make_wire_in_scope(const struct vlltype&li,
perm_string name, perm_string name,
NetNet::Type net_type, NetNet::Type net_type,
NetNet::PortType port_type,
ivl_variable_type_t vt_type); ivl_variable_type_t vt_type);
/* /*
@ -350,9 +349,8 @@ extern PForeach* pform_make_foreach(const struct vlltype&loc,
*/ */
extern void pform_makewire(const struct vlltype&li, perm_string name, extern void pform_makewire(const struct vlltype&li, perm_string name,
NetNet::Type type, NetNet::Type type,
NetNet::PortType pt, ivl_variable_type_t dt,
ivl_variable_type_t, std::list<pform_range_t> *indices);
std::list<named_pexpr_t>*attr);
/* This form handles assignment declarations. */ /* This form handles assignment declarations. */
@ -382,9 +380,6 @@ extern void pform_set_port_type(const struct vlltype&li,
data_type_t*dt, data_type_t*dt,
std::list<named_pexpr_t>*attr); std::list<named_pexpr_t>*attr);
extern void pform_set_reg_idx(perm_string name,
std::list<pform_range_t>*indices);
extern void pform_set_data_type(const struct vlltype&li, data_type_t*, std::list<perm_string>*names, NetNet::Type net_type, std::list<named_pexpr_t>*attr); extern void pform_set_data_type(const struct vlltype&li, data_type_t*, std::list<perm_string>*names, NetNet::Type net_type, std::list<named_pexpr_t>*attr);
extern void pform_set_string_type(const struct vlltype&li, const string_type_t*string_type, std::list<perm_string>*names, NetNet::Type net_type, std::list<named_pexpr_t>*attr); extern void pform_set_string_type(const struct vlltype&li, const string_type_t*string_type, std::list<perm_string>*names, NetNet::Type net_type, std::list<named_pexpr_t>*attr);

View File

@ -195,8 +195,7 @@ void pform_attach_discipline(const struct vlltype&loc,
PWire* cur_net = pform_get_wire_in_scope(*cur); PWire* cur_net = pform_get_wire_in_scope(*cur);
if (cur_net == 0) { if (cur_net == 0) {
/* Not declared yet, declare it now. */ /* Not declared yet, declare it now. */
pform_makewire(loc, *cur, NetNet::WIRE, pform_makewire(loc, *cur, NetNet::WIRE, IVL_VT_REAL, 0);
NetNet::NOT_A_PORT, IVL_VT_REAL, 0);
cur_net = pform_get_wire_in_scope(*cur); cur_net = pform_get_wire_in_scope(*cur);
assert(cur_net); assert(cur_net);
} }