📄 serial interface5.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0045)http://www.fpga4fun.com/SerialInterface5.html -->
<HTML><HEAD><TITLE>FPGAs are fun!</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<STYLE>BODY {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
A {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
P {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
DIV {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
HR {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
UL {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
TD {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
TH {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
DD {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
DT {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
PRE {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
CAPTION {
FONT-FAMILY: Verdana,Tahoma,Arial; FONT-SIZE: 10px
}
A {
COLOR: black; FONT-WEIGHT: bold; TEXT-DECORATION: none
}
A:hover {
TEXT-DECORATION: underline
}
.link {
COLOR: #000000
}
.link:hover {
COLOR: blue; TEXT-DECORATION: underline
}
PRE {
BACKGROUND: #d0d0f0; MARGIN: 5px; PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px
}
</STYLE>
<META content="MSHTML 5.00.3315.2870" name=GENERATOR></HEAD>
<BODY leftMargin=0 rightMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<TABLE border=0 cellPadding=2 cellSpacing=5 width="100%" nowrap>
<TBODY>
<TR>
<TD bgColor=#9090c0 vAlign=top><FONT size=40>fpga4fun.com</FONT> - where
FPGAs are fun<BR><BR></TD></TR>
<TR>
<TD bgColor=white height=1></TD></TR>
<TR>
<TD bgColor=black height=1></TD></TR></TBODY></TABLE>
<TABLE cellPadding=5 cellSpacing=5 height="100%">
<TBODY>
<TR>
<TD bgColor=#dddddd vAlign=top width=140><FONT color=#9090c0><B>Home<BR><A
class=link href="http://www.fpga4fun.com/">FPGAs are fun!</A><BR><A
class=link href="http://www.fpga4fun.com/WhyThisSite.html">Why this
site?</A><BR><BR>FPGA Boards<BR><A class=link
href="http://www.fpga4fun.com/board.html">Overview</A><BR><A class=link
href="http://www.fpga4fun.com/board_pluto.html">Pluto board</A><BR><A
class=link href="http://www.fpga4fun.com/board_pluto-II.html">Pluto-II
board</A><BR><A class=link
href="http://www.fpga4fun.com/board_dragon.html">Dragon board</A><BR><A
class=link href="http://www.fpga4fun.com/board_TXDI.html">TXDI serial
interface</A><BR><A class=link
href="http://www.fpga4fun.com/board_flashy.html">Flashy fast
ADC</A><BR><BR>FPGA projects<BR><A class=link
href="http://www.fpga4fun.com/RCServos.html">R/C servos</A><BR><A
class=link href="http://www.fpga4fun.com/SerialInterface.html">Serial
interface</A><BR><A class=link
href="http://www.fpga4fun.com/TextLCDmodule.html">Text LCD
module</A><BR><A class=link
href="http://www.fpga4fun.com/MusicBox.html">Music box</A><BR><A
class=link href="http://www.fpga4fun.com/PWM_DAC.html">PWM and one-bit
DAC</A><BR><A class=link
href="http://www.fpga4fun.com/QuadratureDecoder.html">Quadrature
decoder</A><BR><A class=link
href="http://www.fpga4fun.com/PongGame.html">Pong game</A><BR><A
class=link href="http://www.fpga4fun.com/GraphicLCDpanel.html">Graphic LCD
panel</A><BR><BR>Advanced projects<BR><A class=link
href="http://www.fpga4fun.com/digitalscope.html">Digital
oscilloscope</A><BR><A class=link
href="http://www.fpga4fun.com/10BASE-T.html">10BASE-T interface</A><BR><A
class=link href="http://www.fpga4fun.com/PCI.html">PCI
interface</A><BR><BR>FPGAs<BR><A class=link
href="http://www.fpga4fun.com/WhatAreFPGAs.html">What are FPGAs</A><BR><A
class=link href="http://www.fpga4fun.com/HowFPGAsWork.html">How FPGAs
work</A><BR><A class=link
href="http://www.fpga4fun.com/clocks.html">Clocks and global
lines</A><BR><A class=link
href="http://www.fpga4fun.com/DownloadCables.html">Download
cables</A><BR><A class=link
href="http://www.fpga4fun.com/configuration.html">Configuration</A><BR><A
class=link href="http://www.fpga4fun.com/LearnMore.html">Learn
more</A><BR><BR>FPGA electronic<BR><A class=link
href="http://www.fpga4fun.com/SMD.html">SMD technology</A><BR><A
class=link href="http://www.fpga4fun.com/oscillators.html">Crystals and
oscillators</A><BR><BR>FPGA software<BR><A class=link
href="http://www.fpga4fun.com/designsoftware.html">Design
software</A><BR><A class=link
href="http://www.fpga4fun.com/pinassignment.html">Pin assignment</A><BR><A
class=link
href="http://www.fpga4fun.com/designentry.html">Design-entry/HDL</A><BR><A
class=link
href="http://www.fpga4fun.com/simulation.html">Simulation/HDL</A><BR><A
class=link href="http://www.fpga4fun.com/synthesis&pnr.html">Synthesis
and P&R</A><BR><BR>Quick-start guides<BR><A class=link
href="http://www.fpga4fun.com/ISEQuickStart.html">ISE</A><BR><A class=link
href="http://www.fpga4fun.com/QuartusQuickStart.html">Quartus</A><BR><BR>HDL
Tips & Tricks<BR><A class=link
href="http://www.fpga4fun.com/VerilogTips.html">Verilog tips</A><BR><A
class=link href="http://www.fpga4fun.com/VHDLTips.html">VHDL
tips</A><BR><BR>Site<BR><A class=link
href="http://www.fpga4fun.com/WhoAmI.html">Who am I?</A><BR><A class=link
href="http://www.fpga4fun.com/forum">Forum</A><BR><A class=link
href="http://www.fpga4fun.com/shop.html">Shop</A><BR><A class=link
href="http://www.fpga4fun.com/links.html">Links</A><BR></B></FONT><BR><BR></TD>
<TD vAlign=top>
<H4>How to use the Transmitter and Receiver modules </H4>Consider the
following module.<BR>It does two things:
<OL>
<LI>It creates an 8-bits general purpose ("GP") output port, controlled
by any character received on the serial port.
<LI>It creates an 8-bits general purpose input port. The state of the
port is sent back to the PC every time a character is received.
</LI></OL>The GP outputs can be used to control anything remotely from
your PC, might be LEDs on your FPGA board, or a coffee machine with the
help of a relay.<BR><BR>
<TABLE cellPadding=10>
<TBODY>
<TR>
<TD bgColor=#d0d0f0><B>module</B> serialfun(clk, RxD, TxD, GPout,
GPin);<BR><B>input</B> clk;<BR><B>input</B> RxD;<BR><B>output</B>
TxD;<BR><B>output</B> [7:0] GPout;<BR><B>input</B> [7:0]
GPin;<BR><BR><B>wire</B> RxD_data_ready;<BR><B>wire</B> [7:0]
RxD_data;<BR><B>async_receiver</B> deserializer(.clk(clk),
.RxD(RxD), .RxD_data_ready(RxD_data_ready),
.RxD_data(RxD_data));<BR><BR><B>reg</B> [7:0]
GPout;<BR><B>always</B> @(<B>posedge</B> clk)
<B>if</B>(RxD_data_ready) GPout <=
RxD_data;<BR><BR>///////////////////////////////////////////////////<BR><B>reg</B>
[7:0] GPin_reg;<BR><B>wire</B> TxD_busy;<BR><B>always</B>
@(<B>posedge</B> clk) <B>if</B>(RxD_data_ready & ~TxD_busy)
GPin_reg <= GPin;<BR><BR><B>async_transmitter</B>
serializer(.clk(clk), .TxD(TxD), .TxD_start(RxD_data_ready &
~TxD_busy), .TxD_data(GPin_reg),
.TxD_busy(TxD_busy));<BR><BR><B>endmodule</B>
</TD></TR></TBODY></TABLE><BR>Remember to grab the async_receiver and
async_transmitter modules <A
href="http://www.fpga4fun.com/files/async.zip">here</A>, and to update the
clock values inside.<BR><BR>Have fun! <BR><BR><BR><BR>
<HR>
This page was last updated on June 20
2004.<BR><BR></TD></TR></TBODY></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -