±ÏÒµÂÛÎÄ£º»ùÓÚFPGAµÄ´®¿ÚÉè¼Æ-¾«Æ· ÏÂÔØ±¾ÎÄ

¸½Â¼

¸½Â¼3 3 Ö÷Òª³ÌÐò £¨1£©Ö÷³ÌÐò

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity top is

port(clk32mhz,reset,rxd,xmit_cmd_p_in:in std_logic; ¡ª×ܵÄÊäÈëÊä³öÐźŵ͍Òå

µÚ47Ò³ £¨¹²37Ò³£©

»ùÓÚFPGAµÄ´®¿ÚÉè¼Æ

rec_ready,txd_out,txd_done_out:out std_logic;

txdbuf_in :in std_logic_vector(7 downto 0); ¡ª´ý·¢ËÍÊý¾ÝÊäÈë rec_buf:out std_logic_vector(7 downto 0)); ¡ª½ÓÊÕÊý¾Ý»º³å end top;

architecture Behavioral of top is component reciever

port(bclkr,resetr,rxdr:in std_logic; r_ready:out std_logic;

rbuf: out std_logic_vector(7 downto 0)); end component; component transfer

port(bclkt,resett,xmit_cmd_p:in std_logic; txdbuf:std_logic_vector(7 downto 0); txd:out std_logic; txd_done:out std_logic); end component; component baud

Port (clk,resetb:in std_logic; bclk:out std_logic); end component; signal b:std_logic; begin

u1:baud port map(clk=>clk32mhz,resetb=>reset,bclk=>b); µÚ 48 Ò³ ¹² 40 Ò³

¡ª¶¥²ãÓ³Éä

¸½Â¼

u2:reciever port map(bclkr=>b,resetr=>reset,rxdr=>rxd,r_ready=>rec_ready, rbuf=>rec_buf);

u3:transfer

port map(bclkt=>b,resett=>reset,xmit_cmd_p=>xmit_cmd_p_in,txdbuf=>txdbuf_in, txd=>txd_out,txd_done=>txd_done_out); end Behavioral ;

£¨2£©²¨ÌØÂÊ·¢ÉúÆ÷Ä£¿é(baud.vhd)

library ieee;

use ieee.std_logic_1164.all; use ieee.numeric_std.all; use ieee.std_logic_unsigned.all; entity last is

port (resetb : in std_logic; clk: in std_logic; bclk: out std_logic); end last;

architecture cc of last is

signal clk_cnt : unsigned(3 downto 0); signal clk_bit : std_logic; begin

process(clk,resetb)

µÚ49Ò³ £¨¹²37Ò³£©

»ùÓÚFPGAµÄ´®¿ÚÉè¼Æ

begin

if(resetb='1') then clk_cnt<=\clk_bit<='0';

elsif rising_edge(clk) then if (clk_cnt=4) then clk_cnt<=\clk_bit<=not clk_bit; else

clk_cnt<= clk_cnt+1; end if; end if; end process; bclk<=clk_bit; end cc;

£¨3£©UART½ÓÊÕÆ÷(receiver.Vhd)

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity reciever is

µÚ 50 Ò³ ¹² 40 Ò³