Re: [myhdl-list] Wrap-around support in MyHDL
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2011-05-26 13:22:47
|
On 5/20/2011 10:25 AM, Jan Decaluwe wrote: > As you like the proposal after putting the feature > back on the map, and I hear no objections, I'd like > to make some progress. > > This is definitely a 0.8 feature, so I will open > a 0.8-dev branch for development. I will also turn > the proposal into a MEP. > If you like, when the 0.8-dev branch is created, I can take the existing tests that we created and move them over, as a starting point, for the modbv tests. Note: Ben did majority of the work for the previous tests :) Guess it would look something like the following (as a start). Should add additional tests for the expanded features and some tests for conversion. +++ b/myhdl/test/core/test_modbv.py class TestModbvWrap(TestCase): def testWrap(self): x = modbv(0, min=-8, max=8) x[:] = x + 1 self.assertEqual(1, x) x[:] = x + 2 self.assertEqual(3, x) x[:] = x + 5 self.assertEqual(-8, x) x[:] = x + 1 self.assertEqual(-7, x) x[:] = x - 5 self.assertEqual(4, x) x[:] = x - 4 self.assertEqual(0, x) x[:] += 15 x[:] = x - 1 self.assertEqual(-2, x) def testInit(self): self.assertRaises(ValueError, intbv, 15, min=-8, max=8) x = modbv(15, min=-8, max=8) self.assertEqual(-1, x) self.assertRaises(ValueError, intbv, 5, min=-3, max=8) modbv(5, min=-3, max=8) self.assertEqual(5, x) def testNoWrap(self): # verifies the base class does not wrap x = intbv(0, min=-8, max=8) try: x[:] += 15 self.fail() except ValueError: pass if __name__ == "__main__": unittest.main() Chris |