Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add def_one_caller_wrapper #536

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lekcyjna123
Copy link
Contributor

This PR ports from #395 a def_one_caller_wrapper. Function which is a syntax sugar for introducing a Fifo which collect all incoming data and pass them to the one_caller method.

Examples of usage:

write_wrapper = def_one_caller_wrapper(vrf.write, self.write_vrf)

sender_wrappers = [def_one_caller_wrapper(_internal_send[i], self.send[i]) for i in range(self.inputs_count)]

@tilk
Copy link
Member

tilk commented Dec 15, 2023

Do we need this anywhere now? Isn't a function returning a module something weird?

@lekcyjna123
Copy link
Contributor Author

I have the plan to port switching networks from #395 and it is needed there.

@@ -250,3 +251,37 @@ def elaborate(self, platform):
m.submodules[f"ManyToOneConnectTrans_input_{i}"] = ConnectTrans(self.m_put_result, self.get_results[i])

return m


def def_one_caller_wrapper(method_to_wrap: Method, wrapper: Method) -> TModule:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this an Elaboratable (or, alternatively, why does this not have a module argument)? It's kinda weird in Amaranth to return a module from a function.

raise ValueError("def_one_caller_wrapper support only wrapping of methods which don't return data.")

m = TModule()
buffer = FIFO(method_to_wrap.data_in.layout, 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the connector should be parametrized?

Copy link
Member

@tilk tilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test.

@@ -8,6 +8,7 @@
"Connect",
"ConnectTrans",
"ManyToOneConnectTrans",
"def_one_caller_wrapper",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename one to single, to be consistent with Transactron core.

@tilk tilk added the enhancement New feature or request label Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants