Skip to content

Commit

Permalink
Update doc strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekcyjna committed Oct 24, 2023
1 parent 8e79cc7 commit 4e39bfc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions test/transactions/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def process():


class DataDependentConditionalCircuit(Elaboratable):
def __init__(self, n=2, ready_function = lambda arg: arg.data != 3):
def __init__(self, n=2, ready_function=lambda arg: arg.data != 3):
self.method = Method(i=data_layout(n))
self.ready_function = ready_function

Expand Down Expand Up @@ -573,7 +573,7 @@ def setUp(self):

def base_random(self, f):
random.seed(14)
self.circ = DataDependentConditionalCircuit(n = self.n, ready_function = f)
self.circ = DataDependentConditionalCircuit(n=self.n, ready_function=f)

def process():
for _ in range(self.test_number):
Expand Down
16 changes: 13 additions & 3 deletions transactron/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def rec(transaction: Transaction, source: TransactionBase):
raise RuntimeError(f"Method '{method.name}' can't be called twice from the same transaction")
self.methods_by_transaction[transaction].append(method)
self.transactions_by_method[method].append(transaction)
self.readiness_by_method_and_transaction[(transaction,method)] = method._ready_function(arg_rec)
self.readiness_by_method_and_transaction[(transaction, method)] = method._ready_function(arg_rec)
rec(transaction, method)

for transaction in transactions:
Expand Down Expand Up @@ -130,7 +130,7 @@ def eager_deterministic_cc_scheduler(
ccl.sort(key=lambda transaction: porder[transaction])
for k, transaction in enumerate(ccl):
ready = [
method_map.readiness_by_method_and_transaction[(transaction,method)]
method_map.readiness_by_method_and_transaction[(transaction, method)]
for method in method_map.methods_by_transaction[transaction]
]
runnable = Cat(ready).all()
Expand Down Expand Up @@ -169,7 +169,7 @@ def trivial_roundrobin_cc_scheduler(
m.submodules.scheduler = sched
for k, transaction in enumerate(cc):
ready = [
method_map.readiness_by_method_and_transaction[(transaction,method)]
method_map.readiness_by_method_and_transaction[(transaction, method)]
for method in method_map.methods_by_transaction[transaction]
]
runnable = Cat(ready).all()
Expand Down Expand Up @@ -1058,6 +1058,11 @@ def body(
Data generated by the `Method`, which will be passed to
the caller (a `Transaction` or another `Method`). Assigned
combinationally to the `data_out` attribute.
ready_function: Optional[Callable[[Record], ValueLike]]
Function to instantiate a combinational circuit for each
method caller. It should take input arguments and return
if the method can be called with those arguments. By default
there is no function, so all arguments are accepted.
Returns
-------
Expand Down Expand Up @@ -1193,6 +1198,11 @@ def def_method(
Signal to indicate if the method is ready to be run. By
default it is `Const(1)`, so the method is always ready.
Assigned combinationally to the `ready` attribute.
ready_function: Optional[Callable[[Record], ValueLike]]
Function to instantiate a combinational circuit for each
method caller. It should take input arguments and return
if the method can be called with those arguments. By default
there is no function, so all arguments are accepted.
Examples
--------
Expand Down

0 comments on commit 4e39bfc

Please sign in to comment.