Line 18... |
Line 18... |
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA #02110-1301, USA.
|
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA #02110-1301, USA.
|
################################################################
|
################################################################
|
$CodePath = $ARGV[0];
|
$CodePath = $ARGV[0];
|
$DefsPath = "aDefinitions.v";
|
$DefsPath = "aDefinitions.v";
|
|
|
|
|
|
print
|
|
"
|
|
---------------------------------------------------------------
|
|
|
|
_/_/_/_/_/ _/ _/
|
|
_/ _/_/_/ _/_/ _/_/_/
|
|
_/ _/ _/ _/_/_/_/ _/ _/ _/
|
|
_/ _/ _/ _/ _/ _/ _/
|
|
_/ _/ _/ _/_/_/ _/ _/_/_/
|
|
|
|
|
|
---------------------------------------------------------------
|
|
Compiling file '$CodePath'
|
|
|
|
|
|
";
|
|
|
$Line = 0;
|
$Line = 0;
|
%Registers;
|
%Registers;
|
%Instructions;
|
%Instructions;
|
%Labels;
|
%Labels;
|
%EntryPoints;
|
%EntryPoints;
|
@EntryKeys;
|
@EntryKeys;
|
open OUT, ">Instructions.mem" or die "Can't open output file for R/W\n";
|
$OutputFile = "Instructions.mem";
|
|
open OUT, ">$OutputFile" or die "Can't open output file for R/W\n";
|
PopulateRegistersAndInstructionSet();
|
PopulateRegistersAndInstructionSet();
|
GenerateLabels();
|
GenerateLabels();
|
ParseCode();
|
ParseCode();
|
print
|
print
|
"
|
"
|
** Compilation successful! **
|
|
|
|
The output has been written to 'Code.mem' file.
|
Output file: '$OutputFile'
|
Please make to copy this file under the same folder
|
|
where the simulation executable is, and edit the
|
|
'Creg.mem' let the RTL executable know that it
|
|
should use the shader.
|
|
Have a nice one!
|
|
|
|
|
** Compilation successful! **
|
|
---------------------------------------------------------------
|
";
|
";
|
close OUT;
|
close OUT;
|
exit(0);
|
exit(0);
|
|
|
|
|
Line 112... |
Line 127... |
|
|
{
|
{
|
#print "$1\n";
|
#print "$1\n";
|
die "Error line $Line: Entry point not defined $1\n" if (not defined $EntryPoints{$1});
|
die "Error line $Line: Entry point not defined $1\n" if (not defined $EntryPoints{$1});
|
$EntryPoints{$1} = sprintf("%06X",$IP | 0x8000);#sprintf("%08X",$Line-1 | 0x8000);
|
$EntryPoints{$1} = sprintf("%06X",$IP | 0x8000);#sprintf("%08X",$Line-1 | 0x8000);
|
#print ">> $EntryPoints{$1}\n";
|
print "Implemented @ 0x$EntryPoints{$1} --> $1\n";
|
next;
|
next;
|
}
|
}
|
|
|
if (m/[\s|\t]*(\S+)\:.*\n/)
|
if (m/[\s|\t]*(\S+)\:.*\n/)
|
{
|
{
|
print "$1 " . sprintf("%08X",$InstructionCount | 0x8000) . "\n";
|
# print "$1 " . sprintf("%08X",$InstructionCount | 0x8000) . "\n";
|
$Labels{$1} = ($IP | 0x8000);#(($Line-1) | 0x8000); #sprintf("%08X",$Line-1 | 0x8000)
|
$Labels{$1} = ($IP | 0x8000);#(($Line-1) | 0x8000); #sprintf("%08X",$Line-1 | 0x8000)
|
print "$1 = $Labels{$1}\n";
|
# print "$1 = $Labels{$1}\n";
|
next;
|
next;
|
}
|
}
|
|
|
$IP++;
|
$IP++;
|
$InstructionCount++;
|
$InstructionCount++;
|
Line 157... |
Line 172... |
|
|
push @D_Tokens, hex $Registers{$Token};
|
push @D_Tokens, hex $Registers{$Token};
|
|
|
} elsif (defined $Labels{$Token})
|
} elsif (defined $Labels{$Token})
|
{
|
{
|
print "$Labels{$Token}\n";
|
# print "$Labels{$Token}\n";
|
push @D_Tokens, ($Labels{$Token}+$EntryAddrCount);
|
push @D_Tokens, ($Labels{$Token}+$EntryAddrCount);
|
|
}elsif (defined $EntryPoints{$Token}){
|
|
|
|
push @D_Tokens,hex $EntryPoints{$Token};
|
} elsif ($Token =~ m/32\'h(.*)/) {
|
} elsif ($Token =~ m/32\'h(.*)/) {
|
#if this is inmmediate value of 32 bits, then insert 0 and then the value
|
#if this is inmmediate value of 32 bits, then insert 0 and then the value
|
push @D_Tokens,0;
|
push @D_Tokens,0;
|
push @D_Tokens, hex $1;
|
push @D_Tokens, hex $1;
|
} else {
|
} else {
|