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

Subversion Repositories nanoblaze

[/] [nanoblaze/] [trunk/] [Tools/] [nanoasm.pl] - Diff between revs 7 and 12

Show entire file | Details | Blame | View Log

Rev 7 Rev 12
Line 6... Line 6...
################################################################################
################################################################################
# Input arguments
# Input arguments
#
#
use Getopt::Std;
use Getopt::Std;
my %opts;
my %opts;
getopts('hva:d:r:k', \%opts);
getopts('hva:d:r:kz', \%opts);
 
 
die("\n".
die("\n".
    "Usage: $0 [options] fileSpec\n".
    "Usage: $0 [options] fileSpec\n".
    "\n".
    "\n".
    "Options:\n".
    "Options:\n".
Line 18... Line 18...
    "${indent}-v        verbose\n".
    "${indent}-v        verbose\n".
    "${indent}-a bitNb  the number of program address bits\n".
    "${indent}-a bitNb  the number of program address bits\n".
    "${indent}-d bitNb  the number of data bits\n".
    "${indent}-d bitNb  the number of data bits\n".
    "${indent}-r bitNb  the number of register address bits\n".
    "${indent}-r bitNb  the number of register address bits\n".
    "${indent}-k        keep source comments in VHDL code\n".
    "${indent}-k        keep source comments in VHDL code\n".
 
    "${indent}-z        zero don't care bits in VHDL ROM code\n".
    "\n".
    "\n".
    "Assemble code to VHDL for the nanoBlaze processor.\n".
    "Assemble code to VHDL for the nanoBlaze processor.\n".
    "\n".
    "\n".
    "More information with: perldoc $0\n".
    "More information with: perldoc $0\n".
    "\n".
    "\n".
    ""
    ""
   ) if ($opts{h});
   ) if ($opts{h});
 
 
my $verbose              = $opts{v};
my $verbose              = $opts{v};
my $keepComments         = $opts{k};
my $keepComments         = $opts{k};
 
my $zeroDontCares        = $opts{z};
my $addressBitNb         = $opts{a} || 10;
my $addressBitNb         = $opts{a} || 10;
my $registerBitNb        = $opts{d} || 8;
my $registerBitNb        = $opts{d} || 8;
my $registerAddressBitNb = $opts{r} || 4;
my $registerAddressBitNb = $opts{r} || 4;
 
 
my $asmFileSpec = $ARGV[0] || 'nanoTest.asm';
my $asmFileSpec = $ARGV[0] || 'nanoTest.asm';
Line 452... Line 454...
    if ($operand2 =~ m/s[0-9A-F]/) {
    if ($operand2 =~ m/s[0-9A-F]/) {
      $operand2 =~ s/\As//;
      $operand2 =~ s/\As//;
      $operand2 = toBinary($operand2, $registerAddressBitNb);
      $operand2 = toBinary($operand2, $registerAddressBitNb);
      if ($registerBitNb > $registerAddressBitNb) {
      if ($registerBitNb > $registerAddressBitNb) {
        $operand2 = $operand2 . '-' x ($registerBitNb - $registerAddressBitNb);
        $operand2 = $operand2 . '-' x ($registerBitNb - $registerAddressBitNb);
 
        if ($zeroDontCares) {
 
          $operand2 =~ s/\-/0/g;
 
        }
      }
      }
    }
    }
                                                     # address as second operand
                                                     # address as second operand
    elsif ($opcode =~ m/\Abr/) {
    elsif ($opcode =~ m/\Abr/) {
      my $fill = '';
      my $fill = '';
      if ($binaryBranchInstructionLength < $binaryInstructionLength) {
      if ($binaryBranchInstructionLength < $binaryInstructionLength) {
        $fill = '-' x ($binaryInstructionLength - $binaryBranchInstructionLength);
        $fill = '-' x ($binaryInstructionLength - $binaryBranchInstructionLength);
 
        if ($zeroDontCares) {
 
          $fill =~ s/\-/0/g;
 
        }
      }
      }
      if ( ($opcode =~ m/Ret/) ) {
      if ( ($opcode =~ m/Ret/) ) {
        $operand2 = $fill . '-' x $addressBitNb;
        $operand2 = $fill . '-' x $addressBitNb;
      }
      }
      else {
      else {

powered by: WebSVN 2.1.0

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