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

Subversion Repositories openrisc

[/] [openrisc/] [branches/] [or1200_rel3/] [doc/] [preprocess.pl] - Diff between revs 645 and 795

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 645 Rev 795
#!/usr/bin/perl
#!/usr/bin/perl
# Preprocessing of the spec file.
# Preprocessing of the spec file.
# So far the table with the instruction list is modified.
# So far the table with the instruction list is modified.
# Output is printed to stdout.
# Output is printed to stdout.
 
 
use warnings;
use warnings;
use strict;
use strict;
use POSIX qw (ceil);
use POSIX qw (ceil);
 
 
if (@ARGV != 1) {
if (@ARGV != 1) {
    print "Usage: preprocess.pl infile ('-' for stdin)\n";
    print "Usage: preprocess.pl infile ('-' for stdin)\n";
    exit 1;
    exit 1;
}
}
 
 
my $infile = $ARGV[0];
my $infile = $ARGV[0];
 
 
if ($infile eq '-') {
if ($infile eq '-') {
    open(INPUT, '<-') or die $!;
    open(INPUT, '<-') or die $!;
} else {
} else {
    open(INPUT, '<', $infile) or die $!;
    open(INPUT, '<', $infile) or die $!;
}
}
 
 
my @inst_table;
my @inst_table;
my $insts_per_col = 18;
my $insts_per_col = 18;
my $inst_line = 0;
my $inst_line = 0;
my $inst_header;
my $inst_header;
my $inst_footer;
my $inst_footer;
 
 
while (<INPUT>) {
while (<INPUT>) {
    if (/^\| Instruction mnemonic/../^\|==/) {
    if (/^\| Instruction mnemonic/../^\|==/) {
        chomp;
        chomp;
        if (/^\| Instruction mnemonic/) {
        if (/^\| Instruction mnemonic/) {
            $inst_header = $_;
            $inst_header = $_;
            next;
            next;
        } elsif (/^\|==/) {
        } elsif (/^\|==/) {
            $inst_footer = $_;
            $inst_footer = $_;
            next;
            next;
        }
        }
        if ($inst_line < $insts_per_col) {
        if ($inst_line < $insts_per_col) {
            push @inst_table, $_;
            push @inst_table, $_;
        } else {
        } else {
            $inst_table[$inst_line % $insts_per_col] .= "\t" . $_;
            $inst_table[$inst_line % $insts_per_col] .= "\t" . $_;
        }
        }
        $inst_line++;
        $inst_line++;
    } else {
    } else {
        if (@inst_table) {
        if (@inst_table) {
            # complete the rows that have their last column empty
            # complete the rows that have their last column empty
            for (my $i = $inst_line % $insts_per_col; $i < $insts_per_col; $i++) {
            for (my $i = $inst_line % $insts_per_col; $i < $insts_per_col; $i++) {
                $inst_table[$i] .= "\t|\t|";
                $inst_table[$i] .= "\t|\t|";
            }
            }
            my $cols = ceil($inst_line / $insts_per_col);
            my $cols = ceil($inst_line / $insts_per_col);
            print $inst_header x $cols . "\n";
            print $inst_header x $cols . "\n";
            print join("\n", @inst_table) . "\n";
            print join("\n", @inst_table) . "\n";
            print $inst_footer . "\n";
            print $inst_footer . "\n";
            @inst_table = ();
            @inst_table = ();
        }
        }
        print $_;
        print $_;
    }
    }
}
}
close INPUT or die $!;
close INPUT or die $!;
 
 

powered by: WebSVN 2.1.0

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