HDB3编码器的设计.docx
《HDB3编码器的设计.docx》由会员分享,可在线阅读,更多相关《HDB3编码器的设计.docx(13页珍藏版)》请在冰点文库上搜索。
![HDB3编码器的设计.docx](https://file1.bingdoc.com/fileroot1/2023-5/15/c0e284d3-5fc9-43a8-9f17-5742328bbed2/c0e284d3-5fc9-43a8-9f17-5742328bbed21.gif)
HDB3编码器的设计
通信原理课程设计报告
HDB3编码器的设计
班级:
通信05-2班
*******
学号:
15号
*******
设计日期:
2007年11月26日至2007年11月30日
第一章HDB3码概述及产生背景
现代通信借助于电和光来传输信息,数字终端产生的数字信息是以“1”和“0”两种状态位代表的随机序列,他可以用不同形式的电信号表示,以构造不同形式的数字信号。
在一般的数字通信系统中首先将消息变为数字基带信号,称为信源编码,经过调制后进行传输,在接收端先进行解调恢复为基带信号,再进行解码转换为消息。
HDB3码是AMI码的改进型,HDB3码又叫三阶高密度双极性码,是基带电信设备之间进行基带传输的主要码型之一。
该码具有以下特点:
(1) 无直流分量,功率谱密度与AMI码类似。
(2) 解决了AMI码长连‘0’且提取信号的困难的问题。
(3) 具有内在检错能力。
由此可见,HDB3码是一种优良码,目前是广泛应用于基带传输的接口码。
在一般的数字通信系统中首先将消息变为数字基带信号,其次,传输码型中应含有定时时钟信息,以利于收端定时时钟的提取,再次,实际传输系统常希望在不中断通信的前提下,能监视误码,如果传输码型有一定的规律性,那么就可以根据这一规律性来检测传输质量,以便做到自动监测,因此,传输码型应具有一定的误码检测能力。
HDB3码就是具有误码检测能力的一种码。
第2章设计原理及步骤
2.1HDB3编码器的设计原理
2.1.1引言
数字基带信号的传输是数字通信系统的重要组成部分。
在数字通信中,有些场合可不经过载波调制和解调过程,而对基带信号进行直接传输。
采用AMI码的信号交替反转,有可能出现四连零现象,这不利于接收端的定时信号提取。
而HDB3码因其无直流成份、低频成份少和连0个数最多不超过三个等特点,而对定时信号的恢复十分有利。
针对数字基带传输系统中HDB3信号的特点,采用基于CPLD/FPGA的VHDL语言,在Max+plusⅡ的环境中,实现HDB3数字基带信号的调制、解调器.仿真结果表明,实现的HDB3基带信号调解器,系统简单、可靠,通过此系统能够方便地将原始信息流转换成HDB3基带信号。
2.1.2HDB3码的编码规则:
1.将消息代码变换成AMI码。
2.检查AMI码中是否有连0情况,当有四个或四个以上连0时,将1后的第四个1变成V。
3.当相邻俩个V间有偶数个1时将第一个零变成B,若为奇数则不变;1和B与前一个不为0符号相反,V与前一个不为0符号相同。
2.1.3HDB3码的译码规则:
HDB3码的译码是编码的逆过程。
由编码原理可知,每一个破坏符号V总是与前一个非0符号同极性,因此,从收到的HDB3码序列中容易识别V符号,同时也肯定V符号及其前面的3个符号必是连0符号,于是可恢复成四个连0码然后再将所有的-1变成+1后便得到原消息代码。
2.2建模思想
本设计没有像其他设计那样将插V补B分开实现,而是通过变量的设置将两个功能一起实行。
首先判断前面已存在非0符号的极性,用以判断后面非0符号的极性。
同时通过变量flag的状态判断前面是否已经插V,若已经插V则再通过变量H的状态判断两个V之间的非0符号的个数,为偶数且后面连续输入4个以上连0时则插B,为奇数时则不插B。
若尚未插V则不补B。
插V和插B的功能由两个3位移位寄存器的强制输出实现,当不需要插V和B的时候则移位寄存器顺序输出。
本设计在实现过程中将插入的V和B根据需要直接由+1和-1表示,省去了其他程序中先插入V和B然后再判断极性的过程。
输出部分由两路表示,当aout和bout分别为0和1时表示输出-1,为1和0时表示输出+1,为0和0时表示输出0。
将基于VHDL的HDB3编码用在光纤通信系统中作为误码仪测试误码的HDB3转换器,能满足实际测试的需要。
且运用基于VHDL的可编程芯片开发技术将相关的信号处理电路进行硬件描述,并用CPLD/FPGA技术实现数字通信系统,不仅可以实现多种数字逻辑功能,而且可大大提高工作效率,减少电路设计的时间和可能发生的错误,同时也可降低开发成本。
HDB3码编码器模型如图所示:
图1:
HDB3编码器模型
2.3设计步骤
1.编写程序。
2.在Max+plusⅡ的环境中进行波形仿真,运行出程序正确,见图2,结果见图3。
3.进行编码程序运行,运行结果见图4。
4.进性译码程序运行,运行结果见图5。
第3章调试分析
此图波形仿真运行结果图,波形的产生程序符合HDB3编码器的编码规则,HDB3码的编码规则如下:
1.将消息代码变换成AMI码;
2.检查AMI码中是否有连0情况,当有四个或四个以上连0时,将1后的第四个0变成V.
3.当相邻俩个V间有偶数个1时将第一个0变成B,若为奇数则不变;1和B与前一个不为0符号相反,V与前一个不为0符号相同。
运行所需的程序正确,从而得到正确的运行结果图。
图
2图2:
运行结果图
第4章结果分析与体会
通过对VHDL源程序进行编译、适配、优化、逻辑综合与仿真。
仿真结果显示其完全可以达到编码要求。
其仿真图如图3所示。
图3:
波形仿真结果
系统加入调制部分后的仿真结果如下图4所示。
其中indata为调制器的输入信号,DATAOUT为解调输出,outa2和outb2为DATAOUT的HDB3编码结果。
OUTCLK为最后的输出时钟。
图4:
编码器运行仿真结果
系统加入调制部分后的仿真结果如下图5所示。
其中indata为调制器的输入信号,DATAOUT为解调输出,outa2和outb2为DATAOUT的HDB3译码结果。
OUTCLK为最后的输出时钟。
图5:
译码器运行仿真结果
附录:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityhdb3_codingis
port(data_in :
in std_logic;
clock :
in std_logic;
data_out :
outstd_logic_vector(1downto0));
endhdb3_coding;
architecturertlofhdb3_codingis
signalreg :
std_logic_vector(3downto0);
zparity :
std_logic; --记录破坏点间1码个数的奇偶性
signaljudge_v :
std_logic; --判断是否有破坏符
signalgrant_cnt:
std_logic; --允许开始计算破坏点间的1码个数
signallast_sign:
std_logic; --上一输出的符号
signalv_cnt :
std_logic_vector(2downto0); --v点位置跟踪计数器
begin
process(clock) --移位寄存器,插V
begin
ifrising_edge(clock)then
ifdata_in='0'andreg(3downto1)="000"then
reg<=('1'®(3downto1));judge_v<='1';grant_cnt<='1';
elsereg<=data_in®(3downto1);judge_v<='0';grant_cnt<='0';
endif;
endif;
endprocess;
process(clock) --计数
begin
ifrising_edge(clock)then
ifgrant_cnt='1'anddata_in='0'thenparity<='0';
elsifgrant_cnt='1'anddata_in='1'thenparity<='1';
elsifdata_in='1'thenparity<=notparity;
endif;
endif;
endprocess;
process(clock) --V点跟踪
begin
ifrising_edge(clock)then
ifjudge_v='1'thenv_cnt<="000";
elsifv_cnt="111"thenv_cnt<=v_cnt;
elsev_cnt<=v_cnt+1;
endif;
endif;
endprocess;
process(clock) --编码输出
begin
ifrising_edge(clock)then
ifreg(0)='1'then
ifv_cnt<="010"then
iflast_sign='1'thendata_out<="11";
elsedata_out<="01";
endif;
elsiflast_sign='1'thendata_out<="01";last_sign<=notlast_sign;
elsiflast_sign='0'thendata_out<="11";last_sign<=notlast_sign;
endif;
elsifjudge_v='1'andparity='0'then
iflast_sign='1'thendata_out<="01";last_sign<=notlast_sign;
elsedata_out<="11";last_sign<=notlast_sign;
endif;
elsedata_out<="00";
endif;
endif;
endprocess;
endrtl;
------HDB3码编码器
------输出相对于输入延时了五个脉冲周期
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityhdb3_codingis
port(data_in :
in std_logic;
clock :
in std_logic;
data_out :
outstd_logic_vector(1downto0));
endhdb3_coding;
architecturertlofhdb3_codingis
signalreg :
std_logic_vector(3downto0);
signalparity :
std_logic; --记录破坏点间1码个数的奇偶性
signaljudge_v :
std_logic; --判断是否有破坏符
signalgrant_cnt:
std_logic; --允许开始计算破坏点间的1码个数
signallast_sign:
std_logic; --上一输出的符号
signalv_cnt :
std_logic_vector(2downto0);--v点位置跟踪计数器
begin
process(clock) --移位寄存器,插V
begin
ifrising_edge(clock)then
ifdata_in='0'andreg(3downto1)="000"then
reg<=('1'®(3downto1));judge_v<='1';grant_cnt<='1';
elsereg<=data_in®(3downto1);judge_v<='0';grant_cnt<='0';
endif;
endif;
endprocess;
process(clock) --计数
begin
ifgrant_cnt='1'thenparity<='0';
elsifrising_edge(clock)then
ifdata_in='1'thenparity<=notparity;
endif;
endif;
endprocess;
process(clock) --V点跟踪
begin
ifjudge_v='1'thenv_cnt<="000";
elsifrising_edge(clock)then
ifv_cnt="111"thenv_cnt<=v_cnt;
elsev_cnt<=v_cnt+1;
endif;
endif;
endprocess;
process(clock) --编码输出
begin
ifrising_edge(clock)then
ifreg(0)='1'then
ifv_cnt<="011"then0
iflast_sign='1'thendata_out<="11";
elsedata_out<="01";
endif;
elsiflast_sign='1'thendata_out<="01";last_sign<=notlast_sign;
elsiflast_sign='0'thendata_out<="11";last_sign<=notlast_sign;
endif;
elsifjudge_v='1'andparity='0'then
iflast_sign='1'thendata_out<="01";last_sign<=notlast_sign;
elsedata_out<="11";last_sign<=notlast_sign;
endif;
elsedata_out<="00";
endif;
endif;
endprocess;
endrtl;
--------HDB3码译码器
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityhdb3_decodeis
port(data1 :
in std_logic; --高位
data0 :
in std_logic; --低位
clock :
in std_logic;
data_out:
outstd_logic);
endhdb3_decode;
architecturertlofhdb3_decodeis
signalreg0 :
std_logic_vector(4downto0);
signalreg1 :
std_logic_vector(4downto0);
begin
process(clock)
begin
ifrising_edge(clock)then
ifdata0='1'anddata1='0'andreg0(4downto1)="0001"andreg1(4downto1)="0000"then
reg0<="00001";reg1<="00000";
elsifdata0='1'anddata1='1'andreg0(4downto1)="0001"andreg1(4downto1)="0001"then
reg0<="00001";reg1<="00000";
elsifdata0='1'anddata1='1'andreg0(4downto2)="001"andreg1(4downto2)="001"then
reg0<="0000"®0
(1);reg1<="0000"®1
(1);
elsifdata0='1'anddata1='0'andreg0(4downto2)="001"andreg1(4downto2)="000"then
reg0<="0000"®0
(1);reg1<="0000"®1
(1);
elsereg0<=data0®0(4downto1);reg1<=data1®1(4downto1);
endif;
endif;
endprocess;
process(clock)
begin
ifrising_edge(clock)then
ifreg0(0)='1'orreg1(0)='1'thendata_out<='1';
elsedata_out<='0';
endif;
endif;
endprocess;
endrtl;
参考文献
[1]靳刚庄奕琪刘锋.MPEG4编码器二维DCT变换的FPGA实现及优化电路与系统学报,2005,10(4):
131-135.
[2]崔俊杰郭宏.基于FPGA的实时数据采集与远程传输系统设计数据采集与处理,2005,20(3):
366-370.
[3]段吉海黄智伟.基于CPLD/FPGA的数字通信系统的建模与设计北京:
电子工业出版社,2004..
[4]樊昌信张甫翊通信原理国防工业出版社
[5]褚振勇翁木云FPGA设计及应用西安电子科技大学出版社