From 6c08cd67aaf42667115efba485adf61e7b27c3cf Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 25 Apr 2013 13:11:15 +0200 Subject: [PATCH] graycounter: expose binary output --- examples/basic/graycounter.py | 4 ++-- migen/genlib/cdc.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/basic/graycounter.py b/examples/basic/graycounter.py index bfc30f56..f623fbf7 100644 --- a/examples/basic/graycounter.py +++ b/examples/basic/graycounter.py @@ -11,8 +11,8 @@ class TB(Module): self.prng = Random(7345) def do_simulation(self, s): - print("{0:0{1}b} CE={2}".format(s.rd(self.gc.q), - self.width, s.rd(self.gc.ce))) + print("{0:0{1}b} CE={2} bin={3}".format(s.rd(self.gc.q), + self.width, s.rd(self.gc.ce), s.rd(self.gc.q_binary))) s.wr(self.gc.ce, self.prng.getrandbits(1)) sim = Simulator(TB()) diff --git a/migen/genlib/cdc.py b/migen/genlib/cdc.py index 13612cfe..9569e013 100644 --- a/migen/genlib/cdc.py +++ b/migen/genlib/cdc.py @@ -78,20 +78,20 @@ class GrayCounter(Module): self.ce = Signal() self.q = Signal(width) self.q_next = Signal(width) + self.q_binary = Signal(width) + self.q_next_binary = Signal(width) ### - q_binary = Signal(width) - q_next_binary = Signal(width) self.comb += [ If(self.ce, - q_next_binary.eq(q_binary + 1) + self.q_next_binary.eq(self.q_binary + 1) ).Else( - q_next_binary.eq(q_binary) + self.q_next_binary.eq(self.q_binary) ), - self.q_next.eq(q_next_binary ^ q_next_binary[1:]) + self.q_next.eq(self.q_next_binary ^ self.q_next_binary[1:]) ] self.sync += [ - q_binary.eq(q_next_binary), + self.q_binary.eq(self.q_next_binary), self.q.eq(self.q_next) ] -- 2.30.2