FPGARelated.com
Forums

How to control the uart

Started by ZHI June 30, 2006
Here is my general idea.I generate a matrix in Matlab. I want to
transmit the numbers in matrix into FPGA. And these numbers will be
sent to an algorithm implemented FPGA board. The algorithm will deal
with these numbers and new result is sent back to PC(Matlab, I want to
compare the result from MATLAB).

I know transmitting these numbers to FPGA board. I need a UART. I have
one. I also have done the algorithms in FPGA. But I don't know how to
transmit the numbers from Matlab to FPGA. Exactly to say, I don't know
how to control uart. How does uart know the data come in? Shall i add
like "FF" file head to transmitting number? ...I am totally lost now. I
have no idea how to connect Matlab to FPGA. Please give me some
suggestions. Thanks.

ZHI wrote:
> Here is my general idea.I generate a matrix in Matlab. I want to > transmit the numbers in matrix into FPGA. And these numbers will be > sent to an algorithm implemented FPGA board. The algorithm will deal > with these numbers and new result is sent back to PC(Matlab, I want to > compare the result from MATLAB). > > I know transmitting these numbers to FPGA board. I need a UART. I have > one. I also have done the algorithms in FPGA. But I don't know how to > transmit the numbers from Matlab to FPGA. Exactly to say, I don't know > how to control uart. How does uart know the data come in? Shall i add > like "FF" file head to transmitting number? ...I am totally lost now. I > have no idea how to connect Matlab to FPGA. Please give me some > suggestions. Thanks.
Do a google search on "Matlab serial I/O". I came up with this rather promising link in under 30 seconds. http://www.math.carleton.ca/~help/matlab/MathWorks_R13Doc/techdoc/matlab_external/ch_seria.html You will need some sort of control logic in the FPGA to handle the UART, but if you are already implementing algo's in both MATLAB and VHDL/Verilog, a simple state machine should be no problem.
ZHI wrote:
> ... > I know transmitting these numbers to FPGA board. I need a UART. I have > one. I also have done the algorithms in FPGA. But I don't know how to > transmit the numbers from Matlab to FPGA. Exactly to say, I don't know > how to control uart. How does uart know the data come in? ...
Every byte of data sent via the UART starts with a start bit and ends with a stop bit (in the most commonly used scheme, 1 start bit, 1 stop bit, no parity). In between transmission of data, the UART holds the stop bit level. UART receivers therefore know that no data is being sent until it receives a start bit, and it knows that the next 8 bits are data. All this is handled by the hardware and is largely transparent to you. Within the FPGA, the UART receiver will provide a bit indicating that data has been received.
Thanks radarman and Duane Clark. I have read that link. It is quite
useful.
I want to make a simple test for transmission data between PC(matlab)
to FPGA(UART).  I can generate the UART.bit file and download into FPGA
board successfully.
Can I ask a question of user constraint file ? I have successfully
downloaded a LED flash into FPGA board before. I copied this exercise
from the CD enclosed with the FPGA board. I remember before I implement
it into FPGA board. I not only generate the .bit file also copied the
LED user constraint file in the CD. Actually I am not quite sure the
content of the constraint file. I just copied it. Now I want to
implement UART into FPGA board. I think it also needs one user
constraint file for implementing. I think the user constraint file is
generated automatically when the programming file is generated. But
when I open the .ucf file, it is blank. What is the problem? Shall i
write it by myself? I don't know how to connect the pin? Can you
explain the .ucf function for me clearly? And How does it work and how
does it generate? Actually I have not a clear thread of it. Any
suggestions are appreciated. Thanks again.
\zhi
Duane Clark wrote:
> ZHI wrote: > > ... > > I know transmitting these numbers to FPGA board. I need a UART. I have > > one. I also have done the algorithms in FPGA. But I don't know how to > > transmit the numbers from Matlab to FPGA. Exactly to say, I don't know > > how to control uart. How does uart know the data come in? ... > > Every byte of data sent via the UART starts with a start bit and ends > with a stop bit (in the most commonly used scheme, 1 start bit, 1 stop > bit, no parity). In between transmission of data, the UART holds the > stop bit level. UART receivers therefore know that no data is being sent > until it receives a start bit, and it knows that the next 8 bits are data. > > All this is handled by the hardware and is largely transparent to you. > Within the FPGA, the UART receiver will provide a bit indicating that > data has been received.
It is solved. Thanks all again.