Repository: amaranth-lang/amaranth
Pull request #1199 (2024-03-13 12:51:35)

sim: Do not direct user to deprecated `add_sync_process`.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/amaranth-lang/amaranth/pull/1199?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=amaranth-lang) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 89.39%. Comparing base [(`cb96b15`)](https://app.codecov.io/gh/amaranth-lang/amaranth/commit/cb96b15b8cbdee56651f783977c478786ec331f4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=amaranth-lang) to head [(`cde9cfa`)](https://app.codecov.io/gh/amaranth-lang/amaranth/pull/1199?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=amaranth-lang).


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main    #1199      +/-   ##
==========================================
- Coverage   89.44%   89.39%   -0.05%     
==========================================
  Files          43       43              
  Lines        9066     9066              
  Branches     2150     2150              
==========================================
- Hits         8109     8105       -4     
- Misses        780      784       +4     
  Partials      177      177              
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/amaranth-lang/amaranth/pull/1199?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=amaranth-lang).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=amaranth-lang).


Patch:
diff --git a/amaranth/lib/memory.py b/amaranth/lib/memory.py
index 7d1175c..802671e 100644
--- a/amaranth/lib/memory.py
+++ b/amaranth/lib/memory.py
@@ -408,6 +408,10 @@ class Memory(wiring.Component):
     def init(self):
         return self._init
 
+    @init.setter
+    def init(self, init):
+        self._init = Memory.Init(init, shape=self._shape, depth=self._depth)
+
     @property
     def attrs(self):
         return self._attrs
diff --git a/amaranth/sim/_pycoro.py b/amaranth/sim/_pycoro.py
index 6baffac..085eb00 100644
--- a/amaranth/sim/_pycoro.py
+++ b/amaranth/sim/_pycoro.py
@@ -143,8 +143,7 @@ class PyCoroProcess(BaseProcess):
 
                 elif command is None: # only possible if self.default_cmd is None
                     raise TypeError("Received default command from process {!r} that was added "
-                                    "with add_process(); did you mean to add this process with "
-                                    "add_sync_process() instead?"
+                                    "with add_process(); did you mean to use Tick() instead?"
                                     .format(self.src_loc()))
 
                 else:


Test patch:
diff --git a/tests/test_lib_memory.py b/tests/test_lib_memory.py
index eb7512b..222b98b 100644
--- a/tests/test_lib_memory.py
+++ b/tests/test_lib_memory.py
@@ -311,6 +311,8 @@ class MemoryTestCase(FHDLTestCase):
         self.assertEqual(m.init._raw, [0, 2, 0, 0])
         m.init[2:] = [4, 5]
         self.assertEqual(list(m.init), [0, 2, 4, 5])
+        m.init = [6, 7]
+        self.assertEqual(list(m.init), [6, 7, 0, 0])
 
     def test_init_set_shapecastable(self):
         m = Memory(shape=MyStruct, depth=4, init=[])