?? uart_package.vhd
字號:
-- 庫聲明library IEEE;use IEEE.STD_LOGIC_1164.all; -- 包聲明PACKAGE UART_PACKAGE IS -- 信號監測器狀態type dt_state is (dt_unlock, -- 未鎖定狀態dt_lock -- 鎖定狀態); -- UART狀態type UART_STATE is( UART_IDLE,UART_LOAD,UART_SEND, UART_END_SEND,UART_RECV,UART_END_RECV);-- 計數器計數范圍type BD_COUNT is range 65535 downto 0;-- 9600波特率對應參數constant BD9600_FPC : BD_COUNT := 5208;constant BD9600_HPC : BD_COUNT := 2604;-- 波特率測試參數constant BDTEST_FPC : BD_COUNT := 10;constant BDTEST_HPC : BD_COUNT := 5;-- 奇偶校驗規則定義type PARITY is(NONE, -- 無奇偶校驗ODD, -- 奇校驗EVEN -- 偶校驗);-- 類型聲明type test_vectors is array (0 to 10) of std_logic;-- 無奇偶校驗測試序列constant test_si_none : test_vectors := ('0', '1', '0', '1', '0', '1', '0', '1', '0', others => '1');-- 奇校驗測試序列constant test_si_odd : test_vectors := ('0', '1', '0', '1', '0', '1', '1', '1', '0', '1', others => '1');-- 偶校驗測試序列constant test_si_even : test_vectors := ('0', '1', '0', '1', '0', '1', '0', '1', '0', '1', others => '1');-- 函數聲明function MultiXOR( din : in std_logic_vector ) return std_logic;END UART_PACKAGE;-- 包體PACKAGE BODY UART_PACKAGE IS-- 函數實現function MultiXOR( din : in std_logic_vector ) return std_logic is variable check : std_logic;begin check := din(din'LOW); for i in 1 to (din'HIGH) loop check := check xor din(i); end loop; return check;end MultiXOR;END UART_PACKAGE;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -