• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. RF Design
  3. Subcircuit string parameters will not pass to a SUBCKT NET...

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 62
  • Views 12242
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Subcircuit string parameters will not pass to a SUBCKT NET=, but works with local variable.

FormerMember
FormerMember over 4 years ago

Hello,

I'm trying to pass the name of an s2p Data File into a subcircuit parameter so I can have a subcircuit with a big template but change the s2p being used in that subcircuit by variable name.

It works if I set the name of the s2p datafile in the subcircuit, but it does not work if I pass the s2p data file name as a string argument to the subcircuit.  The first image shows it working with A="100A0R5" and the second image shows the error with A<<"100A0R5".  Is this some kind of bug when passing strings to subcircuits and using them with NET= in a sub-subcircuit?  I have attached a small test project to demonstrate the problem.  Just change the A<< parameter to an A= variable in the S2 schematic and press F8 to render the graph:

Working:

Not Working:

Here is the error:

Here is the .emz:

Subcircuit Parameter Test.zip

  • Cancel
  • FormerMember
    FormerMember over 4 years ago

    Oh, I got it to work!  You have to right-click on the A<<"String" EQN and set its datatype to a string.

    Maybe someone can pass this on to the developers: it sure would be nice if the error said something like "Error evaluating parameter 'A', expecting variable type of 'String'" or something similar.  It would have at least pointed me in the right direction.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • FormerMember
    FormerMember over 4 years ago in reply to FormerMember

    Actually I think the error in this example might more accurately be something like "A@SUBCKT.S1 is of type Real but was passed a String"

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MohiK
    MohiK over 4 years ago

    The right way to do this is to create an MDIF file.  Please see:  https://awrcorp.com/download/faq/english/docs/Users_Guide/data_file_formats.html#generalized_mdif

    You can create these manually, or there is a script to help create them: https://kb.awr.com/display/awrutil/Generate+MDIF+from+Collection+of+Files

    I would strongly advise using MDIF, which will also work for sweeping through multiple s-parameter sets.  (Sweeping subcircuit names is a bad idea.)

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • FormerMember
    FormerMember over 4 years ago in reply to MohiK

    Interesting!

    Can I put the .s2p file content directly within the ACDATA/END blocks?  For example, here is some s2p from an AVX component, Is this valid MDF?

    VAR C_pF=0.1
    Begin ACDATA
    # mhz S db R 50
    50 -82.86e-6 -0.96 -49.319 89.162 -49.319 89.162 -81.41e-6 -0.961
    75 -129e-6 -1.441 -45.797 88.592 -45.797 88.592 -124.7e-6 -1.442
    End

    The documentation seems to imply that this is possible.  Will it just figure it out or is the "% F n11x n11y n21x n21y n12x n12y n22x n22y" line necessary?

    Are there any existing tools that compile a bunch of s2p's into an mdf?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • FormerMember
    FormerMember over 4 years ago in reply to FormerMember

    Upon closer inspection, the "%F n11x n11y n21x n21y n12x n12y n22x n22y" line appears to be required, but correct me if I am wrong.

    The n11x and n11y values are clearly db and phase in this example, but can they ever represent something else?  Is it always an x and y suffix, or are their other suffixes with other meanings?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MohiK
    MohiK over 4 years ago in reply to FormerMember

    Please see my previous message for a link to a script that compiles s-parameter data into an MDIF format file.

    The data can be real-imaginary, magnitude-degrees, or magdB-degrees (RI, MA, or DB).  The header line beginning with the hashtag is standard Touchstone format.  See https://awrcorp.com/download/faq/english/docs/Users_Guide/data_file_formats.html#i477948

    (I only remember seeing MDIF used for s-parameters.  So if you try another port parameter type, check the results.)

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • FormerMember
    FormerMember over 4 years ago in reply to MohiK

    This script takes a bunch of .s2p files and formats them as an MDF.  It decodes the pF or nH code and sorts the entries by value:

    For example, if the files are ./100B/100A101F.S2P like those from AVX ATC, then this script compiles them into an MDF and parses the bolded value in the name by regex as 100pF.  It also parses codes like 1R5 meaning 1.5pF and assigns them to the MDF variable C_pF:

    #] parse-sizes --vars 'C_pF,.*/....(...)' ./100B/100* > avx_atc.mdf

    ===== parse-sizes =====

    #!/usr/bin/perl 

    use strict;
    use warnings;
    use Getopt::Long qw(:config bundling);
    use Data::Dumper;

    my %opts;
    my %files;

    GetOptions(
    "var|v=s" => \@{ $opts{vars} },
    "mdf|m=s" => \$opts{mdf},
    "sort|s=s" => \$opts{sort}
    ) or usage();

    usage() if ( !@ARGV );
    usage() if ( !@{ $opts{vars} } );

    $opts{sort} //= $opts{vars}->[0];
    $opts{sort} =~ s/,.*$//;

    foreach my $file (@ARGV)
    {
    my %vars;

    foreach my $var_regex (@{ $opts{vars} })
    {
    my ( $var, $regex ) = split(/,/, $var_regex);
    my $val;

    if ( $file =~ /$regex/ && $1 )
    {
    $val = $1;
    if ( $val =~ s/[A-Z]/./i )
    {
    $vars{$var} = $val;
    }
    elsif ( $val =~ s/^(\d+)(\d)$/$1/ )
    {
    $vars{$var} = $1 * (10 ** $2);
    }
    else
    {
    warn "$file: unknown value code $val";
    }
    }
    else
    {
    warn "$file: Does not match regex $regex for $var.";
    }
    }

    if ( !defined($vars{$opts{sort}}) )
    {
    die "$file: no sort column found for $opts{sort}";
    }

    $files{$file} = \%vars;
    }

    foreach my $file ( sort { $files{$a}->{$opts{sort}} <=> $files{$b}->{$opts{sort}} } keys %files )
    {
    my $c = read_file($file);

    foreach my $var ( keys(%{ $files{$file} }) )
    {
    print "VAR $var=$files{$file}{$var}\n";
    }

    print "Begin ACDATA\n";
    print "%F n11x n11y n21x n21y n12x n12y n22x n22y\n";
    print "$c\n";
    print "End\n\n";

    }

    #print Dumper(\%files);

    exit 0;

    sub usage
    {
    print "$0 --var 'C_pF,regex(NNX|N[A-Z])' [--var ...] --mdf output_file file1.s2p [file2...]\n";
    print " --var specifies the variable to be assigned and a reglar
    expression to match the capacitance code (or other unit). X is
    the exponent, N is a numeric value. A-Z is typically used by
    manufacturers to indicate the decimal point.\n";

    exit 1;
    }

    sub read_file
    {
    my $fn = shift;
    local $/ = undef;
    open(my $in, $fn) or die "$!: $fn";

    my $content = <$in>;
    close($in);
    return $content;
    }
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • FormerMember
    FormerMember over 4 years ago in reply to FormerMember

    Looks like the forum broke indentation, here it is as a .zip:

    parse-sizes.zip

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MohiK
    MohiK over 4 years ago in reply to FormerMember

    Hi Eric,

    Just curious: were the libraries already available in the AWR Design Environment outdated or not accessible to you?  Add a schematic, View > Element Browser > Circuit Elements > Libraries > * AWR web site > Parts By Vendor > AVX > Capacitor > Accu-P > 0603 > MDIF, drag element from lower pane into schematic.  Sorry I didn't think to ask earlier.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information