--/******************************************************************************
-- ** 功能描述:串口通信__FPGA和上位机通信(波特率:9600bps,10个bit是1位起始位,8个数据位,1个结束)
-- 字符串(串口调试工具设成字符格式接受和发送方式),FPGA接受(0到9和A到F)后显示在7段数码管上。
--*******************************************************************************/
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
entity uart_seg is
port(
clk:in std_logic;--50M时钟输入
rst:in std_logic;--复位信号输入
rxd:in std_logic;--串行数据接收端
txd:out std_logic;--串行数据发送端
en:out std_logic_vector(7 downto 0);--数码管使能
seg_data:out std_logic_vector(7 downto 0)--数码管数据
);
end uart_seg;
architecture behave of uart_seg is
--/*****************************/
signal div_reg:integer range 0 to 326 ; --分频计数器,分频值由波特率决定。分频后得到频率8倍波特率的时钟
signal div8_rec_reg:std_logic_vector(2 downto 0); --该寄存器的计数值对应接收时当前位于的时隙数
signal state_rec:std_logic_vector(3 downto 0); --接受状态寄存器
signal clkbaud_rec:st