How to write binary instead of strings

Questions and discussions about the Xillybus IP core and drivers

How to write binary instead of strings

Postby rajavazrala »

Hi Eli,

I have been using Xillybus IP core for integrating with a custom FPGA logic. The requirement is to send a 32bit data from the host to the FPGA through FIFO, FPGA then reads this data processes it and puts it back to another FIFO (FPGA to host). As we know that the data written into user_w_write_32 device file will be first converted to strings and then it's written to FIFO. But, I need to put the binary values directly instead of putting the ascii values into the FIFO. Is there any way to do this ?

For example: if I want to put 32 bit binary 0000000000000000000011011101111 into the FIFO through device file, how do I do that?

Thanks,
Raja
rajavazrala
 
Posts: 3
Joined:

Re: How to write binary instead of strings

Postby support »

Hello,

What do you mean that the data is first converted to strings? Where does that happen?

Whatever you write into /dev/xillybus_write_32 arrives exactly the same at the FPGA's FIFO. Sometimes people misunderstand the utilities or the file I/O operations on the host, and therefore get the impression that changes are made on the way. But there are no changes made to the data once it reaches the device file.

Regards,
Eli
support
 
Posts: 802
Joined:

Re: How to write binary instead of strings

Postby rajavazrala »

Hi Eli,

Thank you for the reply. Whatever we write into the device will be treated as strings, So, the driver tries to convert this to ASCII and then puts it into the FIFO.

For example, if I want to put binary 1010 into the FIFO, I will use the below command

cat > /dev/xillybus_write_32
1010

Then the driver below the device file understands this is as "1010", hence it transforms into ASCII(1)ASCII(0)ASCII(1)ASCII(0) and the resultant 32-bit word is put into the FIFO. This is how it works on the xillybus Linux platform.

So, in my case, I don't want the driver to convert from binary to strings. If I write 1010....(32bit binary) , I should see that written into FIFO without storing its equivalent ASCII value.

Thanks,
Raja
rajavazrala
 
Posts: 3
Joined:

Re: How to write binary instead of strings

Postby support »

Hello,

You've chosen to use the "cat" utility. If you type "1", you get the ASCII representation of "1". It's as simple as that.

If you want to type a binary representation of a number, and have that written to the file, I suppose the shortest path is to write a small program in your favorite language that does exactly that. All it has to do is receive the number from standard input and write the desired representation to the file. There are plenty of languages, both compiled and scripted to choose from on a Linux system.

Regards,
Eli
support
 
Posts: 802
Joined:


Return to Xillybus