I happen to be working on a circuit with 3 ports, for checking the limits of it's operation, I need to switch 3 different inputs on these 3 ports. So 3! = 6 permutations.
I thought I could simply make the 3 inputs be connected to output ports, then assign the individual port names to variables inside a VAR (multiplexed by conditional if-else):
VAR
MY_VAR
PORT1=if (mode == 1) then IN1 elseif (mode == 2) then IN2 else IN3 endif
PORT2=if (mode == 1) then IN2 elseif (mode == 2) then IN1 else IN3 endif
PORT3=if (mode == 1) then IN3 elseif (mode == 2) then IN2 else IN1 endif
/* ^only a shortened example, not actual declaration */
/* "mode" is "Parameter Sweep"-ed */
These variables PORT1, PORT2, PORT3 are then the same name as the input ports (there's really no parameter in input ports to assign these values). So the intended effect is mapping the IN1, IN2, IN3 to PORT1, PORT2, PORT3 with the permutations afforded by the conditionals.
I quickly found out that that could never work as these are Simulator Expressions -- processes that happen before the numerical calculations are done, simply used as initial starting values for everything else.
Seems like I have to rely on Symbolically Defined Devices. I skimmed through the help file and realized that it a little bit too much to learn in a few day's time. So I was wondering if there was a more direct way of doing this?
Edited by: ren_zokuken01 on Mar 20, 2016 9:47 AM
I thought I could simply make the 3 inputs be connected to output ports, then assign the individual port names to variables inside a VAR (multiplexed by conditional if-else):
VAR
MY_VAR
PORT1=if (mode == 1) then IN1 elseif (mode == 2) then IN2 else IN3 endif
PORT2=if (mode == 1) then IN2 elseif (mode == 2) then IN1 else IN3 endif
PORT3=if (mode == 1) then IN3 elseif (mode == 2) then IN2 else IN1 endif
/* ^only a shortened example, not actual declaration */
/* "mode" is "Parameter Sweep"-ed */
These variables PORT1, PORT2, PORT3 are then the same name as the input ports (there's really no parameter in input ports to assign these values). So the intended effect is mapping the IN1, IN2, IN3 to PORT1, PORT2, PORT3 with the permutations afforded by the conditionals.
I quickly found out that that could never work as these are Simulator Expressions -- processes that happen before the numerical calculations are done, simply used as initial starting values for everything else.
Seems like I have to rely on Symbolically Defined Devices. I skimmed through the help file and realized that it a little bit too much to learn in a few day's time. So I was wondering if there was a more direct way of doing this?
Edited by: ren_zokuken01 on Mar 20, 2016 9:47 AM
IN1, IN2 and IN3 this time are wire labels PORT1, PORT2 and PORT3, likewise, are wire labels. Then we have a VAR:
VAR
MY_VAR
PORT1=if (mode == 1) then _Node(IN1) elseif (mode == 2) then _Node(IN2) else _Node(IN3) endif
PORT2=if (mode == 1) then _Node(IN2) elseif (mode == 2) then _Node(IN1) else _Node(IN3) endif
PORT3=if (mode == 1) then _Node(IN3) elseif (mode == 2) then _Node(IN2) else _Node(IN1) endif
/* ^only a shortened example, not actual declaration */
/* "mode" is "Parameter Sweep"-ed */
Neatly solved. But, I do admit, this might not go well with how the whole system works together.
Edited by: ren_zokuken01 on Mar 20, 2016 9:55 AM