Re: [casper] Problem with fi and test suite
Hi Danny, It was the reinterpretcast function that fixed my problems. Cheers, Ross p.s. BTW in python there is a fixed_point module called SPFPM but it's not great. I've just found that bit manipulation is a little more straight forward using python. On Thu, Oct 3, 2013 at 1:39 PM, Danny Price wrote: > Hi Ross > > I think this should do exactly what you want: > > % Convert complex data stored in a 36_0 Unsigned format into > % actual complex data in a matlab array > % Useful for converting output of casper FFT into complex array. > > function cplx_vec = conv36u_cplx(vec_36u) > %disp('Converting 36_0 data to 18_17 complex') > s18 = numerictype(1, 18, 17); > cplx_vec = complex(zeros(length(vec_36u),1)); > > for jj=1:length(vec_36u) > a = fi(vec_36u(jj), 0, 64, 0); > re = reinterpretcast(bitsliceget(a, 18, 1), s18); > im = reinterpretcast(bitsliceget(a, 36, 19), s18); > cplx = re + im*1i; > cplx_vec(jj) = cplx; > end > > There may be a neater way to do this (in which case please tell me!). > > Regards > Danny > > PS: I've never done fixed point stuff with scipy, can you point me in the > direction of some examples? > > > > Ross Williamson wrote: > > Hi, > > I'm trying to implement a test suite for a correlator and I'm having > serious problems with my understanding of fi. The output of the fft > stage is UFIX 36_0. I capture that in a matlab variable (say > fft_out0). All I want to do is split that up into Re and Im parts at > FIX 18_17. I'm finding this rather difficult to do in matlab > (especially because simple bit operations such as & >> and > representing numbers via 0x notation do not work). > > If for example I try and convert the output from matlab > > fi(fft_out0,0,36,0) I still get a fractional number which baffles me. > > Is there a way to take this UFIX36_0, split into two FIX 18_17 and > turn it into a complex number? > > Ross > > p.s. I'm using the unbus blocks to create the simulink output. I don't > want to manually add gateways from every re_im block unless I really > have to. > > (p.p.s I'm coming from scipy where this would be trivial hence the > want to throw the toys out of the pram) > -- Ross Williamson Research Scientist - Sub-mm Group California Institute of Technology 626-395-2647 (office) 312-504-3051 (Cell)
Re: [casper] Problem with fi and test suite
Be careful when outputting very wide values to the Matlab workspace. I think Matlab stores values as doubles (i.e. IEEE 64-bit floating point) which only have 52+1 bits of mantissa. Values wider than 53 bits may not be bit accurate when converted to double format. It should be OK for the 36 bit values you are using. The "To Workspace" block might be able to save in bit accurate fixed point format if you have the fixed point toolbox installed, but I think it's preferable to avoid that as much as possible (ideally entirely) so that CASPER collaborators are not required to purchase another toolbox. Dave On Oct 3, 2013, at 2:30 PM, Ross Williamson wrote: > I could do that but it's messy and it should not be difficult to do in > Matlab - I have screwed up though > > fi(fft_out0,0,36,0) is not a fractional number at all - Matlab puts it > in exponential form which is described at the top of the list about > 100 page-scrolls back.. > > This might make the rest of what I'm doing make more sense.. > > Matlab always put's me in a good mood. > > Ross > > On Thu, Oct 3, 2013 at 1:48 PM, G Jones wrote: >> I always just break out the real and imag parts before going to matlab >> workspace >> >> On Oct 3, 2013 4:23 PM, "Ross Williamson" >> wrote: >>> >>> Hi, >>> >>> I'm trying to implement a test suite for a correlator and I'm having >>> serious problems with my understanding of fi. The output of the fft >>> stage is UFIX 36_0. I capture that in a matlab variable (say >>> fft_out0). All I want to do is split that up into Re and Im parts at >>> FIX 18_17. I'm finding this rather difficult to do in matlab >>> (especially because simple bit operations such as & >> and >>> representing numbers via 0x notation do not work). >>> >>> If for example I try and convert the output from matlab >>> >>> fi(fft_out0,0,36,0) I still get a fractional number which baffles me. >>> >>> Is there a way to take this UFIX36_0, split into two FIX 18_17 and >>> turn it into a complex number? >>> >>> Ross >>> >>> p.s. I'm using the unbus blocks to create the simulink output. I don't >>> want to manually add gateways from every re_im block unless I really >>> have to. >>> >>> (p.p.s I'm coming from scipy where this would be trivial hence the >>> want to throw the toys out of the pram) >>> >>> -- >>> Ross Williamson >>> Research Scientist - Sub-mm Group >>> California Institute of Technology >>> 626-395-2647 (office) >>> 312-504-3051 (Cell) >>> >> > > > > -- > Ross Williamson > Research Scientist - Sub-mm Group > California Institute of Technology > 626-395-2647 (office) > 312-504-3051 (Cell) >
Re: [casper] Problem with fi and test suite
I could do that but it's messy and it should not be difficult to do in Matlab - I have screwed up though fi(fft_out0,0,36,0) is not a fractional number at all - Matlab puts it in exponential form which is described at the top of the list about 100 page-scrolls back.. This might make the rest of what I'm doing make more sense.. Matlab always put's me in a good mood. Ross On Thu, Oct 3, 2013 at 1:48 PM, G Jones wrote: > I always just break out the real and imag parts before going to matlab > workspace > > On Oct 3, 2013 4:23 PM, "Ross Williamson" > wrote: >> >> Hi, >> >> I'm trying to implement a test suite for a correlator and I'm having >> serious problems with my understanding of fi. The output of the fft >> stage is UFIX 36_0. I capture that in a matlab variable (say >> fft_out0). All I want to do is split that up into Re and Im parts at >> FIX 18_17. I'm finding this rather difficult to do in matlab >> (especially because simple bit operations such as & >> and >> representing numbers via 0x notation do not work). >> >> If for example I try and convert the output from matlab >> >> fi(fft_out0,0,36,0) I still get a fractional number which baffles me. >> >> Is there a way to take this UFIX36_0, split into two FIX 18_17 and >> turn it into a complex number? >> >> Ross >> >> p.s. I'm using the unbus blocks to create the simulink output. I don't >> want to manually add gateways from every re_im block unless I really >> have to. >> >> (p.p.s I'm coming from scipy where this would be trivial hence the >> want to throw the toys out of the pram) >> >> -- >> Ross Williamson >> Research Scientist - Sub-mm Group >> California Institute of Technology >> 626-395-2647 (office) >> 312-504-3051 (Cell) >> > -- Ross Williamson Research Scientist - Sub-mm Group California Institute of Technology 626-395-2647 (office) 312-504-3051 (Cell)
Re: [casper] Problem with fi and test suite
FWIW, I break the complex into real and imag using the casper block for that purpose, then go through gateway outs (with "translate into output port" off) then recombine the ral ans imag with a Simulink reim-to-complex block and then go into a "To Workspace" block. That way I don't have to do any manipulation on the matlab side of things. Dave On Oct 3, 2013, at 1:48 PM, G Jones wrote: > I always just break out the real and imag parts before going to matlab > workspace > > On Oct 3, 2013 4:23 PM, "Ross Williamson" > wrote: > Hi, > > I'm trying to implement a test suite for a correlator and I'm having > serious problems with my understanding of fi. The output of the fft > stage is UFIX 36_0. I capture that in a matlab variable (say > fft_out0). All I want to do is split that up into Re and Im parts at > FIX 18_17. I'm finding this rather difficult to do in matlab > (especially because simple bit operations such as & >> and > representing numbers via 0x notation do not work). > > If for example I try and convert the output from matlab > > fi(fft_out0,0,36,0) I still get a fractional number which baffles me. > > Is there a way to take this UFIX36_0, split into two FIX 18_17 and > turn it into a complex number? > > Ross > > p.s. I'm using the unbus blocks to create the simulink output. I don't > want to manually add gateways from every re_im block unless I really > have to. > > (p.p.s I'm coming from scipy where this would be trivial hence the > want to throw the toys out of the pram) > > -- > Ross Williamson > Research Scientist - Sub-mm Group > California Institute of Technology > 626-395-2647 (office) > 312-504-3051 (Cell) >
Re: [casper] Problem with fi and test suite
I always just break out the real and imag parts before going to matlab workspace On Oct 3, 2013 4:23 PM, "Ross Williamson" wrote: > Hi, > > I'm trying to implement a test suite for a correlator and I'm having > serious problems with my understanding of fi. The output of the fft > stage is UFIX 36_0. I capture that in a matlab variable (say > fft_out0). All I want to do is split that up into Re and Im parts at > FIX 18_17. I'm finding this rather difficult to do in matlab > (especially because simple bit operations such as & >> and > representing numbers via 0x notation do not work). > > If for example I try and convert the output from matlab > > fi(fft_out0,0,36,0) I still get a fractional number which baffles me. > > Is there a way to take this UFIX36_0, split into two FIX 18_17 and > turn it into a complex number? > > Ross > > p.s. I'm using the unbus blocks to create the simulink output. I don't > want to manually add gateways from every re_im block unless I really > have to. > > (p.p.s I'm coming from scipy where this would be trivial hence the > want to throw the toys out of the pram) > > -- > Ross Williamson > Research Scientist - Sub-mm Group > California Institute of Technology > 626-395-2647 (office) > 312-504-3051 (Cell) > >
Re: [casper] Problem with fi and test suite
Hi Ross I think this should do exactly what you want: % Convert complex data stored in a 36_0 Unsigned format into % actual complex data in a matlab array % Useful for converting output of casper FFT into complex array. function cplx_vec = conv36u_cplx(vec_36u) %disp('Converting 36_0 data to 18_17 complex') s18 = numerictype(1, 18, 17); cplx_vec = complex(zeros(length(vec_36u),1)); for jj=1:length(vec_36u) a = fi(vec_36u(jj), 0, 64, 0); re = reinterpretcast(bitsliceget(a, 18, 1), s18); im = reinterpretcast(bitsliceget(a, 36, 19), s18); cplx = re + im*1i; cplx_vec(jj) = cplx; end There may be a neater way to do this (in which case please tell me!). Regards Danny PS: I've never done fixed point stuff with scipy, can you point me in the direction of some examples? Ross Williamson wrote: Hi, I'm trying to implement a test suite for a correlator and I'm having serious problems with my understanding of fi. The output of the fft stage is UFIX 36_0. I capture that in a matlab variable (say fft_out0). All I want to do is split that up into Re and Im parts at FIX 18_17. I'm finding this rather difficult to do in matlab (especially because simple bit operations such as& >> and representing numbers via 0x notation do not work). If for example I try and convert the output from matlab fi(fft_out0,0,36,0) I still get a fractional number which baffles me. Is there a way to take this UFIX36_0, split into two FIX 18_17 and turn it into a complex number? Ross p.s. I'm using the unbus blocks to create the simulink output. I don't want to manually add gateways from every re_im block unless I really have to. (p.p.s I'm coming from scipy where this would be trivial hence the want to throw the toys out of the pram)
[casper] Problem with fi and test suite
Hi, I'm trying to implement a test suite for a correlator and I'm having serious problems with my understanding of fi. The output of the fft stage is UFIX 36_0. I capture that in a matlab variable (say fft_out0). All I want to do is split that up into Re and Im parts at FIX 18_17. I'm finding this rather difficult to do in matlab (especially because simple bit operations such as & >> and representing numbers via 0x notation do not work). If for example I try and convert the output from matlab fi(fft_out0,0,36,0) I still get a fractional number which baffles me. Is there a way to take this UFIX36_0, split into two FIX 18_17 and turn it into a complex number? Ross p.s. I'm using the unbus blocks to create the simulink output. I don't want to manually add gateways from every re_im block unless I really have to. (p.p.s I'm coming from scipy where this would be trivial hence the want to throw the toys out of the pram) -- Ross Williamson Research Scientist - Sub-mm Group California Institute of Technology 626-395-2647 (office) 312-504-3051 (Cell)