Skip to content

Commit

Permalink
Function binding cherry-pick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansaya committed Aug 27, 2022
1 parent 811d6ad commit 56dc02e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/HLS/binding/module/fu_binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,7 @@ void fu_binding::manage_memory_ports_parallel_chained(const HLS_managerRef, cons
GetPointerS<port_o>(port_i)->get_ports_size() - GetPointerS<port_o>(cir_port)->get_ports_size();
GetPointerS<port_o>(cir_port)->add_n_ports(n_ports, cir_port);
}
SM->add_connection(cir_port, port_i);
}
}
}
Expand Down Expand Up @@ -1694,11 +1695,19 @@ void fu_binding::manage_extern_global_port(const HLS_managerRef, const hlsRef, c
structural_objectRef ext_port;
if(GetPointer<port_o>(port_in)->get_is_global())
{
std::string port_name = GetPointer<port_o>(port_in)->get_id();
const auto port_name = GetPointerS<port_o>(port_in)->get_id();
ext_port = circuit->find_member(port_name, port_in->get_kind(), circuit);
THROW_ASSERT(!ext_port || GetPointer<port_o>(ext_port), "should be a port or null");
if(ext_port && GetPointer<port_o>(ext_port)->get_port_direction() != dir)
if(ext_port && GetPointerS<port_o>(ext_port)->get_port_direction() != dir)
{
THROW_ASSERT(port_in->get_kind() == ext_port->get_kind(), "unexpected condition");
if(port_in->get_kind() == port_vector_o_K &&
GetPointerS<port_o>(port_in)->get_ports_size() > GetPointerS<port_o>(ext_port)->get_ports_size())
{
const auto n_ports =
GetPointerS<port_o>(port_in)->get_ports_size() - GetPointerS<port_o>(ext_port)->get_ports_size();
GetPointerS<port_o>(ext_port)->add_n_ports(n_ports, ext_port);
}
SM->change_port_direction(ext_port, dir, circuit);
if(STD_GET_SIZE(ext_port->get_typeRef()) < STD_GET_SIZE(port_in->get_typeRef()))
{
Expand All @@ -1717,6 +1726,17 @@ void fu_binding::manage_extern_global_port(const HLS_managerRef, const hlsRef, c
ext_port = SM->add_port(port_name, dir, circuit, port_in->get_typeRef());
}
}
else
{
THROW_ASSERT(port_in->get_kind() == ext_port->get_kind(), "unexpected condition");
if(port_in->get_kind() == port_vector_o_K &&
GetPointerS<port_o>(port_in)->get_ports_size() > GetPointerS<port_o>(ext_port)->get_ports_size())
{
const auto n_ports =
GetPointerS<port_o>(port_in)->get_ports_size() - GetPointerS<port_o>(ext_port)->get_ports_size();
GetPointer<port_o>(ext_port)->add_n_ports(n_ports, ext_port);
}
}
}
else
{
Expand Down

0 comments on commit 56dc02e

Please sign in to comment.