Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to send 1's & 0's as binary from pc to fpga

Status
Not open for further replies.

charita vyshnavi N

Newbie level 4
Joined
Feb 19, 2015
Messages
7
Helped
0
Reputation
2
Reaction score
1
Trophy points
3
Activity points
63
hai sir/madam.....

i have BCH code which run for (15,7,2) set which is implemented in VHDL and it is dumped in FPGA kit.my task is to sending 15 bits as input to the bch code and then separating them as msg and parity. after seperation i will take msg seperately and generate the parity (i will see the output parity on LED on FPGA board) after that i will compare the old parity and newly generated parity to know about the msg is correpted or not, if they are not same then i will say there is an error in the msg.

i tagged the 15 bits in the program and i am sending to fpga, but if i want to send another set of 15 bits then i have to tag them in the program and then again have to dump the entire program in the fpga.

for every new data i have to dump the same logic again and again. instead of dumping the same logic again and again i created a text file with 10 lines of binary information each line consists of 15 bits (input bits). now i wanted to send each line of binary information to BCH logic as an input.

i know interfacing of pc with fpga kit because luckly i have a fpga kit with uart interfacing, so i connected with a USB cable simply.

now

Q) while reading the text file, the first line first bit is sending via UART but UART accepts only ascii values so how to convert ascii to binary to send to BCH logic.



please give me reply as early as possible .....

thank u
 

ASCII code of 0 is 0x30 and the ASCII code of 1 is 0x31. Just translate the UART ASCII characters and stuff them into a shift register. You can look for 0x0A 0x0d (and throw away) to delineate each 15-bit value.
 

Can u please explain clearly about translating ASCII character....... We have to translate ASCII to what?
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
Can u please explain clearly about translating ASCII character....... We have to translate ASCII to what?
You really don't know this? 8-O

ASCII is the stuff that is used to represent text and some control characters like line feed, carriage return, EOF, etc. The ASCII character set is in that table I linked in post #2.

e.g. If you have a text file with the following lines
0101
1100

The file actually has the following if you look at it in a hex editor:
303130310D0A313130300D0A

In your code you look for those hex codes 0x30 or 0x31 (the ASCII codes for 0 and 1 respectively).

Code VHDL - [expand]
1
2
3
4
5
6
7
if input_char == "00110000" then
  -- stuff 0 into shift register
  number <= number(13 downto 0) & '0';
elsif input_char == "00110001" then
  -- stuff 1 into shift register
  number <= number(13 downto 0) & '1';
end if;



Something like that would shift a 0 or 1 into a 15-bit word register. You need more code to detect the CR-LF of the text file (to delineate the numbers) you are sending over the UART.
 
thank u for giving reply......

Can we send data to FPGA from PC using a MATLAB program, what is the procedure?
 

i have written matlab code for sending data to fpga.....

code:
------

1. clc;
2. delete(instrfindall);
3. clear s;
4. s = serial('COM3', 'BauRate',9600, 'DataBits',8);
5. f = open(s);
6. fwrite(s,'1');
7. a = fscanf(s,'%c',s.BytesAvailable);
8. disp(a);
9. fclose(s);

Q) when i run this program it is giving error in the line:7 s.BytesAvailable should be greater than '0' but s.BytesAvailable is zero. my data is present in a text file.
we r representing 's' with com port, baudrate and databits but i didn't mention any data which i wanted to transfer in s..... so how to send data in textfile to that port?

i have a textfile with 1's and 0's' .... each line consist of 63 digits (eg: 101111000010110100010101...... 63rd digit)... now i have to send each digit from pc(1 next 0 next 1 ans so on)....

uart(rx) : uart at fpga

Q) the o/p of uart(rx) is 7 bit representation of each digit (now my first digit is 1 represented by 7 bits as 0000001) but i have to represent in 1 bit (1 should be represented in 1 bit instead of representing 0000001 ).... how to write code for that in vhdl to send a digit(8-bit) from pc to 1 bit in fpga?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top