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

Subversion Repositories openfire_core

[/] [openfire_core/] [trunk/] [utils/] [create_array.pl] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 cutullus
#!/usr/bin/perl
2
##############################################################################
3
# create_array.pl
4
# 
5
# Creates EDK input files needed to create an array of OpenFire processors.
6
#
7
# Stephen Douglas Craven
8
# modified 11/18/2005
9
# Virginia Tech
10
#
11
# WARNING!  This script may break with newer / older versions of the EDK.
12
# Works with 7.1.
13
#
14
##############################################################################
15
 
16
# Globals
17
use vars qw/ %opt /;
18
 
19
# Command line options processing
20
sub init()
21
{
22
    use Getopt::Std;
23
    my $opt_string = 'hn:m:p:';
24
    getopts( "$opt_string", \%opt ) or usage();
25
    usage() if ($opt{h} or !$opt{n} or ($opt{n} < 1));
26
}
27
 
28
# Message about this program and how to use it
29
sub usage()
30
{
31
    print STDERR << "EOF";
32
 
33
This program modifies an EDK MHS file instantiating and connecting
34
the specified number of OpenFires in an array controlled by the MicroBlaze
35
master.  Currently only unidirectional ring networks are supported.
36
 
37
Also modifies a MSS file for the master MB.
38
 
39
usage: $0 [-h] -n # <-d> <-o filename>
40
 
41
 -h                  : this (help) message
42
 -n #                : positive number of processors in the array (not counting master node)
43
 -m MB_instance_name : instance name of master MicroBlaze (default = microblaze_0)
44
 -p project_name     : name of project (default = system)
45
 
46
example: $0 -n 16 -m microblaze_0 -p system
47
 
48
EOF
49
exit(0);
50
}
51
 
52
#############################################
53
# Begin MHS file component declarations
54
#    This script works by adding FSL links
55
#    and OpenFires to existing MHS / MSS
56
#    files.
57
#############################################
58
$fsl_bus1 = "BEGIN fsl_v20
59
 PARAMETER INSTANCE = ";
60
$fsl_bus2 =" PARAMETER HW_VER = 2.00.a
61
 PARAMETER C_EXT_RESET_HIGH = 0
62
 PARAMETER C_FSL_DEPTH = 1
63
 PORT FSL_Clk = sys_clk_s
64
 PORT SYS_Rst = sys_rst_s
65
END
66
";
67
 
68
$openfire_instance1 = "BEGIN openfire_top_syn
69
 PARAMETER INSTANCE = ";
70
$openfire_instance2 = " BUS_INTERFACE SFSL = ";
71
$openfire_instance3 = " BUS_INTERFACE MFSL = ";
72
$openfire_instance4 = " PORT clock = sys_clk_s
73
 PORT reset = sys_rst_s
74
END
75
";
76
 
77
 
78
# Begin MSS file declarations
79
$mss_openfire = "
80
 
81
BEGIN DRIVER
82
 PARAMETER DRIVER_NAME = generic
83
 PARAMETER DRIVER_VER = 1.00.a
84
 PARAMETER HW_INSTANCE = openfire";
85
 
86
init();
87
 
88
# setup MHS filehandler
89
if($opt{p}) {
90
        $outputfile = $opt{p}.".mhs";
91
} else {
92
        $outputfile = "system.mhs";
93
}
94
 
95
# setup master MB name
96
if($opt{m}) {
97
        $master_mb = $opt{m};
98
} else {
99
        $master_mb = "microblaze_0";
100
}
101
 
102
# Open MHS file for appending first... write OpenFires and FSLs to end of file
103
open(mhs_file, ">>$outputfile") || die("Could not open file $outputfile!");
104
 
105
# Create Backup of file before we modify it
106
system("cp $outputfile create_array_bck.mhs");
107
 
108
# Add master Nodes's FSL buses
109
print mhs_file $fsl_bus1."fsl_MB_slave\n";
110
print mhs_file $fsl_bus2."\n";
111
print mhs_file $fsl_bus1."fsl_MB_master\n";
112
print mhs_file $fsl_bus2."\n";
113
 
