?? 新建 文本文檔.txt
字號:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity HS_UJDM is
Port (clk : in std_logic; --系統(tǒng)時鐘
Start : in std_logic; --始能信號
dat : in std_logic_vector(15 downto 0); --二進(jìn)制數(shù)據(jù)輸入端
NRZ : out std_logic; --非歸零信號輸出端
DRZ : out std_logic; --單極性歸零信號輸出端
SRZ : out std_logic_vector(1 downto 0); --雙極性歸零信號輸出端
AMI : out std_logic_vector(1 downto 0); --交替極性信號輸出端
CFM : out std_logic; --差分信號輸出端
CMI : out std_logic; --編碼信號反轉(zhuǎn)碼信號輸出端
FXM : out std_logic); --分相碼(曼徹斯特碼)信號輸出端
end HS_UJDM;
architecture Behavioral of HS_UJDM is
begin
process(clk,start)
variable latch_dat : std_logic_vector(15 downto 0); --十六位二進(jìn)制信號鎖存器
variable latch_sig : std_logic; --高位信號鎖存器
variable latch_cfm : std_logic; --差分碼信號寄存器
variable latch_cnt : std_logic; --基帶碼同步信號
variable count_fri : integer range 0 to 8; --分頻計數(shù)器(碼寬定義)
variable count_mov : integer range 0 to 16; --移位計數(shù)器
begin
if start='0' then latch_cnt:='0'; --異步復(fù)位
latch_cfm:='0'; latch_sig:='0';
count_fri:=7;count_mov:=16; --異步置位
latch_dat:="0000000000000000";
elsif rising_edge(clk) then count_fri:=count_fri+1; --分頻計數(shù)器+1
if count_fri=8 then count_fri:=0; --計數(shù)到8
if count_mov<16 then count_mov:=count_mov+1; --移位計數(shù)器+1
latch_sig:=latch_dat(15); --二進(jìn)制碼高位移入latch_sig中
latch_dat:=latch_dat(14 downto 0)&'0'; --二進(jìn)制數(shù)據(jù)向高位移動一位,低位補零
else latch_dat:=dat;count_mov:=0; --載入下一輪將發(fā)送的數(shù)據(jù)
latch_cfm:='0';latch_sig:='0';latch_cnt:='0'; --寄存器復(fù)位
end if;
if latch_sig='1' then latch_cfm:=not(latch_cfm); --差分碼信號寄存器中信號取反
end if;
end if;
if count_fri<4 then latch_cnt:='1'; --基帶碼同步信號的占空比調(diào)節(jié)
else latch_cnt:='0';
end if;
end if;
--碼形轉(zhuǎn)換部分
NRZ<=latch_sig; --非歸零碼信號
DRZ<=latch_sig and latch_cnt; --單極性歸零碼信號
SRZ(0)<=latch_cnt; --雙極性歸零碼信號
SRZ(1)<=not(latch_sig); --SRZ(1)=‘1’表示負(fù)極性
AMI(0)<=latch_sig and latch_cnt; --極性交替碼信號
AMI(1)<=not(latch_cfm); --AMI(1)=‘1’表示負(fù)極性
CFM<=latch_cfm; --差分碼信號
FXM<=latch_cnt xnor latch_sig; --分相碼信號
if latch_sig='1' then CMI<=latch_cfm; --編碼信號反轉(zhuǎn)碼
else CMI<=not(latch_cnt);
end if;
end process;
end Behavioral;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -