New Feature For Updating C-Block Code

Today’s QSpice update included the following revision note:

07/14/2025 Added a command to paste the variable declarations of the C++ interface to the clipboard so it's easier for you to edit the .cpp file after modifying the ports.

In the past, if you made any changes to a DLL block, you needed to generate a new C-Block code template to get the correct uData* definitions. That would overwrite your DLL *.cpp file with the generic template. Any prior code changes were lost.

The old work-around was to temporarily rename the DLL block in the schematic, generate template code to this temporary *.cpp, copy the uData array code from the temporary *.cpp to your existing code, and restore the block name in the schematic. Tedious and annoying, it was.

Now, right-clicking the C-Block in the schematic has a new option to generate only the uData port code directly into the clipboard. Open the C-Block *.cpp and paste the clipboard contents into the existing code and you’re done. (Of course, if you renamed/added/deleted ports or changed port data types, you still need to modify your code for the changes but you haven’t lost all of your existing code.)

For the above micro-controller C-Block, the clipboard contains:

   double       VDD        = data[ 0].d  ; // input
   double       RA0_I      = data[ 1].d  ; // input
   double       RA1_I      = data[ 2].d  ; // input
   double       RA2_I      = data[ 3].d  ; // input
   double       RA3_I      = data[ 4].d  ; // input
   double       RA4_I      = data[ 5].d  ; // input
   double       RA5_I      = data[ 6].d  ; // input
   bool         CLK        = data[ 7].b  ; // input
   const char * MdbSimPath = data[ 8].str; // input parameter
   const char * McPgm      = data[ 9].str; // input parameter
   double      &RA0_O      = data[10].d  ; // output
   bool        &RA0_C      = data[11].b  ; // output
   double      &RA1_O      = data[12].d  ; // output
   double      &RA2_O      = data[13].d  ; // output
   double      &RA4_O      = data[14].d  ; // output
   double      &RA5_O      = data[15].d  ; // output
   bool        &RA1_C      = data[16].b  ; // output
   bool        &RA2_C      = data[17].b  ; // output
   bool        &RA4_C      = data[18].b  ; // output
   bool        &RA5_C      = data[19].b  ; // output

Many thanks to Mike for a most welcome new feature!

–robert

1 Like