114
# Loop over the processors
115
for($i = 0; $i < $opt{n}; $i++)
116
{
117
        $node_num = "openfire".$i;
118
        $node_num_prev = "openfire".($i-1);
119
        $fsl_master = "fsl_".$node_num."_master\n";
120
        $fsl_slave = "fsl_".$node_num_prev."_master\n";
121
        # Add each processor to the MHS
122
        print mhs_file $openfire_instance1.$node_num."\n";
123
        # Depending on the location of the processor in the ring network,
124
        #     connect its FSL links to different interfaces (OpenFire or MicroBlaze)
125
 
126
        # Both FSLs connect to Master
127
        if($opt{n} == 1) {
128
                print mhs_file $openfire_instance2."fsl_MB_master\n";
129
                print mhs_file $openfire_instance3."fsl_MB_slave\n";
130
                print mhs_file $openfire_instance4."\n";
131
        # No FSLs connect to master
132
        } elsif(($i != 0) & ($i != ($opt{n}-1))) {
133
                print mhs_file $openfire_instance2.$fsl_slave;
134
                print mhs_file $openfire_instance3.$fsl_master;
135
                print mhs_file $openfire_instance4."\n";
136
                print mhs_file $fsl_bus1.$fsl_master;
137
                print mhs_file $fsl_bus2."\n";
138
        # Slave FSL connects to Master
139
        } elsif($i == 0) {
140
                print mhs_file $openfire_instance2."fsl_MB_master\n";
141
                print mhs_file $openfire_instance3.$fsl_master;
142
                print mhs_file $openfire_instance4."\n";
143
                print mhs_file $fsl_bus1.$fsl_master;
144
                print mhs_file $fsl_bus2."\n";
145
        # Master FSL connects to Master
146
        } else {
147
                print mhs_file $openfire_instance2.$fsl_slave;
148
                print mhs_file $openfire_instance3."fsl_MB_slave\n";
149
                print mhs_file $openfire_instance4."\n";
150
        }
151
}
152
close(mhs_file);
153
 
154
# Must add FSL interfaces to master MB
155
# Open file again for reading
156
open(mhs_file, $outputfile) || die("Could not open file $outputfile!");
157
 
158
# hopefully read in entire file
159
@lines=<mhs_file>;
160
 
161
# go ahead and close the file
162
close(mhs_file);
163
 
164
$master_fsl_parameters = " PARAMETER C_FSL_LINKS = 1
165
 BUS_INTERFACE SFSL0 = fsl_MB_slave
166
 BUS_INTERFACE MFSL0 = fsl_MB_master
167
 ";
168
 
169
# search for master MB to add FSL interfaces to it
170
# This could be improved
171
$master_found = 0;
172
$complete = 0;
173
$output = "";
174
foreach $line (@lines)
175
{
176
        $_ = $line;
177
        if(/$master_mb/)
178
        {
179
                $master_found = 1;
180
                $output = $output.$line;
181
        } elsif($master_found & /BUS_INTERFACE/)
182
        {
183
                $output = $output.$master_fsl_parameters.$line;
184
                $master_found = 0;
185
                $complete = 1;
186
        }else{
187
                $output = $output.$line;
188
        }
189
}
190
if(!$complete)
191
{
192
        die("Could not find the $master_mb instance!");
193
}
194
 
195
# Open file again for overwriting
196
open(mhs_file, ">$outputfile") || die("Could not open file $outputfile!");
197
# We overwrite the entire file with our modified system that includes FSL interfaces for the MB
198
print mhs_file $output;
199
close(mhs_file);
200
 
201
# find output MSS file
202
if($opt{p}) {
203
        $outputfile = $opt{p}.".mss";
204
} else {
205
        $outputfile = "system.mss";
206
}
207
 
208
# Create backup
209
system("cp $outputfile create_array_bck.mss");
210
 
211
# write OpenFire drivers to MSS file
212
open(mss_file, ">>$outputfile") || die("Could not open file $outputfile!");
213
print mss_file $mss_header;
214
for($i = 0; $i < $opt{n}; $i++)
215
{
216
        print mss_file $mss_openfire.$i."\n END\n";
217
}
218
close(mss_file);
219
exit;

powered by: WebSVN 2.1.0

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