From 23f3dc0c7e175c5855f4a42b010d2c2a0182532f Mon Sep 17 00:00:00 2001 From: Marek Materzok Date: Wed, 18 Dec 2024 00:42:00 +0100 Subject: [PATCH] Documentation fixes --- docs/transactions.md | 6 +++--- transactron/core/method.py | 30 +++++++++++++++--------------- transactron/core/sugar.py | 14 +++++++++----- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/docs/transactions.md b/docs/transactions.md index 286f3c7..d42ae7f 100644 --- a/docs/transactions.md +++ b/docs/transactions.md @@ -140,7 +140,7 @@ Suppose we have the following layout, which is an input layout for a method call ```python layout = [("foo", 1), ("bar", 32)] -method = Method(input_layout=layout) +method = Method(i=layout) ``` The method can be called in multiple ways. @@ -170,7 +170,7 @@ Take the following definitions: ```python layout2 = [("foobar", layout), ("baz", 42)] -method2 = Method(input_layout=layout2) +method2 = Method(i=layout2) ``` One can then pass the arguments using `dict`s in following ways: @@ -208,7 +208,7 @@ The `dict` syntax can be used for returning values from methods. Take the following method declaration: ```python -method3 = Method(input_layout=layout, output_layout=layout2) +method3 = Method(i=layout, o=layout2) ``` One can then define this method as follows: diff --git a/transactron/core/method.py b/transactron/core/method.py index 10721d6..013702c 100644 --- a/transactron/core/method.py +++ b/transactron/core/method.py @@ -76,21 +76,6 @@ def __init__( The format of `data_in`. o: method layout The format of `data_out`. - nonexclusive: bool - If true, the method is non-exclusive: it can be called by multiple - transactions in the same clock cycle. If such a situation happens, - the method still is executed only once, and each of the callers - receive its output. Nonexclusive methods cannot have inputs. - combiner: (Module, Sequence[MethodStruct], Value) -> AssignArg - If `nonexclusive` is true, the combiner function combines the - arguments from multiple calls to this method into a single - argument, which is passed to the method body. The third argument - is a bit vector, whose n-th bit is 1 if the n-th call is active - in a given cycle. - single_caller: bool - If true, this method is intended to be called from a single - transaction. An error will be thrown if called from multiple - transactions. src_loc: int | SrcLoc How many stack frames deep the source location is taken from. Alternatively, the source location to use instead of the default. @@ -207,6 +192,21 @@ def body( It instantiates a combinational circuit for each method caller. By default, there is no function, so all arguments are accepted. + combiner: (Module, Sequence[MethodStruct], Value) -> AssignArg + If `nonexclusive` is true, the combiner function combines the + arguments from multiple calls to this method into a single + argument, which is passed to the method body. The third argument + is a bit vector, whose n-th bit is 1 if the n-th call is active + in a given cycle. + nonexclusive: bool + If true, the method is non-exclusive: it can be called by multiple + transactions in the same clock cycle. If such a situation happens, + the method still is executed only once, and each of the callers + receive its output. Nonexclusive methods cannot have inputs. + single_caller: bool + If true, this method is intended to be called from a single + transaction. An error will be thrown if called from multiple + transactions. Returns ------- diff --git a/transactron/core/sugar.py b/transactron/core/sugar.py index 6e663ed..22a4773 100644 --- a/transactron/core/sugar.py +++ b/transactron/core/sugar.py @@ -47,11 +47,15 @@ def def_method( default it is `Const(1)`, so the method is always ready. Assigned combinationally to the `ready` attribute. validate_arguments: Optional[Callable[..., ValueLike]] - Function that takes input arguments used to call the method - and checks whether the method can be called with those arguments. - It instantiates a combinational circuit for each - method caller. By default, there is no function, so all arguments - are accepted. + For details, see `Method.body`. + validate_arguments: Optional[Callable[..., ValueLike]] + For details, see `Method.body`. + combiner: (Module, Sequence[MethodStruct], Value) -> AssignArg + For details, see `Method.body`. + nonexclusive: bool + For details, see `Method.body`. + single_caller: bool + For details, see `Method.body`. Examples --------