File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 5
5
import textwrap
6
6
import re
7
7
import jinja2
8
+ import warnings
8
9
9
10
from .. import __version__
10
11
from .._toolchain import *
@@ -45,11 +46,25 @@ def default_clk_constraint(self):
45
46
46
47
@property
47
48
def default_clk_frequency (self ):
49
+ # TODO(amaranth-0.7): remove
50
+ warnings .warn (
51
+ f"Per RFC 66, `default_clk_frequency` is deprecated. Use `default_clk_period` instead."
52
+ f" instead." ,
53
+ DeprecationWarning , stacklevel = 1 )
54
+
55
+ constraint = self .default_clk_constraint
56
+ if constraint is None :
57
+ raise AttributeError ("Platform '{}' does not constrain its default clock"
58
+ .format (type (self ).__qualname__ ))
59
+ return constraint .period .hertz
60
+
61
+ @property
62
+ def default_clk_period (self ):
48
63
constraint = self .default_clk_constraint
49
64
if constraint is None :
50
65
raise AttributeError ("Platform '{}' does not constrain its default clock"
51
66
.format (type (self ).__qualname__ ))
52
- return constraint .frequency
67
+ return constraint .period
53
68
54
69
def add_file (self , filename , content ):
55
70
if not isinstance (filename , str ):
Original file line number Diff line number Diff line change @@ -382,21 +382,21 @@ def create_missing_domain(self, name):
382
382
i_CLKHFPU = 1 ,
383
383
p_CLKHF_DIV = f"0b{ self .hfosc_div :02b} " ,
384
384
o_CLKHF = clk_i )
385
- delay = int ( 100e-6 * self .default_clk_frequency )
385
+ delay = Period ( us = 100 ) // self .default_clk_period
386
386
# Internal low-speed clock: 10 KHz.
387
387
elif self .default_clk == "SB_LFOSC" :
388
388
clk_i = Signal ()
389
389
m .submodules += Instance ("SB_LFOSC" ,
390
390
i_CLKLFEN = 1 ,
391
391
i_CLKLFPU = 1 ,
392
392
o_CLKLF = clk_i )
393
- delay = int ( 100e-6 * self .default_clk_frequency )
393
+ delay = Period ( us = 100 ) // self .default_clk_period
394
394
# User-defined clock signal.
395
395
else :
396
396
clk_io = self .request (self .default_clk , dir = "-" )
397
397
m .submodules .clk_buf = clk_buf = io .Buffer ("i" , clk_io )
398
398
clk_i = clk_buf .i
399
- delay = int ( 15e-6 * self .default_clk_frequency )
399
+ delay = Period ( us = 15 ) // self .default_clk_period
400
400
401
401
if self .default_rst is not None :
402
402
rst_io = self .request (self .default_rst , dir = "-" )
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def elaborate(self, platform):
7
7
8
8
led = platform .request ("led" )
9
9
10
- half_freq = int (platform .default_clk_frequency // 2 )
10
+ half_freq = int (platform .default_clk_period . hertz // 2 )
11
11
timer = Signal (range (half_freq + 1 ))
12
12
13
13
with m .If (timer == half_freq ):
You can’t perform that action at this time.
0 commit comments