123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #!/usr/bin/perl
- #
- # Extract dependency files from a Quartus .qsf file
- #
- use strict;
- my($infile,$project) = @ARGV;
- my %fit_deps = ($infile);
- my %asm_deps = ();
- my %cof_list = ();
- my $output_dir = 'output_files';
- open(my $in, '<', $infile) or die;
- while (defined(my $l = <$in>)) {
- chomp $l;
- next unless ($l =~ /^\s*set_global_assignment\s+\-name\s+(\w+)\s+\"?(.*?)\"?\s*$/);
- my $type = $1;
- my $name = $2;
- if ($type =~ /^project_output_directory$/i) {
- $output_dir = $name;
- next;
- }
-
- next if ($type !~ /_file$/i || $type =~ /^generate_/i);
-
- $name =~ s/^quartus_\w+://;
- if ($name =~ /\.cof$/i) {
- $cof_list{$name}++;
- } elsif ($type =~ /^(mif|hex)_file$/i) {
- $asm_deps{$name}++;
- } else {
- $fit_deps{$name}++;
- }
- }
- close($in);
- sub print_deps($%) {
- my($target,%deps) = @_;
- print "\n", $target, " :";
- foreach my $dep (sort keys(%deps)) {
- print " \\\n\t", $dep;
- }
- print "\n";
- }
- my $fit_target = "$output_dir/$project.done";
- print_deps($fit_target, %fit_deps);
- my $asm_target = "$output_dir/$project.asm.done";
- $asm_deps{$fit_target}++;
- print_deps($asm_target, %asm_deps);
- print "\t\$(QCDB) --update_mif $project\n";
- print "\t\$(QASM) $project\n";
- foreach my $cof (sort keys(%cof_list)) {
- print "\t\$(QCPF) --convert $cof\n";
- }
- print "\ttouch $asm_target\n";
- exit 0;
|