diff --git a/README.md b/README.md index 22ec64f..2e4963c 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,8 @@ class Example(VA.Module): # link created modules together, from left to right self('INBOUND') - branch branch(0) - decision - branch(1) - condition - branch(2) - value - condition - decision('C') - value - decision('E') + branch(1) - condition - decision('C') + branch(2) - value - decision('E') decision - self('OUTBOUND') # for instance, set desired link properties @@ -53,8 +51,8 @@ class Example(VA.Module): value('O')['Arithmetic'] = 'signed' # (needs to match the input link) # for instance, set desired module properties - condition['Number'] = 0 - value['Value'] = 0 + condition['Number'] = 0 # input value threshold + value['Value'] = 0 # output value below threshold ``` Now the second part of our Python script: diff --git a/example.py b/example.py index 990d01c..141e7a0 100644 --- a/example.py +++ b/example.py @@ -17,10 +17,8 @@ def __init__(self, parent, name, x, y): # link created modules together, from left to right self('INBOUND') - branch branch(0) - decision - branch(1) - condition - branch(2) - value - condition - decision('C') - value - decision('E') + branch(1) - condition - decision('C') + branch(2) - value - decision('E') decision - self('OUTBOUND') # for instance, set desired link properties @@ -30,8 +28,8 @@ def __init__(self, parent, name, x, y): value('O')['Arithmetic'] = 'signed' # (needs to match the input link) # for instance, set desired module properties - condition['Number'] = 0 - value['Value'] = 0 + condition['Number'] = 0 # input value threshold + value['Value'] = 0 # output value below threshold if __name__ == '__main__': diff --git a/example.tcl b/example.tcl index 5e367be..58320ae 100644 --- a/example.tcl +++ b/example.tcl @@ -10,8 +10,8 @@ CreateModule "IF" "Process0/Example/Decision" "0" "0" "326" "43" ConnectModules "Process0/Example" "INBOUND#I000" "Process0/Example/Branch" "I" ConnectModules "Process0/Example/Branch" "O000" "Process0/Example/Decision" "I000" ConnectModules "Process0/Example/Branch" "O001" "Process0/Example/Condition" "I" -ConnectModules "Process0/Example/Branch" "O002" "Process0/Example/Value" "I" ConnectModules "Process0/Example/Condition" "O" "Process0/Example/Decision" "Condition000" +ConnectModules "Process0/Example/Branch" "O002" "Process0/Example/Value" "I" ConnectModules "Process0/Example/Value" "O" "Process0/Example/Decision" "ElseI" ConnectModules "Process0/Example/Decision" "O" "Process0/Example" "OUTBOUND#O000" SetLinkParam "Process0/Example/Branch" "I" "Bit Width" "16" diff --git a/visualapplets.py b/visualapplets.py index 0db6e12..7b07a9e 100644 --- a/visualapplets.py +++ b/visualapplets.py @@ -136,6 +136,8 @@ def __call__(self, *port_args): def __sub__(self, other): + assert isinstance(other, (Module, Port)) + src = self() dst = other() if isinstance(other, Module) else other @@ -180,6 +182,8 @@ def __setitem__(self, param_name, param_value): def __sub__(self, other): + assert isinstance(other, (Module, Port)) + src = self dst = other() if isinstance(other, Module) else other @@ -221,6 +225,15 @@ def __setitem__(self, param_name, param_value): return Param(self, param_name, param_value) + def __sub__(self, other): + + assert isinstance(other, (Module, Port)) + + src = self.dst.module() + dst = other() if isinstance(other, Module) else other + + return src - dst + class Param: