Fix annotation for special cases

This commit is contained in:
mole99 2023-08-16 09:04:10 +02:00
parent 6d3e2bf344
commit 423f88cce9
1 changed files with 44 additions and 54 deletions

View File

@ -1680,6 +1680,13 @@ vpiHandle vpi_handle_multi(PLI_INT32 type,
return nullptr; return nullptr;
} }
bool is_output = false;
if (port1->get_direction() == vpiOutput && port2->get_direction() == vpiOutput)
{
std::cout << "OUTPUT!!!" << std::endl;
is_output = true;
}
/*if (!(port1->get_direction() == vpiOutput || port1->get_direction() == vpiInout)) { /*if (!(port1->get_direction() == vpiOutput || port1->get_direction() == vpiInout)) {
fprintf(stderr, "ERROR: First vpiPort must be an output" fprintf(stderr, "ERROR: First vpiPort must be an output"
" or bidirectional port\n"); " or bidirectional port\n");
@ -1821,55 +1828,33 @@ vpiHandle vpi_handle_multi(PLI_INT32 type,
net_ptr = &next_net->port[net_ptr->port()]; net_ptr = &next_net->port[net_ptr->port()];
} }
// Iterate over linked list until port2 is found // Verify if port2 is connected to port1
net_ptr = net1_ptr; vvp_net_t* current_net = net1_ptr->ptr();
vvp_net_ptr_t previous_net_ptr = vvp_net_ptr_t(nullptr, 0);
vvp_net_t* previous_net = net1;
while (net_ptr) while (current_net)
{ {
vvp_net_t* next_net = net_ptr->ptr(); if (!current_net) break; // End of list
if (!next_net) break; // End of list if (current_net == net2)
if (next_net == net2) break; // Found net2 {
std::cout << "Found net2!" << std::endl;
previous_net_ptr = *net_ptr; // Ol switcheroo
net_ptr = &next_net->port[net_ptr->port()]; vvp_net_fun_t* net2_functor = net2->fun;
}
if (!net_ptr->ptr()) return 0; int width = 1; // TODO
vvp_fun_intermodpath*obj = new vvp_fun_intermodpath(net2, width);
fprintf(stderr, "Net2 connected to net1!\n"); net2->fun = obj;
fprintf(stderr, "%p\n", previous_net);
fprintf(stderr, "Inserting intermodpath...\n");
int width = 1; // TODO get width of port, check port widths are equal
vvp_net_t*new_net = new vvp_net_t; vvp_net_t*new_net = new vvp_net_t;
vvp_fun_intermodpath*obj = new vvp_fun_intermodpath(new_net, width); new_net->fun = net2_functor;
new_net->fun = obj; //net2_functor->net = new_net;
// point to where net2 was pointing new_net->out_ = net2->out_;
new_net->port[0] = net_ptr->ptr()->port[net_ptr->port()]; net2->out_ = vvp_net_ptr_t(new_net, 0);
// Directly connected to port1
if (!previous_net_ptr.ptr())
{
net1->out_ = vvp_net_ptr_t(new_net,0);
}
else
{
// what pointed to net2 should point to new_net
previous_net_ptr.ptr()->port[previous_net_ptr.port()] = vvp_net_ptr_t(new_net,0);
}
// out of new_net should point to net2
new_net->out_= vvp_net_ptr_t(net2,0); // point to port0 of net2
__vpiInterModPath*intermodpath = vpip_make_intermodpath(new_net, port1, port2); __vpiInterModPath*intermodpath = vpip_make_intermodpath(net2, port1, port2);
intermodpath->intermodpath = obj; intermodpath->intermodpath = obj;
fprintf(stderr, "Inserted vvp_fun_intermodpath!\n"); fprintf(stderr, "Inserted vvp_fun_intermodpath!\n");
@ -1881,6 +1866,11 @@ vpiHandle vpi_handle_multi(PLI_INT32 type,
print_port_connections(net2_ptr); print_port_connections(net2_ptr);
return intermodpath; return intermodpath;
}
current_net = current_net->port[0].ptr(); // BUFT has only one input, index 0
}
std::cout << "Could not find net2!" << std::endl;
} }
std::cout << "sorry: Could not insert intermodpath!" << std::endl; std::cout << "sorry: Could not insert intermodpath!" << std::endl;