URL
https://opencores.org/ocsvn/socgen/socgen/trunk
Subversion Repositories socgen
[/] [socgen/] [trunk/] [tools/] [bin/] [abs32tosplit] - Rev 46
Go to most recent revision | Compare with Previous | Blame | View Log
eval 'exec `which perl` -S $0 ${1+"$@"}'
if 0;
#/**********************************************************************/
#/* */
#/* ------- */
#/* / SOC \ */
#/* / GEN \ */
#/* / TOOL \ */
#/* ============== */
#/* | | */
#/* |____________| */
#/* */
#/* Converts a 32 bit abs file into a 16 bit verilog readmemh format */
#/* split into 8 bit even and 8 bit odd files */
#/* */
#/* Author(s): */
#/* - John Eaton, jt_eaton@opencores.org */
#/* */
#/**********************************************************************/
#/* */
#/* Copyright (C) <2010> <Ouabache Design Works> */
#/* */
#/* This source file may be used and distributed without */
#/* restriction provided that this copyright statement is not */
#/* removed from the file and that any derivative work contains */
#/* the original copyright notice and the associated disclaimer. */
#/* */
#/* This source file is free software; you can redistribute it */
#/* and/or modify it under the terms of the GNU Lesser General */
#/* Public License as published by the Free Software Foundation; */
#/* either version 2.1 of the License, or (at your option) any */
#/* later version. */
#/* */
#/* This source is distributed in the hope that it will be */
#/* useful, but WITHOUT ANY WARRANTY; without even the implied */
#/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
#/* PURPOSE. See the GNU Lesser General Public License for more */
#/* details. */
#/* */
#/* You should have received a copy of the GNU Lesser General */
#/* Public License along with this source; if not, download it */
#/* from http://www.opencores.org/lgpl.shtml */
#/* */
#/**********************************************************************/
# ToDO: add handling unaligned words
############################################################################
# General PERL config
############################################################################
use Getopt::Long;
use English;
use File::Basename;
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
############################################################################
### Process the options
############################################################################
Getopt::Long::config("require_order", "prefix=-");
GetOptions("h"
) || die "(use '$program_name -h' for help)";
##############################################################################
## Help option
##############################################################################
if ( ($opt_h eq "1") )
{ print "\n type test filename ( no extension)";
print "\n";
exit 1;
}
#############################################################################
##
## open intel hex file and read into array
##
#############################################################################
my $prog_name = $ARGV[0];
my $input_file = ${prog_name}.".abs";
my $output_file_e = ${prog_name}.".absE";
my $output_file_o = ${prog_name}.".absO";
print "Reading hex File $input_file\n";
print "Writing abs File $output_file_e\n";
print "Writing abs File $output_file_o\n";
open VERILOG_E , "> $output_file_e";
open VERILOG_O , "> $output_file_o";
open FILE, $input_file;
while(<FILE>){push @intel_hex, $_ ;}
#############################################################################
##
## Clear a storage area for the 16 bit words
##
#############################################################################
my $x=0;
while( $x <= 65535)
{
@Mem_e[$x] = "00";
@Mem_o[$x] = "00";
$x = $x+1;
}
#############################################################################
##
## Parse Data into storage converting from 8 bit bytes to 16 bit words
##
#############################################################################
my $pointer = 0;
foreach $line (@intel_hex)
{
print "$line -- $pointer";
@Mem_e[$pointer+0] = substr($line, 6,2);
@Mem_o[$pointer+0] = substr($line, 4,2);
@Mem_e[$pointer+1] = substr($line, 2,2);
@Mem_o[$pointer+1] = substr($line, 0,2);
$pointer = $pointer +2;
}
$pointer = $pointer-1;
#############################################################################
##
## dump out up to the last word, undefined space is 000
##
#############################################################################
$x = 0;
while( $x <= ($pointer))
{
printf VERILOG_E (" %s\n",@Mem_e[$x]);
printf VERILOG_O (" %s\n",@Mem_o[$x]);
$x = $x+1;
}
1
Go to most recent revision | Compare with Previous | Blame | View Log