Created
July 29, 2023 06:02
-
-
Save ChuckM/4eb73a633ee9ea37dd1e4591d04cd0c2 to your computer and use it in GitHub Desktop.
A sketch of what I'm kind of trying to implement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# "generic" multi-phase clock module | |
# | |
from amaranth import * | |
class SysClock(Elaboratable): | |
""" | |
This builds a clock divider | |
Input is a clock, output is a multi-phase | |
clock. (instantiated with 4 phases) | |
+--+ +--+ +--+ +--+ +--+ | |
clk_in: | | | | | | | | | | | |
--+ +--+ +--+ +--+ +--+ +-- | |
+--+ +--+ | |
ph0: | | | | | |
--+ +--------------------+ +-- | |
+--+ | |
ph1: | | | |
--------+ +-------------------- | |
+--+ | |
ph2: | | | |
--------------+ +--------------- | |
+--+ | |
ph3: | | | |
--------------------+ +----------- | |
""" | |
def __init__(self, phases): | |
# one signal for each phase | |
self.clk = Signal(phases) | |
def elaborate(self, clk_in, ph_out): | |
""" | |
Bind the phase outputs to various signals | |
""" | |
m = Module() | |
if (len(ph_out) != len(self.clk)): | |
print("SysClock: Number of phases doesn't match") | |
return None | |
# wire up phases | |
for i in range(0, len(self.clk)): | |
m.d.comb += ph_out[i].eq(self.clk.eq(i)) | |
m.d.sync += self.clk.eq(self.clk + 1) | |
# What I would like to be able to do: | |
# | |
if (__name__ == "main"): | |
c = Clock(2) # 2 phase clock | |
p = ICEBreakerPlatfom() | |
ph[0] = p.request_resource("pmod1", 0) | |
ph[1] = p.request_resource("pmod1", 1) | |
m = c.elaborate(p.sysclk,ph) | |
... now my module generates a 2 phase clock on two pins | |
... connector. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment