comparison src/cs/layer1/tools/gen_intram.pl @ 0:92470e5d0b9e

src: partial import from FC Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 01:28:16 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92470e5d0b9e
1 #!/usr/bin/perl
2
3
4 if ($#ARGV == -1)
5 {
6 die "\nSyntax is gen_intram <C file (with extension)>\n\n";
7 }
8
9 $#ARGV == 0 or die "Incorrect number of parameters";
10
11 $c_input_file = @ARGV[0];
12
13 # -------------------------------------------------------------------------------
14 # Remove .c extension and create the new filename for the processed file
15
16 @file_name = split /\.c/, $c_input_file;
17 $c_output_file = join ('', @file_name, "_intram.c");
18
19 print "Output file: $c_output_file\n";
20
21 # -------------------------------------------------------------------------------
22 # Generates the C file for internal RAM
23
24 open input_stream, $c_input_file
25 or die "\n\n Input C file $C_input_file cannot be opened: $!\n";
26
27 open(output_stream,'>'.$c_output_file)
28 or die "\n\nCan't open output file $C_output_file: $!";
29
30 printf output_stream "/* ----- WARNING - File automatically generated - Do not modify it ----- */\n\n\n\n\n";
31
32 $d_internal_found = 0;
33
34 # Search for data
35 while(<input_stream>)
36 {
37 chomp $_;
38
39 # Search for start comment
40 if ( /#pragma DUPLICATE_FOR_INTERNAL_RAM_START/ )
41 {
42 # DEBUG
43 #print "Found begin of string\n";
44 $d_internal_found = 1;
45
46 # Found begin internal RAM code, then output up to the end string
47 while(<input_stream>)
48 {
49 chomp $_;
50 if ( /#pragma DUPLICATE_FOR_INTERNAL_RAM_END/ )
51 {
52 # Found end of the internal RAM code, then search for another one
53 # DEBUG
54 #print "Found end of string\n";
55 last;
56 }
57 else
58 {
59 printf output_stream "%s\n", $_;
60 # DEBUG
61 #print "Copied lines - $_\n";
62 }
63 }
64
65 }
66 }
67
68 close input_stream;
69 close output_stream;