Thread: [myhdl-list] Generating 160 bit signal
Brought to you by:
jandecaluwe
From: Edward V. <dev...@sb...> - 2015-03-07 22:12:14
|
Hello All, Trying to take 16 values from an image to generate 160 bit signal lft_s_i.next = ((r[row+31][col] << W0*15) | (r[row+29][col] << W0*14) | (r[row+27][col] << W0*13) | (r[row+25][col] << W0*12) | (r[row+23][col] << W0*11) | (r[row+21][col] << W0*10) | (r[row+19][col] << W0*9) | (r[row+17][col] << W0*8) | (r[row+15][col] << W0*7) | (r[row+13][col] << W0*6) | (r[row+11][col] << W0*5) | (r[row+9][col] << W0*4) | (r[row+7][col] << W0*3) | (r[row+5][col] << W0*2) | (r[row+3][col] << W0*1) | (r[row-1][col] )) Also works most of time with + instead | Most of the time it works working okay generates a signal of 160 1111100001000010000011111000001111100000111110000011111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1111100000111110000011111000001110100000111010000011111000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 10000100000111110000100001000001111100000111110000011111000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 This causes the error the signal needs 157 more bits 100 100 100 Traceback (most recent call last): File "test_bench_array_jpeg.py", line 482, in <module> sim.run() File "/usr/lib/python2.7/site-packages/myhdl/_Simulation.py", line 132, in run waiter.next(waiters, actives, exc) File "/usr/lib/python2.7/site-packages/myhdl/_Waiter.py", line 141, in next clause = self.generator.next() File "test_bench_array_jpeg.py", line 344, in stimulus lft_s_i.next = ((r[row+31][col] << W0*15) | (r[row+29][col] << W0*14) | (r[row+27][col] << W0*13) | (r[row+25][col] << W0*12) | (r[row+23][col] << W0*11) | (r[row+21][col] << W0*10) | (r[row+19][col] << W0*9) | (r[row+17][col] << W0*8) | (r[row+15][col] << W0*7) | (r[row+13][col] << W0*6) | (r[row+11][col] << W0*5) | (r[row+9][col] << W0*4) | (r[row+7][col] << W0*3) | (r[row+5][col] << W0*2) | (r[row+3][col] << W0*1) | (r[row-1][col] )) File "/usr/lib/python2.7/site-packages/myhdl/_Signal.py", line 216, in _set_next self._setNextVal(val) File "/usr/lib/python2.7/site-packages/myhdl/_Signal.py", line 282, in _setNextIntbv self._next._handleBounds() File "/usr/lib/python2.7/site-packages/myhdl/_intbv.py", line 83, in _handleBounds (self._val, self._min)) ValueError: intbv value -4 < minimum 0 All help is appreciated. Edward Vidal Jr. e-mail dev...@sb... 915-595-1613 |
From: Jan <jen...@mu...> - 2015-03-09 00:15:26
|
On Sat, 7 Mar 2015 14:12:06 -0800 Edward Vidal <dev...@sb...> wrote: > Hello All, > Trying to take 16 values from an image to generate 160 bit signal Why? Jan Coombs. |
From: Christopher F. <chr...@gm...> - 2015-03-12 18:45:34
|
On 3/7/2015 4:12 PM, Edward Vidal wrote: > Hello All, > Trying to take 16 values from an image to generate 160 bit signal > Here is an example that might help. Differs from yours in that it uses ShadowSignals and elaboration to build the "flat" representation. The example uses an 8x5 matrix of 8bit signals and creates a 160 bit flat version of the 4 lsb from each matrix element. def m_flatten(matrix, flat): _flat = ConcatSignal(*[col(4,0) for row in matrix for col in row]) @always_comb def rtl(): flat.next = _flat return rtl def test_flatten(): matrix = [[Signal(intbv(0)[8:]) for col in range(5)] for row in range(8)] flat = Signal(intbv(0)[160:]) tbdut = m_flatten(matrix, flat) @instance def tbstim(): yield delay(1) print(bin(flat, 160)) assert flat == 0 matrix[0][0].next = 0x8 yield delay(1) print(bin(flat, 160)) assert flat[160-1] == 1 return tbdut, tbstim Simulation(test_flatten()).run() https://gist.github.com/cfelton/d52fc4abe8d50b73c13c <snip> > Most of the time it works > working okay generates a signal of 160 <snip> > ValueError: intbv value -4 < minimum 0 I believe the error you are seeing can be explained with this little example: x = intbv(0)[16:] y = intbv(0, min=-128, max=128) z = intbv(0, min=0, max=256) # this will work x[:] = (y << 8) | z print(x) # this will fail y[:] = -8 x[:] = (y << 8) | z print(x) # this will work y[:] = 118 x[:] = (y << 8) | z print(x) Regards, Chris |
From: Edward V. <dev...@sb...> - 2015-03-13 19:57:06
|
Chris, I made some changes to flaten.py at https://github.com/develone/jpeg-2000-test/blob/master/jpeg2k/parallel_jpeg/flaten.py. I added a random number for testing. This needs .signed() to work. Is this only for Python? In your example you started adding values at the MSB is this the preferred method? Regards Edward Vidal Jr. e-mail dev...@sb... 915-595-1613 On Thursday, March 12, 2015 12:45 PM, Christopher Felton <chr...@gm...> wrote: On 3/7/2015 4:12 PM, Edward Vidal wrote: > Hello All, > Trying to take 16 values from an image to generate 160 bit signal > Here is an example that might help. Differs from yours in that it uses ShadowSignals and elaboration to build the "flat" representation. The example uses an 8x5 matrix of 8bit signals and creates a 160 bit flat version of the 4 lsb from each matrix element. def m_flatten(matrix, flat): _flat = ConcatSignal(*[col(4,0) for row in matrix for col in row]) @always_comb def rtl(): flat.next = _flat return rtl def test_flatten(): matrix = [[Signal(intbv(0)[8:]) for col in range(5)] for row in range(8)] flat = Signal(intbv(0)[160:]) tbdut = m_flatten(matrix, flat) @instance def tbstim(): yield delay(1) print(bin(flat, 160)) assert flat == 0 matrix[0][0].next = 0x8 yield delay(1) print(bin(flat, 160)) assert flat[160-1] == 1 return tbdut, tbstim Simulation(test_flatten()).run() https://gist.github.com/cfelton/d52fc4abe8d50b73c13c <snip> > Most of the time it works > working okay generates a signal of 160 <snip> > ValueError: intbv value -4 < minimum 0 I believe the error you are seeing can be explained with this little example: x = intbv(0)[16:] y = intbv(0, min=-128, max=128) z = intbv(0, min=0, max=256) # this will work x[:] = (y << 8) | z print(x) # this will fail y[:] = -8 x[:] = (y << 8) | z print(x) # this will work y[:] = 118 x[:] = (y << 8) | z print(x) Regards, Chris ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ myhdl-list mailing list myh...@li... https://lists.sourceforge.net/lists/listinfo/myhdl-list |
From: Christopher F. <chr...@gm...> - 2015-03-13 21:50:07
|
On 3/13/2015 2:56 PM, Edward Vidal wrote: > Chris, > I made some changes to flaten.py at https://github.com/develone/jpeg-2000-test/blob/master/jpeg2k/parallel_jpeg/flaten.py. I added a random number for testing. This needs .signed() to work. Is this only for Python? In your example you started adding values at the MSB is this the preferred method? Not sure what you mean, "Only for Python?". The example should be convertible. But you would need a top-level wrapper, list-of-signals are not convertible as a top-level port. Why does it need "signed" to work? It is weird to concat signed values. The result, you might want it to be signed but the intermediate bits being concat'd shouldn't need to be signed (am I missing something?). The msb or lsb would be application dependent not a preference, I simply chose one for the example. you can use `*reverse` to flip the lsb-msb. Regards, Chris > > On Thursday, March 12, 2015 12:45 PM, Christopher Felton <chr...@gm...> wrote: > > > > > On 3/7/2015 4:12 PM, Edward Vidal wrote: >> Hello All, >> Trying to take 16 values from an image to generate 160 bit signal >> > Here is an example that might help. Differs from yours > in that it uses ShadowSignals and elaboration to build > the "flat" representation. The example uses an 8x5 > matrix of 8bit signals and creates a 160 bit flat > version of the 4 lsb from each matrix element. > > def m_flatten(matrix, flat): > _flat = ConcatSignal(*[col(4,0) for row in matrix > for col in row]) > @always_comb > def rtl(): > flat.next = _flat > return rtl > > > def test_flatten(): > matrix = [[Signal(intbv(0)[8:]) for col in range(5)] > for row in range(8)] > flat = Signal(intbv(0)[160:]) > tbdut = m_flatten(matrix, flat) > @instance > def tbstim(): > yield delay(1) > print(bin(flat, 160)) > assert flat == 0 > matrix[0][0].next = 0x8 > yield delay(1) > print(bin(flat, 160)) > assert flat[160-1] == 1 > return tbdut, tbstim > Simulation(test_flatten()).run() > > https://gist.github.com/cfelton/d52fc4abe8d50b73c13c > > <snip> > >> Most of the time it works >> working okay generates a signal of 160 > <snip> > >> ValueError: intbv value -4 < minimum 0 > > I believe the error you are seeing can be explained > with this little example: > > x = intbv(0)[16:] > y = intbv(0, min=-128, max=128) > z = intbv(0, min=0, max=256) > > # this will work > x[:] = (y << 8) | z > print(x) > > > # this will fail > y[:] = -8 > x[:] = (y << 8) | z > print(x) > > > # this will work > y[:] = 118 > x[:] = (y << 8) | z > print(x) > > > Regards, > Chris > > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, sponsored > by Intel and developed in partnership with Slashdot Media, is your hub for all > things parallel software development, from weekly thought leadership blogs to > news, videos, case studies, tutorials and more. Take a look and join the > conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, sponsored > by Intel and developed in partnership with Slashdot Media, is your hub for all > things parallel software development, from weekly thought leadership blogs to > news, videos, case studies, tutorials and more. Take a look and join the > conversation now. http://goparallel.sourceforge.net/ > > > > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > |