1 |
169 |
diegovalve |
#!/usr/bin/perl
|
2 |
|
|
################################################################
|
3 |
|
|
#Theia, Ray Cast Programable graphic Processing Unit.
|
4 |
|
|
#Copyright (C) 2010 Diego Valverde (diego.valverde.g@gmail.com)
|
5 |
|
|
#
|
6 |
|
|
#This program is free software; you can redistribute it and/or
|
7 |
|
|
#modify it under the terms of the GNU General Public License
|
8 |
|
|
#as published by the Free Software Foundation; either version 2
|
9 |
|
|
#of the License, or (at your option) any later version.
|
10 |
|
|
#
|
11 |
|
|
#This program is distributed in the hope that it will be useful,
|
12 |
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
|
|
#GNU General Public License for more details.
|
15 |
|
|
#
|
16 |
|
|
#You should have received a copy of the GNU General Public #License
|
17 |
|
|
#along with this program; if not, write to the Free Software
|
18 |
|
|
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA #02110-1301, USA.
|
19 |
|
|
################################################################
|
20 |
|
|
|
21 |
|
|
use Tie::File;
|
22 |
|
|
$NumberOfCores = $ARGV[0];
|
23 |
|
|
|
24 |
|
|
die "\nusage:\nconfigure_gpu.pl number_of_cores width height\n\n" if (not defined $NumberOfCores );
|
25 |
|
|
$DefsPath = "../rtl/aDefinitions.v";
|
26 |
|
|
$TopPath = "../rtl/Theia.v";
|
27 |
|
|
$TestBenchPath = "../rtl/TestBench_THEIA.v";
|
28 |
|
|
$RCOMMIT_O = "assign RCOMMIT_O = wRCommited[0]";
|
29 |
|
|
$HDL_O = "assign HDL_O = wHostDataLatched[0]";
|
30 |
|
|
$DONE_O = "assign DONE_O = wDone[0]";
|
31 |
|
|
$index=$NumberOfCores-1;
|
32 |
|
|
$BankRequest = "iRequest( {wBankReadRequest[$index][Bank]";
|
33 |
|
|
$SELECT_ALL_CORES = "define SELECT_ALL_CORES `MAX_CORES'b1";
|
34 |
|
|
|
35 |
|
|
$Scale = 17;
|
36 |
|
|
|
37 |
|
|
print
|
38 |
|
|
"
|
39 |
|
|
Applying configuration for $NumberOfCores cores
|
40 |
|
|
";
|
41 |
|
|
|
42 |
|
|
#------------------------------------------------------------------
|
43 |
|
|
for ($i = 1; $i < $NumberOfCores; $i++)
|
44 |
|
|
{
|
45 |
|
|
$RCOMMIT_O .= " & wRCommited[$i]";
|
46 |
|
|
$HDL_O .= " & wHostDataLatched[$i]";
|
47 |
|
|
$DONE_O .= " & wDone[$i]";
|
48 |
|
|
$index=$NumberOfCores-$i-1;
|
49 |
|
|
#print "$NumberOfCores $i: $index\n";
|
50 |
|
|
$BankRequest .= ",wBankReadRequest[$index][Bank]";
|
51 |
|
|
$SELECT_ALL_CORES .= "1";
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
tie my @array, 'Tie::File', $DefsPath or die "Can't open $DefsPath: $!";
|
56 |
|
|
foreach (@array)
|
57 |
|
|
{
|
58 |
|
|
s/define MAX_CORES .*(\/\/.*)/define MAX_CORES $NumberOfCores \t\t$1/;
|
59 |
|
|
s/define MAX_TMEM_BANKS .*(\/\/.*)/define MAX_TMEM_BANKS $NumberOfCores \t\t$1/;
|
60 |
|
|
$MaxBits = log( $NumberOfCores ) / log(2);
|
61 |
|
|
s/define MAX_CORE_BITS .*(\/\/.*)/define MAX_CORE_BITS $MaxBits \t\t$1/;
|
62 |
|
|
s/define SELECT_ALL_CORES .*(\/\/.*)/$SELECT_ALL_CORES \t\t$1/;
|
63 |
|
|
|
64 |
|
|
}
|
65 |
|
|
untie @array;
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
tie my @array, 'Tie::File', $TopPath or die "Can't open $TopPath: $!";
|
70 |
|
|
foreach (@array)
|
71 |
|
|
{
|
72 |
|
|
s/assign RCOMMIT_O =.*/$RCOMMIT_O;/;
|
73 |
|
|
s/assign HDL_O =.*/$HDL_O;/;
|
74 |
|
|
s/assign DONE_O =.*/$DONE_O;/;
|
75 |
|
|
s/iRequest\(\s*{wBankReadRequest.*/$BankRequest}\),/;
|
76 |
|
|
|
77 |
|
|
}
|
78 |
|
|
untie @array;
|
79 |
|
|
|
80 |
|
|
$MaxFileLines = 96 + 3*2*$NumberOfCores;
|
81 |
|
|
tie my @array, 'Tie::File', $TestBenchPath or die "Can't open $TestBenchPath: $!";
|
82 |
|
|
foreach (@array)
|
83 |
|
|
{
|
84 |
|
|
s/reg\s+\[31\:0\]\s+rSceneParameters.*/reg [31:0] rSceneParameters[$MaxFileLines:0];/;
|
85 |
|
|
}
|
86 |
|
|
untie @array;
|
87 |
|
|
|