Re: [myhdl-list] Generating 160 bit signal
Brought to you by:
jandecaluwe
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 > |