Stepping C-Block Up To "Component" -- Parameters/Attributes/Hierarchical Schematics

I’ve looked at demos, help file, searched this forum, and Google’d but not finding answers so I’ll hazard a question or two and hope that I’m not missing something obvious. Hope that this isn’t embarrassingly basic…

I have a C-Block component (wavsrc.qsch, wavsrc.cpp, etc.) that compiles and executes as expected. It looks like this:

The next step is to be able to use one or more instances from a “parent” schematic. There are a couple of challenges. I was able to generate a “parent” with “Open Parent Schematic.” That picked up the ports but not any symbol attributes:

image

Obviously, I’d like for the component user to be able to specify unique attributes/parameters for each component instance.

FWIW, running the “parent” gives me this error:

So, what’s the magic way to pass parameters/attributes from a parent to the underlying child component?

TIA.

–robert

Additional info: “Component” netlist:

  • C:\Dev\QSpice\Projects\WavSrc2\WavSrc.qsch
    ؆X1 «REF´d» «CH1´d CH2´d» «» WavSrc char* filename=“.\samples\Stereo.wav” int loops=1 float gain=VGain
    R1 REF 0 1G
    .param VGain=2.0
    .tran 150ms
    .end

“Parent” netlist:

  • C:\Dev\QSpice\Projects\WavSrc2\WavSrcDemo.qsch
    X1 N01 VCH1 VCH2 WavSrc
    V1 N01 0 DC 0

.subckt WavSrc REF CH1 CH2
؆X1 «REF´d» «CH1´d CH2´d» «» WavSrc char* filename=“.\samples\Stereo.wav” int loops=1 float gain=VGain
R1 REF 0 1G
.param VGain=2.0
.tran 150ms
.ends WavSrc

.end

–robert

Hello Robert,

you could wrap the code block into a symbol, and you can add it to the Symbol & IP Browser. You should do it as you wrap up a schematic into a symbol, just the qsch contains a code block.

Draw a symbol, place pins, give names to them (Edit Pin Label), the pin names should meet the port names in your schematic. Place attributes: X for name, and the 1st attribute should match the qsch name. The Symbol Type not so clear, I leave it blank.

1 Like

@WinterMime

image

Thanks!

–robert