pform_make_task_ports(): Reuse `pform_set_net_range()`
`pform_make_task_ports()` has code very similar to `pform_set_net_range()`. Use that helper function instead of duplicating the code. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
c5ebe35953
commit
b307da0831
10
parse.y
10
parse.y
|
|
@ -164,16 +164,6 @@ static std::list<perm_string>* list_from_identifier(list<perm_string>*tmp, char*
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<pform_range_t>* copy_range(list<pform_range_t>* orig)
|
|
||||||
{
|
|
||||||
std::list<pform_range_t>*copy = 0;
|
|
||||||
|
|
||||||
if (orig)
|
|
||||||
copy = new std::list<pform_range_t> (*orig);
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T> void append(vector<T>&out, const std::vector<T>&in)
|
template <class T> void append(vector<T>&out, const std::vector<T>&in)
|
||||||
{
|
{
|
||||||
for (size_t idx = 0 ; idx < in.size() ; idx += 1)
|
for (size_t idx = 0 ; idx < in.size() ; idx += 1)
|
||||||
|
|
|
||||||
36
pform.cc
36
pform.cc
|
|
@ -2786,17 +2786,20 @@ void pform_makewire(const struct vlltype&li,
|
||||||
* constraints as those of tasks, so this works fine. Functions have
|
* constraints as those of tasks, so this works fine. Functions have
|
||||||
* no output or inout ports.
|
* no output or inout ports.
|
||||||
*/
|
*/
|
||||||
static vector<pform_tf_port_t>*pform_make_task_ports(const struct vlltype&loc,
|
static vector<pform_tf_port_t>*pform_make_task_ports_vec(const struct vlltype&loc,
|
||||||
NetNet::PortType pt,
|
NetNet::PortType pt,
|
||||||
ivl_variable_type_t vtype,
|
vector_type_t *vec_type,
|
||||||
bool signed_flag,
|
list<pform_port_t>*ports,
|
||||||
list<pform_range_t>*range,
|
bool allow_implicit)
|
||||||
list<pform_port_t>*ports)
|
|
||||||
{
|
{
|
||||||
assert(pt != NetNet::PIMPLICIT && pt != NetNet::NOT_A_PORT);
|
assert(pt != NetNet::PIMPLICIT && pt != NetNet::NOT_A_PORT);
|
||||||
assert(ports);
|
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 = vtype != IVL_VT_NO_TYPE ? SR_BOTH : SR_PORT;
|
|
||||||
|
PWSRType rt = SR_BOTH;
|
||||||
|
|
||||||
|
if (allow_implicit && vec_type->implicit_flag)
|
||||||
|
rt = SR_PORT;
|
||||||
|
|
||||||
for (list<pform_port_t>::iterator cur = ports->begin()
|
for (list<pform_port_t>::iterator cur = ports->begin()
|
||||||
; cur != ports->end() ; ++ cur ) {
|
; cur != ports->end() ; ++ cur ) {
|
||||||
|
|
@ -2805,12 +2808,8 @@ static vector<pform_tf_port_t>*pform_make_task_ports(const struct vlltype&loc,
|
||||||
/* Look for a preexisting wire. If it exists, set the
|
/* Look for a preexisting wire. If it exists, set the
|
||||||
port direction. If not, create it. */
|
port direction. If not, create it. */
|
||||||
PWire*curw = pform_get_or_make_wire(loc, name, NetNet::IMPLICIT_REG,
|
PWire*curw = pform_get_or_make_wire(loc, name, NetNet::IMPLICIT_REG,
|
||||||
pt, vtype, rt);
|
pt, vec_type->base_type, rt);
|
||||||
curw->set_signed(signed_flag);
|
pform_set_net_range(curw, vec_type, rt);
|
||||||
|
|
||||||
/* If there is a range involved, it needs to be set. */
|
|
||||||
if (range)
|
|
||||||
curw->set_range(*range, rt);
|
|
||||||
|
|
||||||
if (cur->udims) {
|
if (cur->udims) {
|
||||||
if (pform_requires_sv(loc, "Task/function port with unpacked dimensions"))
|
if (pform_requires_sv(loc, "Task/function port with unpacked dimensions"))
|
||||||
|
|
@ -2820,7 +2819,6 @@ static vector<pform_tf_port_t>*pform_make_task_ports(const struct vlltype&loc,
|
||||||
res->push_back(pform_tf_port_t(curw));
|
res->push_back(pform_tf_port_t(curw));
|
||||||
}
|
}
|
||||||
|
|
||||||
delete range;
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2874,14 +2872,8 @@ vector<pform_tf_port_t>*pform_make_task_ports(const struct vlltype&loc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vector_type_t*vec_type = dynamic_cast<vector_type_t*> (vtype)) {
|
if (vector_type_t*vec_type = dynamic_cast<vector_type_t*> (vtype)) {
|
||||||
ivl_variable_type_t base_type = vec_type->base_type;
|
ret = pform_make_task_ports_vec(loc, pt, vec_type, ports,
|
||||||
if (allow_implicit && vec_type->implicit_flag)
|
allow_implicit);
|
||||||
base_type = IVL_VT_NO_TYPE;
|
|
||||||
|
|
||||||
ret = pform_make_task_ports(loc, pt, base_type,
|
|
||||||
vec_type->signed_flag,
|
|
||||||
copy_range(vec_type->pdims.get()),
|
|
||||||
ports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/*real_type_t*real_type = */ dynamic_cast<real_type_t*> (vtype)) {
|
if (/*real_type_t*real_type = */ dynamic_cast<real_type_t*> (vtype)) {
|
||||||
|
|
|
||||||
3
pform.h
3
pform.h
|
|
@ -96,9 +96,6 @@ struct parmvalue_t {
|
||||||
|
|
||||||
struct str_pair_t { ivl_drive_t str0, str1; };
|
struct str_pair_t { ivl_drive_t str0, str1; };
|
||||||
|
|
||||||
|
|
||||||
extern std::list<pform_range_t>* copy_range(std::list<pform_range_t>* orig);
|
|
||||||
|
|
||||||
/* Use this function to transform the parted form of the attribute
|
/* Use this function to transform the parted form of the attribute
|
||||||
list to the attribute map that is used later. */
|
list to the attribute map that is used later. */
|
||||||
extern void pform_bind_attributes(std::map<perm_string,PExpr*>&attributes,
|
extern void pform_bind_attributes(std::map<perm_string,PExpr*>&attributes,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue