Skip to content

Commit ad7c888

Browse files
Deploying to main from @ amaranth-lang/amaranth@c609025 🚀
1 parent ec2dd90 commit ad7c888

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+274
-203
lines changed

docs/amaranth/latest/_code/led_blinker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def elaborate(self, platform):
77

88
led = platform.request("led")
99

10-
half_freq = int(platform.default_clk_frequency // 2)
10+
half_freq = int(platform.default_clk_period.hertz // 2)
1111
timer = Signal(range(half_freq + 1))
1212

1313
with m.If(timer == half_freq):

docs/amaranth/latest/_code/up_counter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def elaborate(self, platform):
4343

4444
return m
4545
# --- TEST ---
46-
from amaranth.sim import Simulator
46+
from amaranth.sim import Simulator, Period
4747

4848

4949
dut = UpCounter(25)
@@ -68,7 +68,7 @@ async def bench(ctx):
6868

6969

7070
sim = Simulator(dut)
71-
sim.add_clock(1e-6) # 1 MHz
71+
sim.add_clock(Period(MHz=1))
7272
sim.add_testbench(bench)
7373
with sim.write_vcd("up_counter.vcd"):
7474
sim.run()

docs/amaranth/latest/_downloads/9916e1f0618daa91d3860f1bdac16820/up_counter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def elaborate(self, platform):
4343

4444
return m
4545
# --- TEST ---
46-
from amaranth.sim import Simulator
46+
from amaranth.sim import Simulator, Period
4747

4848

4949
dut = UpCounter(25)
@@ -68,7 +68,7 @@ async def bench(ctx):
6868

6969

7070
sim = Simulator(dut)
71-
sim.add_clock(1e-6) # 1 MHz
71+
sim.add_clock(Period(MHz=1))
7272
sim.add_testbench(bench)
7373
with sim.write_vcd("up_counter.vcd"):
7474
sim.run()

docs/amaranth/latest/_sources/changes.rst.txt

+21
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ Version 0.6.0 (unreleased)
2626
Implemented RFCs
2727
----------------
2828

29+
.. _RFC 66: https://amaranth-lang.org/rfcs/0066-simulation-time.html
2930
.. _RFC 71: https://amaranth-lang.org/rfcs/0071-enumview-matches.html
3031

32+
* `RFC 66`_: Simulation time
3133
* `RFC 71`_: ``EnumView.matches``
3234

3335

@@ -36,6 +38,7 @@ Language changes
3638

3739
.. currentmodule:: amaranth.hdl
3840

41+
* Added: :class:`Period` for representing time periods. (`RFC 66`_)
3942
* Changed: overriding :meth:`ValueCastable.from_bits` is now mandatory. (`RFC 51`_)
4043
* Deprecated: the :py:`local=` argument to :class:`ClockDomain`. (`RFC 59`_)
4144
* Removed: (deprecated in 0.4.0) :class:`Record`.
@@ -58,6 +61,24 @@ Standard library changes
5861
* Removed: (deprecated in 0.5.0) :mod:`amaranth.lib.coding`. (`RFC 63`_)
5962

6063

64+
Toolchain changes
65+
-----------------
66+
67+
* Added: :meth:`SimulatorContext.elapsed_time <amaranth.sim._async.SimulatorContext.elapsed_time>` for getting elapsed simulation time. (`RFC 66`_)
68+
* Added: :meth:`Platform.default_clk_period <amaranth.build.plat.Platform.default_clk_period>`. (`RFC 66`_)
69+
* 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`_)
78+
* Deprecated: :attr:`Clock.frequency <amaranth.build.dsl.Clock.frequency>`. (`RFC 66`_)
79+
* Deprecated: :meth:`Platform.default_clk_frequency <amaranth.build.plat.Platform.default_clk_frequency>`. (`RFC 66`_)
80+
81+
6182
Platform integration changes
6283
----------------------------
6384

docs/amaranth/latest/_sources/simulator.rst.txt

+12-12
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Simulating a design always requires the three basic steps: constructing the :abb
4848

4949
.. testcode::
5050

51-
from amaranth.sim import Simulator
51+
from amaranth.sim import Simulator, Period
5252

5353
dut = Counter()
5454
sim = Simulator(dut)
@@ -69,9 +69,9 @@ The following code simulates a design and capture the values of all the signals
6969

7070
dut = Counter()
7171
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
7373
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
7575

7676
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_:
7777

@@ -122,10 +122,10 @@ The following example simulates a counter and verifies that it can be stopped us
122122
ctx.set(dut.en, True) # assert `dut.en`, enabling the counter again
123123

124124
sim = Simulator(dut)
125-
sim.add_clock(1e-6)
125+
sim.add_clock(Period(MHz=1))
126126
sim.add_testbench(testbench_example2) # add the testbench; run_until() calls the function
127127
with sim.write_vcd("example2.vcd"):
128-
sim.run_until(1e-6 * 15)
128+
sim.run_until(Period(MHz=1) * 15)
129129

130130
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:
131131

@@ -155,17 +155,17 @@ The following example simulates an adder:
155155
dut = Adder()
156156

157157
async def testbench_example3(ctx):
158-
await ctx.delay(1e-6)
158+
await ctx.delay(Period(us=1))
159159
ctx.set(dut.a, 2)
160160
ctx.set(dut.b, 2)
161161
assert ctx.get(dut.o) == 4
162162

163-
await ctx.delay(1e-6)
163+
await ctx.delay(Period(us=1))
164164
ctx.set(dut.a, 1717)
165165
ctx.set(dut.b, 420)
166166
assert ctx.get(dut.o) == 2137
167167

168-
await ctx.delay(2e-6)
168+
await ctx.delay(Period(us=2))
169169

170170
sim = Simulator(dut)
171171
sim.add_testbench(testbench_example3)
@@ -234,7 +234,7 @@ The following code replaces the :py:`Counter` elaboratable with the equivalent P
234234
ctx.set(en, True)
235235

236236
sim = Simulator(m)
237-
sim.add_clock(1e-6)
237+
sim.add_clock(Period(MHz=1))
238238
sim.add_process(process_example4)
239239
sim.add_testbench(testbench_example4)
240240
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
262262
ctx.set(o, a_value + b_value)
263263

264264
async def testbench_example5(ctx):
265-
await ctx.delay(1e-6)
265+
await ctx.delay(Period(us=1))
266266
ctx.set(a, 2)
267267
ctx.set(b, 2)
268268
assert ctx.get(o) == 4
269269

270-
await ctx.delay(1e-6)
270+
await ctx.delay(Period(us=1))
271271
ctx.set(a, 1717)
272272
ctx.set(b, 420)
273273
assert ctx.get(o) == 2137
274274

275-
await ctx.delay(2e-6)
275+
await ctx.delay(Period(us=2))
276276

277277
sim = Simulator(m)
278278
sim.add_process(process_example5)

docs/amaranth/latest/_sources/stdlib/io.rst.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ All of the following examples assume that one of the built-in FPGA platforms is
6060

6161
.. testcode::
6262

63-
from amaranth.sim import Simulator
63+
from amaranth.sim import Simulator, Period
6464
from amaranth.lib import io, wiring, stream
6565
from amaranth.lib.wiring import In, Out
6666

@@ -249,7 +249,7 @@ For example, consider a simple serializer that accepts a stream of multi-bit dat
249249
assert dout_value == bit, "DUT drives the wrong value on data output"
250250

251251
sim = Simulator(dut)
252-
sim.add_clock(1e-6)
252+
sim.add_clock(Period(MHz=1))
253253
sim.add_testbench(testbench_write_data)
254254
sim.add_testbench(testbench_sample_output)
255255
sim.run()

docs/amaranth/latest/_sources/stdlib/stream.rst.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The pipeline is tested using the :doc:`built-in simulator </simulator>` and the
5959

6060
.. testcode::
6161

62-
from amaranth.sim import Simulator
62+
from amaranth.sim import Simulator, Period
6363

6464
async def stream_get(ctx, stream):
6565
ctx.set(stream.ready, 1)
@@ -150,7 +150,7 @@ In this example, the external device does not provide a way to pause data transm
150150
f"{payload & 0xff:08b} != {expected_word & 0xff:08b} (expected)"
151151

152152
sim = Simulator(dut)
153-
sim.add_clock(1e-6)
153+
sim.add_clock(Period(MHz=1))
154154
sim.add_testbench(testbench_input)
155155
sim.add_testbench(testbench_output)
156156
with sim.write_vcd("stream_serial_receiver.vcd"):
@@ -244,7 +244,7 @@ The serial transmitter accepts a stream of words and provides it to the serial i
244244
await ctx.tick()
245245

246246
sim = Simulator(dut)
247-
sim.add_clock(1e-6)
247+
sim.add_clock(Period(MHz=1))
248248
sim.add_testbench(testbench_input)
249249
sim.add_testbench(testbench_output)
250250
with sim.write_vcd("stream_serial_transmitter.vcd"):
@@ -293,7 +293,7 @@ The value negator accepts a stream of words, negates the 2's complement value of
293293
assert await stream_get(ctx, dut.o_stream) == -17
294294

295295
sim = Simulator(dut)
296-
sim.add_clock(1e-6)
296+
sim.add_clock(Period(MHz=1))
297297
sim.add_testbench(testbench_input)
298298
sim.add_testbench(testbench_output)
299299
with sim.write_vcd("stream_value_negator.vcd"):
@@ -388,7 +388,7 @@ The complete pipeline consists of a serial receiver, a value negator, a FIFO que
388388
ctx.set(dut.o_ssel, 0)
389389

390390
sim = Simulator(dut)
391-
sim.add_clock(1e-6)
391+
sim.add_clock(Period(MHz=1))
392392
sim.add_testbench(testbench_input)
393393
sim.add_testbench(testbench_output)
394394
with sim.write_vcd("stream_example_pipeline.vcd"):

docs/amaranth/latest/_static/documentation_options.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var DOCUMENTATION_OPTIONS = {
22
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
3-
VERSION: '0.6.0.dev57',
3+
VERSION: '0.6.0.dev64',
44
LANGUAGE: 'en',
55
COLLAPSE_INDEX: false,
66
BUILDER: 'html',

0 commit comments

Comments
 (0)