You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Changed: :meth:`Simulator.add_clock <amaranth.sim.Simulator.add_clock>` now accepts a :class:`Period <amaranth.hdl.Period>` for :py:`period` and :py:`phase`. (`RFC 66`_)
70
+
* Changed: :meth:`Simulator.run_until <amaranth.sim.Simulator.run_until>` now accepts a :class:`Period <amaranth.hdl.Period>` for :py:`deadline`. (`RFC 66`_)
71
+
* Changed: :meth:`SimulatorContext.delay <amaranth.sim._async.SimulatorContext.delay>` now accepts a :class:`Period <amaranth.hdl.Period>` for :py:`interval`. (`RFC 66`_)
72
+
* Changed: :meth:`ResourceManager.add_clock_constraint <amaranth.build.res.ResourceManager.add_clock_constraint>` now accepts a :class:`Period <amaranth.hdl.Period>` for :py:`period`. (`RFC 66`_)
73
+
* Changed: :class:`Clock <amaranth.build.dsl.Clock>` now accepts a :class:`Period <amaranth.hdl.Period>` for :py:`period`. (`RFC 66`_)
74
+
* Changed: :attr:`Clock.period <amaranth.build.dsl.Clock.period>` now returns a :class:`Period <amaranth.hdl.Period>`. (`RFC 66`_)
75
+
* Deprecated: Passing a :class:`float` of seconds or hertz to any of the methods/arguments now accepting a :class:`Period <amaranth.hdl.Period>`. (`RFC 66`_)
76
+
* Deprecated: Passing :py:`frequency=` to :meth:`ResourceManager.add_clock_constraint <amaranth.build.res.ResourceManager.add_clock_constraint>`. (`RFC 66`_)
77
+
* Deprecated: Passing :py:`frequency=` to :class:`Clock <amaranth.build.dsl.Clock>`. (`RFC 66`_)
Copy file name to clipboardExpand all lines: docs/amaranth/latest/_sources/simulator.rst.txt
+12-12
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ Simulating a design always requires the three basic steps: constructing the :abb
48
48
49
49
.. testcode::
50
50
51
-
from amaranth.sim import Simulator
51
+
from amaranth.sim import Simulator, Period
52
52
53
53
dut = Counter()
54
54
sim = Simulator(dut)
@@ -69,9 +69,9 @@ The following code simulates a design and capture the values of all the signals
69
69
70
70
dut = Counter()
71
71
sim = Simulator(dut)
72
-
sim.add_clock(1e-6) # 1 µs period, or 1 MHz
72
+
sim.add_clock(Period(MHz=1)) # 1 µs period, or 1 MHz
73
73
with sim.write_vcd("example1.vcd"):
74
-
sim.run_until(1e-6 * 15) # 15 periods of the clock
74
+
sim.run_until(Period(MHz=1) * 15) # 15 periods of the clock
75
75
76
76
The captured data is saved to a :abbr:`VCD` file :file:`example1.vcd`, which can be displayed with a *waveform viewer* such as Surfer_ or GTKWave_:
77
77
@@ -122,10 +122,10 @@ The following example simulates a counter and verifies that it can be stopped us
122
122
ctx.set(dut.en, True) # assert `dut.en`, enabling the counter again
123
123
124
124
sim = Simulator(dut)
125
-
sim.add_clock(1e-6)
125
+
sim.add_clock(Period(MHz=1))
126
126
sim.add_testbench(testbench_example2) # add the testbench; run_until() calls the function
127
127
with sim.write_vcd("example2.vcd"):
128
-
sim.run_until(1e-6 * 15)
128
+
sim.run_until(Period(MHz=1) * 15)
129
129
130
130
Since this circuit is synchronous, and the :meth:`ctx.tick() <SimulatorContext.tick>` method waits until after the circuit has reacted to the clock edge, the change to the :py:`en` input affects the behavior of the circuit on the next clock cycle after the change:
131
131
@@ -155,17 +155,17 @@ The following example simulates an adder:
155
155
dut = Adder()
156
156
157
157
async def testbench_example3(ctx):
158
-
await ctx.delay(1e-6)
158
+
await ctx.delay(Period(us=1))
159
159
ctx.set(dut.a, 2)
160
160
ctx.set(dut.b, 2)
161
161
assert ctx.get(dut.o) == 4
162
162
163
-
await ctx.delay(1e-6)
163
+
await ctx.delay(Period(us=1))
164
164
ctx.set(dut.a, 1717)
165
165
ctx.set(dut.b, 420)
166
166
assert ctx.get(dut.o) == 2137
167
167
168
-
await ctx.delay(2e-6)
168
+
await ctx.delay(Period(us=2))
169
169
170
170
sim = Simulator(dut)
171
171
sim.add_testbench(testbench_example3)
@@ -234,7 +234,7 @@ The following code replaces the :py:`Counter` elaboratable with the equivalent P
234
234
ctx.set(en, True)
235
235
236
236
sim = Simulator(m)
237
-
sim.add_clock(1e-6)
237
+
sim.add_clock(Period(MHz=1))
238
238
sim.add_process(process_example4)
239
239
sim.add_testbench(testbench_example4)
240
240
with sim.write_vcd("example4.vcd", traces=(cd_sync.clk, cd_sync.rst, en, count)):
@@ -262,17 +262,17 @@ The following code replaces the :py:`Adder` elaboratable with the equivalent Pyt
0 commit comments