+######################################################################
+# Test 0
+######################################################################
+
+class ExampleMaskRecord(RecordObject):
+ """ an example of a class used to store 2 operands.
+ requires an eq function, to conform with the pipeline stage API
+ """
+
+ def __init__(self):
+ RecordObject.__init__(self)
+ self.src1 = Signal(16)
+ self.src2 = Signal(16)
+
+ def __eq(self, i):
+ return [self.src1.eq(i.src1), self.src2.eq(i.src2)]
+
+
+class TestInputMask:
+ """ the eq function, called by set_input, needs an incoming object
+ that conforms to the Example2OpClass.eq function requirements
+ easiest way to do that is to create a class that has the exact
+ same member layout (self.op1, self.op2) as Example2OpClass
+ """
+ def __init__(self, src1, src2):
+ self.src1 = src1
+ self.src2 = src2
+
+ def __repr__(self):
+ return "<TestInputMask %x %x" % (self.src1, self.src2)
+
+class ExampleMaskCancellable(StageCls):
+
+ def ispec(self):
+ """ returns an instance of an ExampleMaskRecord.
+ """
+ return ExampleMaskRecord()
+
+ def ospec(self):
+ """ returns the same
+ """
+ return ExampleMaskRecord()
+
+ def process(self, i):
+ """ process the input data: increase op1 and op2
+ """
+ return TestInputMask(i.src1 + 1, i.src2 + 1)
+
+
+class MaskCancellablePipe(MaskCancellable):
+
+ """ connects two stages together as a *single* combinatorial stage.
+ """
+ def __init__(self):
+ self.cancelmask = Signal(16)
+ stage1 = ExampleMaskCancellable()
+ stage2 = ExampleMaskCancellable()
+ combined = StageChain([stage1, stage2])
+ MaskCancellable.__init__(self, combined, 16)
+
+
+def data_chain0():
+ data = []
+ for i in range(num_tests):
+ data.append(TestInputMask(randint(0, 1<<16-1),
+ randint(0, 1<<16-1)))
+ return data
+
+
+def resultfn_0(data_o, expected, i, o):
+ assert data_o['src1'] == expected.src1 + 2, \
+ "src1 %x-%x received data no match\n" \
+ % (data_o['src1'], expected.src1 + 2)
+ assert data_o['src2'] == expected.src2 + 2, \
+ "src2 %x-%x received data no match\n" \
+ % (data_o['src2'] , expected.src2 + 2)
+
+