Re: [myhdl-list] intbv.signed()
Brought to you by:
jandecaluwe
From: Günter D. <dan...@we...> - 2008-08-04 12:03:26
|
Jan Decaluwe wrote: > Günter Dannoritzer wrote: >> Jan Decaluwe wrote: >> ... >>> Sounds all very logical to me. >> Would that change already qualify for a bundle > > Yes, but ideally we should also have a test for it, > perhaps we need to discuss this further. > I have a test case with three tests. The first test verifies the behavior of the signed() function in connection with intbv instances having various parameters and values. The test is divided in two parts. The first part contains cases that make the signed() function classify the value as unsigned and consider the bits based on _nrbits as a 2's complement value. The second part triggers cases were the value is classified as signed and the value returned as is. The second test verifies the behavior of the signed() function in connection with slices. This test can actually be simplified, as the return of a sliced intbv is always an intbv with min=0 and max>min, which is always classified by the signed() function as unsigned. So I only did two verifications here, one with a slice and the sign bit set and one with a slice with the sign bit not set. The third test verifies the behavior in connection with the concat() function. Using the signed() function in connection with concat() only makes sense, if the concat() function will return an intbv instance. If I understand the concat() function right, there are cases when it only returns an integer value. So here I limited the test to two verifies. In one I concat() three bool values, with the msb set and I expect the bit pattern to be returned as 2's complement value by the signed() function. In the second test I take an intbv instance that would be classified as unsigned and concatenate two bool values. Again, expecting the value to be returned as 2's complement value. Guenter |