⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baud.vhd

📁 这个是UART的控制器
💻 VHD
字号:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE	IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;	
ENTITY baud IS
	GENERIC
		(
			XTAL_CLK	:	integer := 50000000;	--12M main clock crystal 
			BAUD		:	integer	:= 9600;		--serial port communcation baud
			cw			:	integer := 11			--store the count frequent division 
		);
	PORT
	(
		clk		: IN	STD_LOGIC;
		reset_n	: IN	STD_LOGIC;
		bclk	: OUT	STD_LOGIC
	);
END baud;
ARCHITECTURE behave OF baud IS
	constant 	CLK_DIV_coef :	integer := XTAL_CLK/(BAUD*16*2);  --count the number of main clock or direct number!!
	SIGNAL 		clk_div	: STD_LOGIC_VECTOR(cw-1 downto 0);
	SIGNAL 		bclk_t  : STD_LOGIC;
BEGIN
PROCESS (clk,reset_n)
BEGIN
	if (reset_n = '0') then
		clk_div <= (others=>'0');
		bclk_t <= '0';
	elsif rising_edge(clk) then
		if(clk_div = (clk_div_coef -1)) then --this value can be modified to change frequence
			clk_div <= (others =>'0');
			bclk_t <= not bclk_t;
		else
			clk_div <= clk_div +1;
		end if;	
	end if;
END PROCESS ;
	bclk <= bclk_t;
END behave;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -