@@ -1222,11 +1222,11 @@ sub generate_output_decode_for_state($$$) {
12221222 }
12231223 # now override with more blocking assignments for each conditional:
12241224 # Conditions are strictly ordered as if-else chains.
1225- my $else_if = " if" ; # First condition gets "if", rest get "else if "
1225+ my $else_if = " if" ; # First condition gets "if", rest get "elsif "
12261226 foreach my $condition (@{$decode -> {$k_condition_list }}) {
12271227 next if ($condition eq " all" );
12281228 print " ${indent}${else_if} (${condition} ) begin\n " ;
1229- $else_if = " else if " ;
1229+ $else_if = " elsif " ;
12301230 foreach my $var (sort keys %{$decode -> {$condition }}) {
12311231 print " ${indent} ${var} = " . $decode -> {$condition }-> {$var } . " ;\n " ;
12321232 }
@@ -1878,7 +1878,7 @@ sub keep_track_of_used_net {
18781878 }
18791879 }
18801880 while ($normalized_net =~ s /\s *(\[ [^\] ]* \] )\s *// x ) {
1881- main::log_info (" ${normalized_net} : removed slice: ${1}" );
1881+ main::log_debug (" ${normalized_net} : removed slice: ${1}" );
18821882 }
18831883 if (!defined ($self -> {NETS }-> {$normalized_net })) {
18841884 # This is the first time we've encountered this
@@ -1936,6 +1936,54 @@ sub extract_iterables($) {
19361936 return $text , \@items ;
19371937}
19381938
1939+ sub extract_filters ($) {
1940+ my $macro = shift ;
1941+ my @pos_filters = ();
1942+ my @neg_filters = ();
1943+ my @macro_lines = split (/ \s *[\r\n ]\s */ , $macro );
1944+ foreach my $line (@macro_lines ) {
1945+ $line =~ s / ^\s +// ;
1946+ $line =~ s /\s +$// ;
1947+ if ($line =~ m / ^\s *$ / ) {
1948+ next ;
1949+ } elsif ($line =~ m / ^!(.*)/ ) {
1950+ push (@neg_filters , $1 );
1951+ } else {
1952+ push (@pos_filters , $line );
1953+ }
1954+ }
1955+ return (\@pos_filters , \@neg_filters );
1956+ }
1957+
1958+ sub apply_filters ($@) {
1959+ my $text = shift ;
1960+ my $pos_filters_ref = shift ;
1961+ my $neg_filters_ref = shift ;
1962+
1963+ my $matched = 1;
1964+ if ($# $pos_filters_ref > -1) {
1965+ $matched = 0;
1966+ $_ = $text ;
1967+ foreach my $filt (@$pos_filters_ref ) {
1968+ my $result = eval ($filt );
1969+ if ($result ) {
1970+ $matched = 1;
1971+ last ;
1972+ }
1973+ }
1974+ }
1975+ if ($# $neg_filters_ref > -1) {
1976+ foreach my $filt (@$neg_filters_ref ) {
1977+ my $result = eval ($filt );
1978+ if ($result ) {
1979+ $matched = 0;
1980+ last ;
1981+ }
1982+ }
1983+ }
1984+ return $matched ;
1985+ }
1986+
19391987$MacroHelp {' FORINST' } = <<EOT ;
19401988FORINST is a iterated version of the INST macro.
19411989
@@ -2577,15 +2625,7 @@ sub expand_autointerface($$) {
25772625 $sort_autoif = 1;
25782626 }
25792627
2580- my @filters = ();
2581- my @macro_lines = split (/ \s *[\r\n ]\s */ , $macro );
2582- foreach my $line (@macro_lines ) {
2583- $line =~ s / ^\s +// ;
2584- $line =~ s /\s +$// ;
2585- if ($line =~ m / ^m/ ) {
2586- push (@filters , $line );
2587- }
2588- }
2628+ my @filters = extract_filters($macro );
25892629
25902630 # parse the input and output ports of this module
25912631 my $my_interface = new ModuleSpec()-> parse_prototype($self -> {text });
@@ -2603,21 +2643,8 @@ sub expand_autointerface($$) {
26032643 next unless ($s =~ m /[[:alpha:] ]/ ); # Must have a letter
26042644 next if ($s =~ m /\W / ); # Must only contain "word" characters.
26052645
2606- # If we have filters enabled, skip signals that don't match filters.
2607- if ($#filters > -1) {
2608- my $matched = 0;
2609- $_ = $s ;
2610- foreach my $filt (@filters ) {
2611- my $result = eval ($filt );
2612- if ($result ) {
2613- $matched = 1;
2614- last ;
2615- }
2616- }
2617- if (!$matched ) {
2618- next ;
2619- }
2620- }
2646+ my $match = apply_filters($s , @filters );
2647+ if (!$match ) { next ; }
26212648
26222649 # examine each net:
26232650 my $ref = $self -> {NETS }-> {$s };
@@ -2776,15 +2803,7 @@ sub expand_autonet($$) {
27762803 $style = $2 ;
27772804 }
27782805
2779- my @filters = ();
2780- my @macro_lines = split (/ \s *[\r\n ]\s */ , $macro );
2781- foreach my $line (@macro_lines ) {
2782- $line =~ s / ^\s +// ;
2783- $line =~ s /\s +$// ;
2784- if ($line =~ m / ^m/ ) {
2785- push (@filters , $line );
2786- }
2787- }
2806+ my @filters = extract_filters($macro );
27882807
27892808 # parse the input and output ports of this module
27902809 my $my_interface = new ModuleSpec()-> parse_prototype($self -> {text });
@@ -2797,18 +2816,11 @@ sub expand_autonet($$) {
27972816 my $cb_signals = new SignalSet();
27982817
27992818 foreach my $s (@sigs ) {
2800- if ($#filters > -1) {
2801- my $matched = 0;
2802- $_ = $s ;
2803- foreach my $filt (@filters ) {
2804- my $result = eval ($filt );
2805- if ($result ) { $matched = 1; }
2806- }
2807-
2808- if (!$matched ) {
2809- next ;
2810- }
2819+ my $match = apply_filters($s , @filters );
2820+ if (!$match ) {
2821+ next ;
28112822 }
2823+
28122824 # if signal is in this module's interface, autonet should
28132825 # skip it:
28142826 if ($my_interface -> HasPort($s )) {
@@ -3054,7 +3066,7 @@ Currently, only one attribute is supported:
30543066* "SUBPATH=<path>"
30553067
30563068This attribute can be supplied multiple times, to specific multiple subpaths.
3057- This subpath specifies an additional path component to be searched for files
3069+ This subpath specifies an additional path component to be searched for file !m/^(dft_clk_en|dft_rst_n_bypass_in|dft_rst_n_bypass_en)/
30583070referred to by INST and FORINST macros. The search is performed by iterating
30593071through each INCDIR path, and then looking for the file in each SUBPATH
30603072beneath each INCDIR path.
@@ -3672,6 +3684,18 @@ EOT
36723684sub parse_config ($) {
36733685 my $configtext = shift ;
36743686
3687+ my @data = split m / ^\s *PERL:\s *$ / mso , $configtext ;
3688+ my $perlcode = " " ;
3689+ if ($#data > 0) {
3690+ $configtext = $data [0];
3691+ my $perlcode = $data [1];
3692+ eval ($perlcode );
3693+ if ($@ ) {
3694+ print " PERL ERROR:\n $@ \n " ;
3695+ print STDERR " PERL ERROR in config file:\n $@ \n\n $perlcode \n " ;
3696+ }
3697+ }
3698+
36753699 # remove comments
36763700 $configtext =~ s / (?<!\\ )#.*\n / \n / g ; # but not \#
36773701 $configtext =~ s /\\ #/ #/ g ; # turn \# into #
0 commit comments