I want to transmit a set of data R to FPGA board. The ABS|R|

- posted
16 years ago

- posted
16 years ago

I want to transmit a set of data R to FPGA board. The ABS|R|

Loading thread data ...

- posted
16 years ago

I would like to add some information here. I transmit these data by separating them as 2 parts like this:

for i= 1: N^2 if R1(i) < 0 R1(i) = R1(i) + 2^8; end for j=1:2 if j==1 R3(k)= rem(R1(i),256); k=k+1; elseif j==2 R3(k)= floor(R1(i)/256); k=k+1; end end end

Then I use a double-ports ram in FPGA to store these data, I use

8bits wideth data port to receive these data. Data is out from a port with 16bits width. So these data resume to the original ones. I guess if these data actually needs 16bits, so I plus 2^8 will get the wrong result. I cannot convince myself. Does anybody know something about it? Thank you.- posted
16 years ago

It looks like you're using Matlab. Their integer functions are very clumsy. This would be easy in almost any other language.

If you're looking to end up with 8-bit 2's complement integers, then you should add 2^7 not 2^8. This might clear up your problem. I don't understand what your loop on "j" is doing. So I can't comment further. Good luck.

Tom

- posted
16 years ago

Sorry, I was confusing the interger value of the sign bit post-conversion, with the value of the constant added during the conversion. 2^8 is right.

As for the rest, if you are starting with integer values, just send the bits and interpret them as you need. So I'll assume that you are starting with floating point values.

Assuming you are using Matlab, I recommend using the fix() function. This converts float to integer (rounding to zero).

If not, and you have to build your own conversion routine: First, you must restrict your range to -1

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.