+#store \$pin2io, $bsdl_file . '.pin2io.storable';
+store \$pin2io, $entity . '.pin2io.storable';
+
+
+my $opcode;
+my $o = $parse->{INSTRUCTION_OPCODE} || die "no INSTRUCTION_OPCODE in ",dump($parse);
+
+foreach ( split(/\)\s*,\s*/, $o) ) {
+ s/\s+\(/ /g;
+ s/\s*\)\s*$//g;
+ warn "### [$_]\n";
+ my ( $inst_opcode, $bin ) = split(/\s+/, $_);
+ $opcode->{$inst_opcode} = sprintf "0x%02x", eval '0b' . $bin;
+}
+warn "# opcode = ",dump($opcode);
+
+foreach (qw(SAMPLE EXTEST)) {
+ die "missing INSTRUCTION_OPCODE $_ in ",dump($opcode) unless $opcode->{$_};
+}
+
+my $pin_desc;
+foreach my $pin_file ( glob "pins/$entity*.tsv" ) {
+ open(my $fh, '<', $pin_file);
+ while(<$fh>) {
+ chomp;
+ my ($pin,$desc, $bcm) = split(/\t+/,$_,3);
+ $pin_desc->{$pin} = $desc;
+ gpio::add_bcm_desc( $bcm => $desc ) if $have_gpio;
+ }
+ close($fh);
+ warn "# $pin_file ",dump($pin_desc);
+}
+
+{
+ open(my $fh, '<', $project_file);
+ while(<$fh>) {
+ chomp;
+ s/[\r\n]+$//;
+ my ($set,$pin, $op, $desc) = split(/\s+/,$_,4);
+ if ( $set =~ m/set_location_assignment/i && $op =~ m/-to/i && $pin =~ s/^PIN_//ig ) {
+ $pin_desc->{$pin} = $desc; # overwrite pin description
+ } else {
+ warn "# ignored $_\n";
+ }
+ }
+ close($fh);
+ warn "# $project_file ",dump($pin_desc);
+}