fix masks on EdgeDetector

This commit is contained in:
Florent Kermarrec 2012-08-12 19:39:26 +02:00
parent 68c451148a
commit 09bcfb0fa5
2 changed files with 14 additions and 11 deletions

View File

@ -66,25 +66,25 @@ class EdgeDetector:
# Rising Edge
if "R" in self.mode:
if self.pipe:
sync += [self.ro.eq(self.i & (~self.i_d))]
sync += [self.ro.eq(self.r_mask & self.i & (~self.i_d))]
else:
comb += [self.ro.eq(self.i & (~ self.i_d))]
comb += [self.ro.eq(self.r_mask & self.i & (~ self.i_d))]
else:
comb += [self.ro.eq(0)]
# Falling Edge
if "F" in self.mode:
if self.pipe:
sync += [self.fo.eq((~ self.i) & self.i_d)]
sync += [self.fo.eq(self.f_mask & (~ self.i) & self.i_d)]
else:
comb += [self.fo.eq((~ self.i) & self.i_d)]
comb += [self.fo.eq(self.f_mask & (~ self.i) & self.i_d)]
else:
comb += [self.fo.eq(0)]
# Both
if "B" in self.mode:
if self.pipe:
sync += [self.bo.eq(self.i != self.i_d)]
sync += [self.bo.eq(self.b_mask & self.i != self.i_d)]
else:
comb += [self.bo.eq(self.i != self.i_d)]
comb += [self.bo.eq(self.b_mask & self.i != self.i_d)]
else:
comb += [self.bo.eq(0)]
#Output
@ -256,7 +256,7 @@ class Trigger:
comb+= [self.dat.eq(self.in_dat)]
return frag + _sum.get_fragment() + Fragment(comb=comb, sync=sync)
return frag + Fragment(comb=comb, sync=sync)
class Storage:

11
top.py
View File

@ -8,7 +8,7 @@ from migen.bus import csr
import migScope
#
#Test RangeDetector
#Test Term
#
#term = migScope.Term(32,True)
#v = verilog.convert(term.get_fragment())
@ -70,12 +70,15 @@ import migScope
#v = verilog.convert(recorder.get_fragment())
#print(v)
#
#Test Trigger
#
term0 = migScope.Term(32)
term1 = migScope.Term(32)
term2 = migScope.Term(32)
term1 = migScope.RangeDetector(32)
term2 = migScope.EdgeDetector(32)
term3 = migScope.Term(32)
trigger0 = migScope.Trigger(0,32,64,[term0, term1, term2, term3])
v = verilog.convert(trigger0.get_fragment())
print(v)