Skip to content

Commit 6bb037e

Browse files
platform.ice40: add support for getting an async-safe ripple counter stage
1 parent 808c211 commit 6bb037e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

software/glasgow/platform/ice40.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,34 @@ def f_out_diff(variant):
116116
i_RESETB=~ResetSignal(pll.idomain),
117117
i_BYPASS=Const(0),
118118
)
119+
120+
def get_ripple_ff_stage(self, d_out, clk, clk_en=None, rst=None):
121+
"""
122+
a single stage of a ripple counter
123+
124+
d_out should be used as the clock for the following stage, and as the data output
125+
"""
126+
if clk_en is None:
127+
clk_en = Const(1)
128+
if rst is None:
129+
rst = Const(0)
130+
131+
m = Module()
132+
d_in = Signal()
133+
134+
m.submodules += [
135+
Instance("SB_LUT4",
136+
p_LUT_INIT=Const(0x00FF, 16),
137+
i_I0=0, i_I1=0, i_I2=0, i_I3=d_out,
138+
o_O=d_in
139+
),
140+
Instance("SB_DFFNER",
141+
i_D=d_in,
142+
o_Q=d_out,
143+
i_C=clk,
144+
i_E=clk_en,
145+
i_R=rst,
146+
),
147+
]
148+
149+
return m

0 commit comments

Comments
 (0)