OpenCores
URL https://opencores.org/ocsvn/workwithfiles/workwithfiles/trunk

Subversion Repositories workwithfiles

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 3 to Rev 4
    Reverse comparison

Rev 3 → Rev 4

/workwithfiles/trunk/from_bin2text.pl
0,0 → 1,48
#!/bin/perl
 
 
$file=@ARGV[0];
$len=@ARGV[1];
 
if ((length($file)==0) || (length($len)==0))
{
printf "\nInput parameters:\n from_bin2text.pl <binary_file_name> <number_of_bytes_in_outfile>\n";
printf "Example: from_bin2text.pl bytesdata.bin 5000 >stimulus.txt\n\n";
exit(0);
}
 
open(F,"$file");
binmode F;
@lines=<F>;
close(F);
 
 
$txt='';
$bytenum=1;
foreach(@lines)
{
$txt=$_;
for ($z=0;$z<length($txt);$z++)
{
$a=ord(substr($txt,$z,1));
printf "$a\n";
$bytenum++;
if ($bytenum>$len) {exit(0);}
}
}
 
 
 
sub hex2dec
{
return sprintf("%d",hex($_[0]))."";
}
 
sub hex2bin
{
return sprintf("%.4b",hex($_[0]))."";
}
sub dec2hex
{
return sprintf("%.2x",$_[0])."";
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.