Skip to content

Commit

Permalink
Allow cascading links, e.g. x - y - z
Browse files Browse the repository at this point in the history
  • Loading branch information
jurihock committed Jan 6, 2022
1 parent 992efe3 commit f6f2153
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
10 changes: 4 additions & 6 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__':
Expand Down
2 changes: 1 addition & 1 deletion example.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions visualapplets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:

Expand Down

0 comments on commit f6f2153

Please sign in to comment.