projects
/
ieee754fpu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
810f032
)
add helper routine for creating latched registers
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Sat, 11 May 2019 04:16:06 +0000
(
05:16
+0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Sat, 11 May 2019 04:24:08 +0000
(
05:24
+0100)
src/nmutil/latch.py
patch
|
blob
|
history
diff --git
a/src/nmutil/latch.py
b/src/nmutil/latch.py
index d845a954331be955681adac188d7e4f05c9ba4b5..6cf5ab7ec93e5de0752cdfd2cf00f56c4edf7d8c 100644
(file)
--- a/
src/nmutil/latch.py
+++ b/
src/nmutil/latch.py
@@
-21,6
+21,15
@@
always @ (posedge c)
endmodule
"""
+def latchregister(m, incoming, outgoing, settrue):
+ reg = Signal.like(incoming) # make register same as input. reset is OK.
+ with m.If(settrue):
+ m.d.sync += reg.eq(incoming) # latch input into register
+ m.d.comb += outgoing.eq(incoming) # return input (combinatorial)
+ with m.Else():
+ m.d.comb += outgoing.eq(reg) # return input (combinatorial)
+
+
class SRLatch(Elaboratable):
def __init__(self, sync=True):
self.sync = sync