$word = $word + scalar @irs;
### $word = ($word<<16) + pack("L", scalar(@irs));
print $handle "0x" . uc (substr(reverse(join('',unpack("h8", pack("L", $word)))),0,8)) . "\t# IRlen & numregs \n";
- push(@{$memhash->{$setting_name}},$word);
+ push(@{$memhash->{$memfilename}},$word);
#####print $handle "0x" .uc (substr(reverse(join('',unpack("h8", pack("L", scalar($this_irlen))))),4,4)) . uc (substr(reverse(join('',unpack("h8", pack("L", scalar(@irs))))),4,4)) . "\t# IRlen & numregs \n";
#print "reverse test: " . reverse32bit(0x00000001)."\n";
# write DEV_ID
$word = 0x4D323601;
print $handle "0x" . uc (substr(reverse(join('',unpack("h8", pack("L", $word)))),0,8)) . "\t# DEV_ID \n";
- push(@{$memhash->{$setting_name}},$word);
+ push(@{$memhash->{$memfilename}},$word);
$crcword = pack("L", reverse32bit($word));
$crc0 = crc32($crcword, $crc0);
my $crc0_rn = ~reverse32bit($crc0);
$crcword = pack("L", reverse32bit($word));
$crc0 = crc32($crcword, $crc0);
print $handle "0x" . uc (substr(reverse(join('',unpack("h8", pack("L", $word)))),0,8)) . "\t# Pointer + reserved \n";
- push(@{$memhash->{$setting_name}},$word);
+ push(@{$memhash->{$memfilename}},$word);
$word = $drlen;
$crcword = pack("L", reverse32bit($word));
$crc0 = crc32($crcword, $crc0);
#print $handle "0x0000". uc (substr(reverse(join('',unpack("h8", pack("L", scalar($drlen))))),4,4)) . "\t# Length\n";
print $handle "0x" . uc (substr(reverse(join('',unpack("h8",pack("L", $word)))),0,8)) . "\t# Length\n";
- push(@{$memhash->{$setting_name}},$word);
+ push(@{$memhash->{$memfilename}},$word);
$offset += floor(($drlen+31)/32);
}
# write CRC-32
#printf "CRC: %0.8X.\n", $crc0_rn, 1;
my $line_crc = sprintf "%0.8X", $crc0_rn;
print $handle "0x". substr($line_crc,length($line_crc)-8,8) . "\t# CRC-32\n";
- push(@{$memhash->{$setting_name}},$crc0_rn);
+ push(@{$memhash->{$memfilename}},$crc0_rn);
my $crc1 = 0xFFFFFFFF;
# write IRs
$crcword = pack("L", reverse32bit($word));
$crc1 = crc32($crcword, $crc1);
print $handle "0x".("0"x(8-length($ir))).uc($ir) . "\t# IR\n";
- push(@{$memhash->{$setting_name}},hex($ir));
+ push(@{$memhash->{$memfilename}},hex($ir));
}
# write BYPASSREG IR
$crcword = pack("L", reverse32bit($word));
$crc1 = crc32($crcword, $crc1);
print $handle "0x".("0"x(8-length($bypassreg))).uc($bypassreg) . "\t# IR BYPASS\n";
- push(@{$memhash->{$setting_name}},hex($bypassreg));
+ push(@{$memhash->{$memfilename}},hex($bypassreg));
# write DRs
for(my $reg_i=0;$reg_i<@irs;$reg_i++) {
$crc1 = crc32($crcword, $crc1);
my $linestr = "0x". substr($drs[$reg_i],($numwords-$i-1)*8,8) . "\t# DR" . $reg_i . "\n";
print $handle $linestr;
- push(@{$memhash->{$setting_name}},hex(substr($drs[$reg_i],($numwords-$i-1)*8,8)));
+ push(@{$memhash->{$memfilename}},hex(substr($drs[$reg_i],($numwords-$i-1)*8,8)));
}
}
#write CRC-32
my $crc1_rn = ~reverse32bit($crc1);
$line_crc = sprintf "%0.8X", $crc1_rn;
print $handle "0x". substr($line_crc,length($line_crc)-8,8) . "\t# CRC-32\n";
- push(@{$memhash->{$setting_name}},$crc1_rn);
+ push(@{$memhash->{$memfilename}},$crc1_rn);
}
}
# my $numchips_hex = int_to_32bit_hex(scalar @sensors);
#if(not defined($opt_quiet)) { print "trbcmd wm $fpga_addr $ram_addr 0 $memfilenames[$i]\n"; }
#$result = `trbcmd wm $fpga_addr $ram_addr 0 $memfilenames[$i]`;
execute_shell_command("trbcmd wm $fpga_addr $ram_addr 0 $memfilenames[$i]", "");
+
+ print "---------------\n";
+ foreach my $s ($memhash->{$memfilenames[$i]}) {
+ printf("0x%08X\n",$s);
+ }
+ print "---------------\n";
}
+
#if(not defined($opt_quiet)){ print "trbcmd w $fpga_addr $cmd_reg_addr 0x00000009\n"; } # CMD_START
#$result = `trbcmd w $fpga_addr $cmd_reg_addr 0x00000009\n`; # CMD_START
trb_register_write($fpga_addr, $cmd_reg_addr, 0x00000009);
print "done.\n";
syslog("INFO", "$chain done.\n");
}
-print "---------------\n";
-print Dumper $memhash;
-print "---------------\n";
+
print $handle_lastprog $initmem_folder;
# #print "data registers for FPGA $fpga_addr:", map { "$_ => $drs_binary{$_}\n" } keys %drs_binary;
# $drs_offset{$irs[0]} = 4+(scalar @irs)*2;