Consolidate functions for task port declaration
With the recent refactorings pform_make_task_ports_vec() and do_make_task_ports() are now very similar. Consolidate them into a single function. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
4e69fe1355
commit
79771b17b2
76
pform.cc
76
pform.cc
|
|
@ -2749,31 +2749,33 @@ void pform_makewire(const struct vlltype&li,
|
|||
* constraints as those of tasks, so this works fine. Functions have
|
||||
* no output or inout ports.
|
||||
*/
|
||||
static vector<pform_tf_port_t>*pform_make_task_ports_vec(const struct vlltype&loc,
|
||||
NetNet::PortType pt,
|
||||
vector_type_t *vec_type,
|
||||
list<pform_port_t>*ports,
|
||||
bool allow_implicit)
|
||||
vector<pform_tf_port_t>*pform_make_task_ports(const struct vlltype&loc,
|
||||
NetNet::PortType pt,
|
||||
data_type_t*vtype,
|
||||
list<pform_port_t>*ports,
|
||||
bool allow_implicit)
|
||||
{
|
||||
assert(pt != NetNet::PIMPLICIT && pt != NetNet::NOT_A_PORT);
|
||||
assert(ports);
|
||||
vector<pform_tf_port_t>*res = new vector<pform_tf_port_t>(0);
|
||||
|
||||
vector<pform_tf_port_t>*res = new vector<pform_tf_port_t>(0);
|
||||
PWSRType rt = SR_BOTH;
|
||||
|
||||
if (allow_implicit && vec_type->implicit_flag)
|
||||
// If this is a non-ansi port declaration and the type is an implicit type
|
||||
// this is only a port declaration.
|
||||
vector_type_t*vec_type = dynamic_cast<vector_type_t*>(vtype);
|
||||
if (allow_implicit && (!vtype || (vec_type && vec_type->implicit_flag)))
|
||||
rt = SR_PORT;
|
||||
|
||||
for (list<pform_port_t>::iterator cur = ports->begin()
|
||||
; cur != ports->end() ; ++ cur ) {
|
||||
for (list<pform_port_t>::iterator cur = ports->begin();
|
||||
cur != ports->end(); ++cur) {
|
||||
perm_string &name = cur->name;
|
||||
|
||||
/* Look for a preexisting wire. If it exists, set the
|
||||
port direction. If not, create it. */
|
||||
PWire*curw = pform_get_or_make_wire(loc, name, NetNet::IMPLICIT_REG,
|
||||
pt, rt);
|
||||
if (rt == SR_BOTH)
|
||||
curw->set_data_type(vec_type);
|
||||
curw->set_data_type(vtype);
|
||||
|
||||
pform_set_net_range(curw, vec_type, rt);
|
||||
|
||||
if (cur->udims) {
|
||||
|
|
@ -2784,56 +2786,8 @@ static vector<pform_tf_port_t>*pform_make_task_ports_vec(const struct vlltype&lo
|
|||
res->push_back(pform_tf_port_t(curw));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static vector<pform_tf_port_t>*do_make_task_ports(const struct vlltype&loc,
|
||||
NetNet::PortType pt,
|
||||
data_type_t*data_type,
|
||||
list<pform_port_t>*ports)
|
||||
{
|
||||
assert(pt != NetNet::PIMPLICIT && pt != NetNet::NOT_A_PORT);
|
||||
assert(ports);
|
||||
vector<pform_tf_port_t>*res = new vector<pform_tf_port_t>(0);
|
||||
PWSRType rt = data_type ? SR_BOTH : SR_PORT;
|
||||
|
||||
for (list<pform_port_t>::iterator cur = ports->begin()
|
||||
; cur != ports->end() ; ++cur) {
|
||||
perm_string &name = cur->name;
|
||||
|
||||
PWire*curw = pform_get_or_make_wire(loc, name, NetNet::IMPLICIT_REG,
|
||||
pt, rt);
|
||||
|
||||
if (data_type)
|
||||
curw->set_data_type(data_type);
|
||||
|
||||
if (cur->udims) {
|
||||
if (pform_requires_sv(loc, "Task/function port with unpacked dimensions"))
|
||||
curw->set_unpacked_idx(*cur->udims);
|
||||
}
|
||||
|
||||
res->push_back(pform_tf_port_t(curw));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
vector<pform_tf_port_t>*pform_make_task_ports(const struct vlltype&loc,
|
||||
NetNet::PortType pt,
|
||||
data_type_t*vtype,
|
||||
list<pform_port_t>*ports,
|
||||
bool allow_implicit)
|
||||
{
|
||||
vector<pform_tf_port_t>*ret = NULL;
|
||||
|
||||
if (vector_type_t*vec_type = dynamic_cast<vector_type_t*> (vtype)) {
|
||||
ret = pform_make_task_ports_vec(loc, pt, vec_type, ports,
|
||||
allow_implicit);
|
||||
} else {
|
||||
ret = do_make_task_ports(loc, pt, vtype, ports);
|
||||
}
|
||||
|
||||
delete ports;
|
||||
return ret;
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue