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

Update to Amaranth 0.5 #278

Merged
merged 6 commits into from
Jan 30, 2025
Merged

Update to Amaranth 0.5 #278

merged 6 commits into from
Jan 30, 2025

Conversation

miek
Copy link
Member

@miek miek commented Sep 17, 2024

Work-in-progress on updating to Amaranth 0.5:

  • Replace uses of amaranth.hdl.Memory with amaranth.lib.memory.Memory
  • Remove uses of Signal.width
  • Replace uses of reset= with init=
  • Remove uses of Pin
  • Update tests to remove uses of add_sync_process
  • ...

@antoinevg antoinevg mentioned this pull request Oct 17, 2024
@miek miek force-pushed the amaranth-0.5 branch 3 times, most recently from 20f58e7 to 0ac7d28 Compare January 3, 2025 12:57
@miek
Copy link
Member Author

miek commented Jan 3, 2025

I think this is ready for review now.

I decided to drop the synchronize helper in favour of less magic and because it was tied pretty closely to Pin/Record which are going away. Most of its uses were from unmaintained examples that depended on old hardware, that I've also removed.

I also decided to skip porting away from add_sync_process for now as refactoring all the tests is going to be a big job, and I'd rather leave that to a follow-up PR, so the test runs will have a deprecation warning relating to that.

Otherwise it's all fairly simple changes from the list here: https://amaranth-lang.org/docs/amaranth/latest/changes.html#migrating-from-version-0-4

@miek miek marked this pull request as ready for review January 3, 2025 14:54
@@ -77,7 +78,7 @@ def __init__(self, *, signals, sample_depth, domain="sync", sample_rate=60e6, sa
#
# Create a backing store for our samples.
#
self.mem = Memory(width=self.sample_width, depth=sample_depth, name="ila_buffer")
self.mem = Memory(shape=Shape(self.sample_width), depth=sample_depth, init=[])
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not necessary to explicitly construct a Shape here, any shape-like can be used, and since that includes integers, you can simply just pass shape=self.sample_width. shape is effectively a superset of the old width argument.

This goes for the other Memory instances in this commit as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks!

@antoinevg
Copy link
Member

We're also going to need a smol change to luna/gateware/usb/request/windows/ms_descriptor.py:

diff --git a/luna/gateware/usb/request/windows/ms_descriptor.py b/luna/gateware/usb/request/windows/ms_descriptor.py
index b89f188..a6b5493 100644
--- a/luna/gateware/usb/request/windows/ms_descriptor.py
+++ b/luna/gateware/usb/request/windows/ms_descriptor.py
@@ -184,7 +184,7 @@ class GetMicrosoftDescriptorHandlerBlock(Elaboratable):
         rom_content, descriptor_max_length, max_index, min_index = self.generate_rom_content()

         m.submodules.rom = rom = Memory(shape=32, depth=len(rom_content), init=rom_content)
-        rom_read_port = rom.read_port(transparent=False)
+        rom_read_port = rom.read_port()

         # Create convenience aliases to the upper and lower half of the ROM.
         rom_upper_half = rom_read_port.data.word_select(1, 16)

Amaranth 0.5 read ports are now not transparent by default, with transparency being set with the transparent_for parameter containing zero or more WritePorts:

read_port(*, domain='sync', transparent_for=(), src_loc_at=0)

@miek
Copy link
Member Author

miek commented Jan 28, 2025

Good catch, thanks! I've fixed that and also updated a use of Memory I'd missed in the superspeed code.

@mossmann mossmann requested a review from antoinevg January 29, 2025 17:27
Copy link
Member

@antoinevg antoinevg left a comment

Choose a reason for hiding this comment

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

Looking great, ready to merge!

@miek miek merged commit 3ad4155 into greatscottgadgets:main Jan 30, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants