Commit d1ab61f5 authored by Christian Fibich's avatar Christian Fibich Committed by Stefan Tauner
Browse files

vecs/fiji#58: Sort drivers in driver selection dialog

parent 4a6285c9
......@@ -888,8 +888,25 @@ sub _connection_tostr {
$type = "ASSIGN";
$str = $type . ": " . $connection->lhs . EQUALSEP . $connection->rhs;
}
push @{$conn_str_list_ref}, {path => $path, type => $type} if defined $conn_str_list_ref;
return $str
if (defined($connection->userdata->{'fiji_driver_bit'})) {
$str .= "[" . $connection->userdata('fiji_driver_bit') . "]";
}
push @{$conn_str_list_ref}, {path => $path, type => $type, str => $str} if defined $conn_str_list_ref;
return $str;
}
sub _sort_conn_str_list {
my ($self, $conn_str_list_ref) = @_;
my @list = sort {
my $a_out = ($a->{str} =~ /[QOqo](\[[0-9]+\]){0,1}[ ]*$/);
my $b_out = ($b->{str} =~ /[QOqo](\[[0-9]+\]){0,1}[ ]*$/);
return $a->{str} cmp $b->{str} if (!($a_out ^ $b_out));
return -1 if ($a_out);
return 1 if ($b_out);
} @{$conn_str_list_ref};
return \@list;
}
## @method public get_connection_object ($connection_path,$connection_type)
......@@ -974,13 +991,21 @@ sub get_connection_object {
# net but driver/driven cannot be decided
sub _get_net_connections_from_path {
my $logger = get_logger("");
my ($self, $net_path, $connection_hashref) = @_;
my ($self, $net_path, $connection_hashref, $sorted) = @_;
my $net_descriptor = $self->get_netdescriptor_from_path($net_path);
return $net_descriptor if (ref($net_descriptor) ne "HASH");
my $net = $net_descriptor->{net};
return $self->_get_net_connections($net, $connection_hashref, $net_descriptor->{'msb'});
}
sub _cmp_driver {
my ($a, $b) = @_;
print "$a\n";
print "$b\n";
return 0;
}
## @method private _untie_concatenations ($concat, $arrayref)
# @brief breaks up a verilog concatenation into single net elements
#
......
......@@ -1563,7 +1563,7 @@ sub _select_driver_dialog($) {
# get a hash of connected objects from the netlist object
# the hash contains objects which are classified as
# 'drivers', 'driven', and 'connected' (cell pins where the netlist could not determine the direction)
my $rv = $self->{'netlist'}->_get_net_connections_from_path($netpath, \%connections);
my $rv = $self->{'netlist'}->_get_net_connections_from_path($netpath, \%connections, 1);
return $rv if (defined($rv));
if (@{$connections{'drivers'}} > 1) {
......@@ -1600,23 +1600,26 @@ sub _select_driver_dialog($) {
# Add a radio button for each possible object and save them
my $sel;
my @conn_str_list;
my $conn_str_list = [];
# Only ask user if there's more than one option
if (@{$possible_drivers} > 1) {
for my $conn (@{$possible_drivers}) {
FIJI::Netlist->_connection_tostr($conn, $conn_str_list);
}
$conn_str_list = FIJI::Netlist->_sort_conn_str_list($conn_str_list);
my $i = 0;
for my $conn (@{$possible_drivers}) { # FIXME: sort (and probably refactor this whole thing + FIJI::Netlist->_connection_tostr)
for my $conn (@{$conn_str_list}) { # FIXME: sort (and probably refactor this whole thing + FIJI::Netlist->_connection_tostr)
my $radio_button = $driver_container_pane->Radiobutton(-value => $i, -variable => \$sel);
my $conn_str = FIJI::Netlist->_connection_tostr($conn, \@conn_str_list);
if (defined($conn->userdata->{'fiji_driver_bit'})) {
$conn_str .= "[" . $conn->userdata('fiji_driver_bit') . "]";
}
my $driver_label = $driver_container_pane->Label(-text => $conn_str, -justify => "left");
my $driver_label = $driver_container_pane->Label(-text => $conn->{str}, -justify => "left");
# preselect driver
if ( !defined $sel
&& $driver_type eq $conn_str_list[$i]->{'type'}
&& $driver_path eq $conn_str_list[$i]->{'path'})
&& $driver_type eq @{$conn_str_list}[$i]->{'type'}
&& $driver_path eq @{$conn_str_list}[$i]->{'path'})
{
$sel = $i;
}
......@@ -1644,13 +1647,13 @@ sub _select_driver_dialog($) {
};
} else {
FIJI::Netlist->_connection_tostr(@{$possible_drivers}[0], \@conn_str_list);
FIJI::Netlist->_connection_tostr(@{$possible_drivers}[0], $conn_str_list);
$sel = 0;
$logger->info("Automatically selecting ".$conn_str_list[$sel]->{'path'}."|".$conn_str_list[$sel]->{'path'}." as a driver for $netpath as there's only one option");
$logger->info("Automatically selecting ".@{$conn_str_list}[$sel]->{'path'}."|".@{$conn_str_list}[$sel]->{'path'}." as a driver for $netpath as there's only one option");
}
$self->{'settings'}->{'fius'}[$fiu_idx]->{'FIU_DRIVER_PATH'} = $conn_str_list[$sel]->{'path'};
$self->{'settings'}->{'fius'}[$fiu_idx]->{'FIU_DRIVER_TYPE'} = $conn_str_list[$sel]->{'type'};
$self->{'settings'}->{'fius'}[$fiu_idx]->{'FIU_DRIVER_PATH'} = @{$conn_str_list}[$sel]->{'path'};
$self->{'settings'}->{'fius'}[$fiu_idx]->{'FIU_DRIVER_TYPE'} = @{$conn_str_list}[$sel]->{'type'};
return undef;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment