Programmable attributes: `LOOKUP<>`

Hello everyone

Has anyone managed to make this work? The way I’m reading the help it’s about having the possibility to use a “template” symbol which can call other symbols (or subcircuits, like LTspice) by using a multiple choice attribute, and have the symbol change shape, parameters, etc (similar to Simulink?). See Help > QSPICE > Schematic Capture > Symbol Editor > Programmable Attributes, 5th entry, in particular 2nd note). What I did:

  1. new C block, y=a*b
  2. make symbol for it, name it “mult”, save it in ./mult/mult.qsym (with source and .dll)
  3. new C block, y=a+b
  4. symbol, name it “add”, save it in ./add/add.qsym (source+.dll)
  5. in sym. ed. delete everything, create (e.g.) basic circle, no pins, make symbol type Φ, add 1st attribute lookup<1,2;mult,add>, 2nd type=<1,2> (w/o parenthesis), save as ./math.qsym
  6. mkdir [QSPICE]/Repository (symlink seems to work, too), move math/* inside
  7. new schematic, look for “math” symbol and place it in the schematic

I can select any type, 1 or 2, from the drop-down menu but, nothing happens – and QSPICE adds a red “!” when I hover the mouse over it. If I add some sort of name before lookup (e.g. name lookup<>), there is no more red “!” but, still, it doesn’t work. If I change lookup<2;mult,add> so that 2 references the 2nd attribute, nothing. Change type=<mult,add>, nothing. Restart QSPICE, nothing. How is it supposed to work? This has a lot of potential.

Oh and, don’t know if you noticed it, char* parameters are not case sensitive (FoObAr reads foobar). Just a heads-up.

Hi, Vlad.

A few of us have been working on this (@LPoma, @KSKelvin).

This is the topic of my next C-Block Basics paper (#15). The paper isn’t finished but I’ll go ahead and upload the example files to my GitHub repo. They may be enough to get you started.

I’ll update this post once the files are uploaded.


The example files are now on the dev branch of my Github repository.

  1. Download the CB15_*.* files.
  2. CB15_Filter.qsym is the top-level symbol.
  3. Put the remaining *.qsym files in [QSpice Install Dir]\Repository\CB15_Filter.
  4. Compile the *.dll.
  5. Open/run CB15_Demo.qsch.

Let me know if there are any issues.

–robert


Edit: The paper is now available on the repo.

1 Like

Hello Robert

I had managed to get one step closer to the truth by eliminating the indices, lookup<;mult,add> which made the symbol change shape but with missing pins and, funny enough, even though the symbol, itself, was not saved with the extra information, everytime I placed it in the schematic, new, it would automatically change to the one I had previously set and stubbornly refuse to accept any other change.

Thank you for the files, they clearly showed what I misunderstood (the indices vs parameters/variables for example). They’ve also made it clear, once more, that Mike’s help files need patience to take time to study and read everything that’s between the lines. Sadly, what I wanted was to be able to inherit full symbols, to avoid having to make a yuge .dll and only have symbols change – that way, separate access to individual symbols would have also been possible. Maybe some other day.

Vlad

Hi, Vlad.

Sorry it didn’t solve your specific use-case. The description isn’t really clear to me. If you could provide a concrete example of what you’re trying to do, maybe we can figure out a way to do it.

–robert

Hello Robert

Currently, the master symbol needs to have a library attached and that lib needs to take care of everything; the additional symbols serve only a cosmetic purpose, mostly (additional parameters still need to be taken care of inside the master lib).

What I wanted was to have the master symbol let the inherited symbols have each one their own lib – in the same way LTspice did it. See this page for example (the two small .webm at the top).

It can still be done with .sub (the same way as in the link) but, I was hoping for .dll. That way, you can have the cosmetic change, together with the functionality, while still being able to export the project without the encumbrance of all the symbols (e.g. if I only use add and mul then there’s no need to prepare the symbols for dif and div, too).

Vlad

Vlad,

I’m a bit confused as to your intended goal.

However, attached is a simple project with symbol called “Math”
It’s a 2-input and 1-output symbol You can select Add, Sub, Mult or Div of in1 and in2.

The math operation is selectable and fed to the math.dll. You can add more math functions as needed. The math.cpp source code should be clear.
Math.zip.txt (2.8 KB)

At least this might be a good starting point.

Hello Ipoma

You somehow saved the .zip file with an added .txt, it may confuse some people. :slight_smile: Until they open it, anyway.

Currently, the master symbol needs to have a library attached and that lib[rary] needs to take care of everything;

This is what you have now: one symbol and one library, that encompasses all the functions. What you’re showing I can achieve.

I don’t know what’s unclear (you’re not saying) but, maybe if I explain it differently. What I wanted was this (example):

add.qsym
add.dll
dif.qsym
dif.dll
mul.qsym
mul.dll
div.qsym
div.dll

Place add and it works on its own. Change its name adddiv and it works on its own (functional and, optional, cosmetic). That’s what you saw in the link above.

If a project needs exporting (to a computer elsewhere in the world) and is only using add and div then having to export all four symbols+dlls would be cumbersome. This way, only the needed files can be sent, and no more, while still working on that computer, whereas using your example, exporting only add and div is impossible (without intervention).

You may say that “so what, it’s just two extra lines of code”. True in this case but, this is just an example. If the libraries are “fluffier” than that, it’s cumbersome. And, potentially unneeded. Remember that there are the .prot and .unprot commands, and some people use them. Do you understand now?

As for a possible solution, one way would be by having the symbols, themselves, automatically call the library with the same name, when changed. If they also change the symbol, it’s a perk. Maybe a flag? This could be a feature, in case Mike is reading and is interested. Or not. As per the ending of the 3rd message in the thread – it’s not the end of the world if it can’t be done.

Vlad

Hi, Vlad.

To be fair, like @LPoma, I’m also having trouble understanding the “issue.” So, let’s try again…

You could have four different symbols that load four different DLLs (one symbol + 1 DLL for each of add, dif, mul, and div). You could add them to the Symbol & IP Browser. To change a function, you’d have to delete the symbol in the schematic and drag a different symbol to the schematic. To share your schematic, you’d need to ship the schematic and DLLs for the symbols used in the schematic. (The symbol file (*.qsym) is copied into the schematic when dropped and isn’t required to run the simulation.)

But you don’t want that. You want a top-level symbol where the user chooses a different function and it automatically loads a second-level symbol which calls the DLL for that function. Further, you want each function DLL to remain separate rather than roll the code for all four functions into a single DLL.

I don’t understand why you’d want to have separate DLLs for each function but let’s roll with it. More complicated but doable. Here’s one way:

Create a top-level symbol – let’s call it “math.qsym.” This is a DLL symbol and calls a DLL called “math_interface.dll.” If you want each function to be graphically unique, create a second-level symbol for each function. If they don’t need to be graphically unique, then you don’t need those symbols and you don’t need Lookup – just pass a multiple-choice function attribute to math_interface.dll. In that DLL, load the appropriate function DLL (add.dll, dif.dll, etc.) with LoadLibrary(). In the math_interface.dll evaluation function, call the dynamically loaded DLL function to evaluate the function.

This seems a great deal of effort for what seems like no advantage over simply having each function be a separate symbol dragged from the Symbol & IP Browser of course. But, if that’s what you want and the LoadLibrary() thing is acceptable, I’ll help you work that out.

But maybe I’m still not getting the “issue.” If so, please forgive my slowness and explain a bit further.

–robert

1 Like

@archbugaboo ,

Here’s my second attempt to achieve your goal. (Probably still comes short)

Math_2.zip.txt (6.7 KB)

When you open Math_test.qsch,

It has the Math.qsym already loaded with Add as the math operation.

Run it. Then out = in1+in2. It runs add.dll

Change the 1st Attribute manually to Dif.

Run it. Then out = in1-in2. It runs dif.dll

Change it to Mul (it runs mul.dll) or to Divide (it runs divide.dll).

Closer. But probably not what you wanted with the 2nd-level symbol.

The issue is that the 1st text Attribute MUST be the name of the dll. It appears it can’t be a multi-select which is needed to support the LOOKUP<> 2nd-level symbol layering.

Len

2 Likes

Hello Robert

I’m also having trouble understanding the “issue.”

Who said it’s an “issue”, kid? I told you to watch your tone. If you’d spend half the time you take to pour all this sarcasm into answers and, instead, use it to read carefully, you’d have understood. Acting like this will not make you look smart or savvy, in any way. The only thing that says about you is that you’re plagued with an infantile mentality and you can’t control yourself even when you’re on a forum that’s meant to be a link to the world for Qorvo. Why do you think people all over the world want to see your antics? Why do you think the people from Qorvo do? What is it that you think you’re achieving by behaving like this?

I’ve browsed the forum a bit and I see that you look comfortable enough with programming and you’re an active contributor; good for you. But, I don’t see this attitude anywhere else, which means it’s something about me. What can it be? We’ve never met. I have no idea who you are and I’m sure the reciprocal is just as true. So then, what reasons do you have for using this tone with me? Because, so far, it looks like you’re suffering from the same affliction that plagues any long time users and contributors to a forum: arrogant self-entitleness.


But, maybe I’m the odd one out? Then this is for the moderators: you be the judges. For my part, I thought I was polite and to the point, and I’ve even shown enough patience to let sourness aside and address the questions, even once more if necessary. If I wasn’t then please point out which parts were not, and why. If you don’t mind, I would ask that you also argue on what and why on the other side – I would like to correct myself.


Hello lpoma

I wonder if you, too, have missed the “solved” part, and the two times I said it’s no big deal if it can’t happen? If you want to insist then, by all means, feel free to follow your thoughts but, please, don’t make it sound as if it’s me you’re answering (or being forced to answer) to.

Vlad