when others=>D<=null; end case; end if; end process; clkout<=clkin; end behavior;
仿真图:
5.3 HDB3编码器程序与仿真图
--HDB3编码
--输入2.048Mb/s数据流,占空比为50%的2.048MHZ的去取样时钟
--输出为两路双极性2.048Mb/s数据流,占空比为50%的2.048MHZ的去取样时钟 library ieee;
use ieee.std_logic_1164.all; use ieee.numeric_std; use ieee.std_logic_arith; entity hdbnecode is port(clkin:in std_logic; datain:in std_logic; dataouthh:out std_logic; dataouthl:out std_logic; clkout:out std_logic); end hdbnecode;
architecture behavior of hdbnecode is
begin
process(clkin)
variable count0,count1:integer:=0 ; variable county:boolean;
20
variable temp:std_logic_vector(3 downto 0); begin
if clkin'event and clkin='0' then
if datain='1' then--输入为1时处理4位寄存器 count0:=0; temp(0):=datain; count1:=count1+1; if temp(3)='0' then--首位0 处理 输出 dataouthh<='0'; dataouthl<='0'; else if county then--首位1处理 输出 dataouthh<='1'; dataouthl<='0'; county:=not county; else dataouthh<='0'; dataouthl<='1'; county:=not county; end if; end if; else temp(0):=datain;--输入为0时处理4位寄存器 count0:=count0+1; if count0=4 then--检测到0000,处理 4位寄存器 count0:=0; count1:=(count1 rem 2);--两个四连零 间 1 的 if count1=1 then--两个四连零 间 1 的 奇偶 count1:=0; temp:=\ dataouthh<='0'; dataouthl<='0'; county:=not county; else count1:=0; --两个四连零 间 1 的 偶 temp:=\ if county then dataouthh<='1'; dataouthl<='0'; else dataouthh<='0'; dataouthl<='1';
21
奇偶 end if; end if; else if temp(3)='0' then--未检测到0000 处理输出 dataouthh<='0'; dataouthl<='0'; else if county then dataouthh<='1'; dataouthl<='0'; county:=not county; else dataouthh<='0'; dataouthl<='1'; county:=not county; end if; end if; end if; end if; end if;
temp(3 downto 1):= temp(2 downto 0); end process; clkout<=clkin; end behavior;
仿真图:
5.4 HDB3译码器程序与仿真图
--输入为两路双极性2.048Mb/s数据流,占空比为50%的2.048MHZ的去取样时钟 --输出为一路单极性2.048Mb/s数据流,占空比为50%的2.048MHZ的去取样时钟 library ieee;
use ieee.std_logic_1164.all; entity hdbdecode is port(
clkin:in std_logic;
22
datainhh:in std_logic; datainhl:in std_logic; dataout:out std_logic; clkout:out std_logic); end hdbdecode;
architecture behavior of hdbdecode is
signal hh,hl:std_logic_vector(4 downto 0); signal temp:std_logic; begin
AHH:process(clkin)
variable temphh:std_logic_vector(4 downto 0); begin
if clkin'event and clkin='0' then temphh(0):=datainhh; if temphh=\ temphh:=\
elsif (temphh=\ temphh:=\ end if; end if;
hh<=temphh;
temphh(4 downto 1):=temphh(3 downto 0); end process;
AHL:process(clkin)
variable temphl:std_logic_vector(4 downto 0); begin
if clkin'event and clkin='0' then temphl(0):=datainhl; if temphl=\ temphl:=\
elsif (temphl=\ temphl:=\ end if; end if;
hl<=temphl;
temphl(4 downto 1):=temphl(3 downto 0); end process;
emp<=(hh(4)or hl(4)); dataout<=temp; clkout<=clkin; end behavior;
23
仿真图:
5.5 一次群复接器程序与仿真图
--时分复接器
--输入一个8位数据总线(即30路PCM话音并行数据共用总线), --输入一个一次群串行位同步时钟2.048MB/S信号
--输出一个一次群串行合路数据流2.048MB/S信号;一个一次群串行位同步时钟2.048MB/S信号
--一个5位时隙地址总线信号(即30路PCM话音并行地址总线) --(其说明当前输入的数据总线上是哪个时隙数据) --此程序要特别注意器件的选择,该程序选择cyclone系列EP1C6Q240C8时得到所期望的结果
--若选用其他器件譬如Stratix II系列的器件会丢失第一路信息
library ieee;--程序所调用的库是IEEE库
use ieee.std_logic_1164.all;--定义了std_logic,std_logic_vector类型
use ieee.std_logic_unsigned.all;--用到基于std_logic,std_logic_vector类型的 --无符号的算术运算 entity fujieqi is
port (clkin: in std_logic;
datain: in std_logic_vector(7 downto 0);--30路语音信号输入 dataout:out std_logic; --输出串行数据流 ads:out std_logic_vector(4 downto 0);--五位时隙总线信号 clkout:out std_logic);--输出时钟 end fujieqi;
architecture behav of fujieqi is
shared variable tscount:std_logic_vector(8 downto 0);--时隙计数器 shared variable bitcount:std_logic_vector(2 downto 0);--位计数器 begin
p1:process(clkin)--位时钟和时隙计数 begin
if clkin'event and clkin='1' then if bitcount=\ bitcount:=\
24
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库通信原理课程设计 基于FPGA的时分多路数字基带传输系统的设(5)在线全文阅读。
相关推荐: