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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [bin/] [abs32tosplit] - Blame information for rev 121

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 41 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
 
4
#/**********************************************************************/
5
#/*                                                                    */
6
#/*             -------                                                */
7
#/*            /   SOC  \                                              */
8
#/*           /    GEN   \                                             */
9
#/*          /    TOOL    \                                            */
10
#/*          ==============                                            */
11
#/*          |            |                                            */
12
#/*          |____________|                                            */
13
#/*                                                                    */
14
#/*  Converts a 32 bit abs file into a 16 bit verilog readmemh format  */
15
#/*  split into 8 bit even and 8 bit odd files                         */
16
#/*                                                                    */
17
#/*  Author(s):                                                        */
18
#/*      - John Eaton, jt_eaton@opencores.org                          */
19
#/*                                                                    */
20
#/**********************************************************************/
21
#/*                                                                    */
22
#/*    Copyright (C) <2010>                     */
23
#/*                                                                    */
24
#/*  This source file may be used and distributed without              */
25
#/*  restriction provided that this copyright statement is not         */
26
#/*  removed from the file and that any derivative work contains       */
27
#/*  the original copyright notice and the associated disclaimer.      */
28
#/*                                                                    */
29
#/*  This source file is free software; you can redistribute it        */
30
#/*  and/or modify it under the terms of the GNU Lesser General        */
31
#/*  Public License as published by the Free Software Foundation;      */
32
#/*  either version 2.1 of the License, or (at your option) any        */
33
#/*  later version.                                                    */
34
#/*                                                                    */
35
#/*  This source is distributed in the hope that it will be            */
36
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
37
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
38
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
39
#/*  details.                                                          */
40
#/*                                                                    */
41
#/*  You should have received a copy of the GNU Lesser General         */
42
#/*  Public License along with this source; if not, download it        */
43
#/*  from http://www.opencores.org/lgpl.shtml                          */
44
#/*                                                                    */
45
#/**********************************************************************/
46
 
47
# ToDO: add handling unaligned words
48
 
49
 
50
############################################################################
51
# General PERL config
52
############################################################################
53
use Getopt::Long;
54
use English;
55
use File::Basename;
56
 
57
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
58
 
59
 
60
############################################################################
61
### Process the options
62
############################################################################
63
 
64
Getopt::Long::config("require_order", "prefix=-");
65
GetOptions("h"
66
) || die "(use '$program_name -h' for help)";
67
 
68
 
69
##############################################################################
70
## Help option
71
##############################################################################
72
if ( ($opt_h eq "1") )
73
  { print "\n type test filename ( no extension)";
74
    print "\n";
75
    exit 1;
76
  }
77
 
78
 
79
 
80
#############################################################################
81
##
82
##  open intel hex  file  and read into array
83
##
84
#############################################################################
85
 
86
  my $prog_name         = $ARGV[0];
87
 
88
  my $input_file   = ${prog_name}.".abs";
89
  my $output_file_e  = ${prog_name}.".absE";
90
  my $output_file_o  = ${prog_name}.".absO";
91
 
92
  print "Reading hex File  $input_file\n";
93
  print "Writing abs File  $output_file_e\n";
94
  print "Writing abs File  $output_file_o\n";
95
 
96
  open  VERILOG_E , ">  $output_file_e";
97
  open  VERILOG_O , ">  $output_file_o";
98
  open   FILE, $input_file;
99
 
100
 
101
 
102
  while(){push @intel_hex, $_  ;}
103
 
104
 
105
#############################################################################
106
##
107
##  Clear a storage area for the 16 bit words
108
##
109
#############################################################################
110
 
111
 
112
   my  $x=0;
113
      while( $x <= 65535)
114
           {
115
           @Mem_e[$x] = "00";
116
           @Mem_o[$x] = "00";
117
            $x = $x+1;
118
           }
119
 
120
 
121
#############################################################################
122
##
123
##  Parse Data  into storage converting from 8 bit bytes to 16 bit words
124
##
125
#############################################################################
126
 
127
my $pointer = 0;
128
 
129
 
130
  foreach $line (@intel_hex)
131
    {
132
    print "$line -- $pointer";
133
 
134
    @Mem_e[$pointer+0] = substr($line, 6,2);
135
    @Mem_o[$pointer+0] = substr($line, 4,2);
136
    @Mem_e[$pointer+1] = substr($line, 2,2);
137
    @Mem_o[$pointer+1] = substr($line, 0,2);
138
    $pointer = $pointer +2;
139
    }
140
$pointer = $pointer-1;
141
 
142
#############################################################################
143
##
144
##  dump out up to the last word, undefined space is 000
145
##
146
#############################################################################
147
 
148
      $x = 0;
149
      while( $x <= ($pointer))
150
           {
151
           printf VERILOG_E (" %s\n",@Mem_e[$x]);
152
           printf VERILOG_O (" %s\n",@Mem_o[$x]);
153
           $x = $x+1;
154
           }
155
 
156
 
157
 
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
1
167
 
168
 

powered by: WebSVN 2.1.0

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