Timothy Miller wrote: > I can put the files on SVN. I have finals on monday, so I may forget, > even though I put it in my planner -- feel free to remind me. :) You probably don't need the reminder, but I have an updated version anyway. Most importantly it transforms the errors into a format that Vim and Emacs understands. The "isp" prefix is to categorise it with potential other wrappers around the ispLEVER Starter installation.
#! /usr/bin/env perl
# Copyright (c) 2006 Petter Urkedal
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# This license notice applies to THIS FILE ONLY, not to the software that it
# invokes.
use strict;
use Getopt::Long;
use Pod::Usage;
use File::Spec;
use File::Temp qw(tempdir);
use File::Basename;
use File::Copy;
use Switch;
use Text::Wrap;
use Term::ANSIColor;
sub path_to_winepath($)
{
my ($path) = @_;
return "z:".File::Spec->rel2abs($path);
}
sub boolopt($)
{
my ($value) = @_;
if ($value == "true") { return 1; }
elsif ($value == "false") { return 0; }
else { die "boolean option must be true or false"; }
}
# Parse config and command line
#
open CF, "$ENV{HOME}/.ogptools/isplever.conf"
or die "You need to set up ~/.ogptools/isplever.conf";
my $isplever_dir;
my $target = "isplsi5000ve";
my $use_colour = 0;
my $show_last = 0;
my $grab_extensions = "edif,vm,vhm";
my $out_base;
my $wrap_lines = 0;
my $print_notes = 1;
my $print_redundant = 0;
while (<CF>) {
next if /^\s*(#.*)?$/;
if (/^\s*(\S*)\s*=\s*(\S*)\s*$/) {
my $value = $2;
switch ($1) {
case "isplever_dir" { $isplever_dir = $value; }
case "default_target" { $target = $value; }
case "print_notes" { $print_notes = boolopt($value); }
case "print_redundant" { $print_redundant = boolopt($value); }
case "grab_extensions" { $grab_extensions = $value; }
case "wrap_lines" { $wrap_lines = boolopt($value); }
case ["colour", "color"] { $use_colour = boolopt($value); }
else { die "Unknown configuration variable"; }
}
}
else { die "Syntax error"; }
}
die "Configuration file must define isplever_dir" unless $isplever_dir;
my $module;
GetOptions(
"help" => sub() { pod2usage(0); },
"module|m=s" => \$module,
"target|t=s" => \$target,
"o=s" => sub($$) {
my $ign;
($ign, $out_base) = @_;
$out_base =~ s/\.edif$//;
},
"grab-extensions" => \$grab_extensions,
"colour|color" => sub() { $use_colour = 1; },
"nocolour|nocolor" => sub() { $use_colour = 0; },
"show-last" => \$show_last
) or pod2usage(2);
my @sources = @ARGV;
my @wine_sources = map(path_to_winepath($_), @sources);
if (!$module) {
pod2usage("Module name is required when compiling more than one source.")
unless $#sources == 0;
$module = basename $sources[0];
$module =~ s/\.[^.]+$//;
}
pod2usage(2) unless $module or $show_last;
# Make a command file
#
my $tmp_dir = tempdir(CLEANUP => 0)
or die "Could not create temporary directory";
my $cmd="$tmp_dir/$module.cmd";
my $build_dir = $ENV{"PWD"};
chdir $tmp_dir or die "Could to change to temporary directory";
open CMD, ">$cmd" or die "Can not write to temporary directory";
print CMD <<__end__;
PROJECT: unspecified
WORKING_PATH: "z:$tmp_dir"
MODULE: $module
VERILOG_FILE_LIST: @wine_sources
OUTPUT_FILE_NAME: $module
SUFFIX_NAME: edif
Vlog_std_v2001: true
__end__
close CMD;
# Invoke Synplify
#
# SynpWrap.exe -e <command file name> [ -rem ]
# [ -part <part name> ] [ -target <target name> ]
my $exit_status;
if (!$show_last) {
unlink("automake.err");
my $exit_status =
system("wine", "$isplever_dir/ispcpld/bin/Synpwrap.exe",
"-e", $module, "-target", "$target");
}
open ERR, "automake.err" or die "Didn't find automake.err";
my $lastblank = 0;
foreach(<ERR>) {
s/\r//g;
next if /^fixme:/; # Wine
next if /#[^#]/;
next if /[EMAIL PROTECTED]/;
next if /^\$ Start of Compile/;
if (/^\s*$/) {
next if $lastblank;
$lastblank = 1;
print;
} else {
$lastblank = 0;
if (!$print_redundant) {
next if /Synthesizing module/;
next if /Creating black box/;
next if /[EMAIL PROTECTED]::"[^"]*"$/;
}
if (/^@([NWE]): *([[:alnum:]]*) *: *"([^"]+)":([0-9:]+)\|(.*)$/) {
my $msgtype = $1;
my $some_sort_of_code_maybe_error_number_q = $2;
my $path = $3;
my $location = $4;
my $msg = $5;
my $colour;
switch ($msgtype) {
case "N" {
$msgtype = "note: ";
$colour = "green";
next unless $print_notes;
}
case "W" {
$msgtype = "warning: ";
$colour = "yellow";
}
case "E" {
$msgtype = "";
$colour = "red";
}
}
$path =~ s/\\/\//g if $path =~ s/^[zZ]://;
print color $colour if $colour && $use_colour;
if ($wrap_lines) {
print wrap("", " ", "$path:$location: $msgtype$msg\n");
} else {
print "$path:$location: $msgtype$msg\n";
}
print color "reset" if $colour && $use_colour;
}
else {
print;
}
}
}
close ERR;
# Get Output Files
#
# Add the extensions of the files that are needed below.
chdir $build_dir or die "Could not change back to build directory";
foreach (split(",", $grab_extensions)) {
if (-e "$tmp_dir/$module.$_") {
print "Writing '$out_base.$_'.\n";
copy("$tmp_dir/$module.$_", "$out_base.$_");
}
}
exit $exit_status == 0? 0 : 2;
__END__
=head1 NAME
ispsympc -- Run the Synplify Synthesis Module of ispLEVER
=head1 SYNOPSIS
ispsympc [OPTIONS] --module|-m MODULE VERILOG_SOURCE...
=head2 Options
=over 8
=item --module|-m
The module to compile. Required.
=item --target|-t
Target chip to compile for.
=item -o
Main output file name. This should end in .edif.
=item --grab-extensions
The extensions of the files which should be stored after the compilation.
=item --colour|--color
Use colour-coded messages.
=item --nocolour|--nocolor
Don't use colour-coded messages.
=item --wrap-lines
Wrap long lines in error messages.
=back
=head1 PREREQUISITES
This tool requires that ispLEVER Starter is installed under Wine. See the wiki
at http://www.opengraphics.org/ if you have problems installing it. You must
also configure Wine such that drive "z" refers to the file system root ("/").
This is the Wine default. Finally, configuration file described below must at
least define isplever_dir.
=head1 CONFIGURATION
The configuration file is ~/$HOME/.ogptools/isplever.conf. it in "KEY = VALUE"
format, one definition per line, with support for blank lines and pure comment
lines starting with "#". It should at least set "isplever_dir". Corresponding
command line options take precedence if present.
=head2 Options
=over 8
=item isplever_dir
The directory where the ispLEVER installation is found. This can be in any
format undorstood by Wine, but must imply the correct drive.
=item default_target
Default target chip to synthesise for.
=item grab_extensions
Comma-separated (no spaces) list of the extensions of the files that should be
produced. These include edif, tlg, vm, vhm, srs, srm, log, cmd.
=item wrap_lines
If "true", wrap long lines in error messages.
=item colour | color
If "true", colour-code error messages.
=back
=head2 Example
# The root directory if the ispLEVER installation.
# Must include the correct drive.
isplever_dir = c:/ispTOOLS6_0_STRT
# The default target (chip).
default_target = isplsi5000ve
=head1 FILES
=over 4
=item $HOME/.ogptools/isplever.conf
=back
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ Open-graphics mailing list [email protected] http://lists.duskglow.com/mailman/listinfo/open-graphics List service provided by Duskglow Consulting, LLC (www.duskglow.com)
