aboutsummaryrefslogtreecommitdiff
path: root/fpga/src/Clock.bs
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-10-08 14:27:19 -0500
committerNathan Ringo <nathan@remexre.com>2024-10-08 14:27:19 -0500
commit08d727e9886cde6a367906999e96a33f7ba37f33 (patch)
tree919da00f9d4bdc451be53f558c4b42bef7c487fd /fpga/src/Clock.bs
parented3e96b5eaae71d035e14569b107040c3538f849 (diff)
Reorganization and rewiring.
Diffstat (limited to 'fpga/src/Clock.bs')
-rw-r--r--fpga/src/Clock.bs19
1 files changed, 19 insertions, 0 deletions
diff --git a/fpga/src/Clock.bs b/fpga/src/Clock.bs
new file mode 100644
index 0000000..c908502
--- /dev/null
+++ b/fpga/src/Clock.bs
@@ -0,0 +1,19 @@
+-- | A simple clock package.
+package Clock where
+
+interface Clock =
+ clk :: Bool
+
+-- TODO: Make a multiclock that uses one count for all the sub-clocks in the
+-- design.
+
+mkClock :: Bit n -> Module Clock
+mkClock divisor =
+ module
+ count :: Reg (Bit n) <- mkReg 0
+ rules
+ when True ==> count := if count == divisor - 1 then 0 else count + 1
+ interface Clock
+ clk = count == 0
+
+-- vim: set ft=haskell :