基于FPGA的HDB3码的编译码器与译码器设计(软件设计)(5)

2019-04-01 16:42

基于FP GA的HDB3码的编码器与译码器设计(软件设计)

Plusvreg1<=’0’ & plusvreg1(3 downto 1);

End if; End if; End process; ---插“V”输出进程 Process(clk) Begin

If clk’event and clk=’1’ then

Plusvout<=plusvregh(0) & plusvreg1(0); End if; End process; End behave;

仿真结果图

图3.3插“V”符号仿真波形图

在上图3.3中可以看出,当datain为0且datain出现4个连续的“0”时,plusvout信号为“10”代表“V”,HDB3编码的插“V”操作得到验证,否则,当datain为“1”时,plusvout信号为“01”,当datain为“0”时,plusvout信号为“00”。 3.3.2插“B”码模块设计及仿真

HDB3编码器的插“B”码就是对HDB3编码器的插“V”码模块的输出信号plusvout进行判决,如果相邻的两个“V”码之间的“1”的个数为偶数个,则把最后一个“V”码前的第1个0变换成一个“B”码;否则保持plusvout的码型不变。由于码元“B”相对于“V”是过去的信息,因此,必须对当前码元进行存储,使用FPGA中的移位寄存器来实现,定义2个五位寄存器,寄存器从高往低移位,如果寄存器的第4位判断出需要进行插“B”码时,同时改变寄存器的第1位的值,达到以现在的情况改变过去的值。码元“B”用“11”表示。图3.4为插“B”模块连接图。

17

基于FP GA的HDB3码的编码器与译码器设计(软件设计)

图3.4插“B”模块连接图

以下给出添加符号“B”模块的源程序代码

Library ieee;

Use ieee.std_logic_1164.all; Use ieee.std_logic_unsigned.all; Entity hdb3plusb is

Port(clk : in std_logic; ---系统时钟输入

Plusvin : in std_logic_vector(1 downto 0);---插“V”信号输入 Plusbout : out

std_logic_vector(1 downto 0);---插“B”信号输入 End hdb3plusb;

Architecture behave of hdb3plusb is Signal parity : std_logic;

Signal startflag : std_logic_vector(2 downto 0); Signal hdb3plusbregh : std_logic_vector(4 downto 0); Signal hdb3plusbreg1 : std_logic_vector(4 downto 0); Begin

---对两个连续“V”之间的非“0”符号进行奇偶判断

---parity为“0”表示两个连续“V”之间的非“0”符号位偶数个,需要进行插“V”操作

--- parity为“1”表示两个连续“V”之间的非“0”符号位奇数个,不需要进行插“V”操作 Process(clk) Begin

18

基于FP GA的HDB3码的编码器与译码器设计(软件设计)

If clk’event and clk=’1’ then If plusvin=”10” then Parity<=’0’;

Elsif plusvin=”01” then Parity<=not parity; End if; End if; End process;

---当两个连续“V”之间的非“0”符号为偶数个,进行插“B”操作 ---符号“B”由“11”来表示 Process(clk) Begin

If clk’event and clk=’1’ then

If(plusvin=”10”) and (parity=’0’) then; Hdb3plusbregh(4)<=’1’;

Hdb3plusbregh(3)<= hdb3plusbregh(4) Hdb3plusbregh(2)<= hdb3plusbregh(3)

Hdb3plusbregh(1)<=’1’;---如果需要插“B”,则改变去过第1位的值 Hdb3plusbregh(0)<= hdb3plusbregh(1) Hdb3plusbreg1(4)<=’0’;

Hdb3plusbreg1(3)<= hdb3plusbreg1(4); Hdb3plusbreg1(2)<= hdb3plusbreg1(3);

Hdb3plusbreg1(1)<=’1’;---如果需要插“B”,则改变去过第1位的值 Hdb3plusbreg1(0)<= hdb3plusbreg1(1); Else

Hdb3plusbregh<=plusvin(1) & hdb3plusbregh(4 downto 1); Hdb3plusbregl<=plusvin(0) & hdb3plusbregl(4 downto 1); End if; End if; End process;

19

基于FP GA的HDB3码的编码器与译码器设计(软件设计)

Process(clk) Begin

If clk’event and clk=’1’ then Plusbout(1)<=hdb3plusbregh(0); Plusbout(0)<=hdb3plusbregl(0); End if; End process; End process; 仿真结果图

图3.5插B符号仿真波形图

由图3.5波形图中可以看出,当两个连续的“V”之间的非“0”符号为偶数个,进行插“B”的操作,“B”用11表示,插“B”操作得到验证。 3.3.3 HDB3编码器的极性转换模块设计及仿真

HDB3编码输出的“1”码和“V”码具有正负交替的特性,但FPGA的输出引脚只能输出正电平,没有负电平,因此必须将前面插“B”码后的信号plusbout进行极性转换才能得到真正的HDB3信号。这就需要两路信号来表示,一路表示整电平,一路表示负电平。然后根据HDB3编码规则,把插“B”模块输出的信号,转化为正/负电平的两路信号,当插“B”模块输出的“01”信号,正/负电平信号交替出现高电平,当插“B”模块输出的“10”信号,高电平出现原来的高电平信号上,当插“B”模块输出的“11”信号与当插“B”模块输出的“01”信号情况相同。

20

基于FP GA的HDB3码的编码器与译码器设计(软件设计)

图3.6 HDB3双单极性转化模块连接图

以下是实现单双极性变换控制功能的源程序代码

Library ieee;

Use ieee.std_logic_1164.all; Use ieee.std_logic_unsigned.all; Entity hdb3poled2s is Port(clk : in std_logic;

Plusbin : in std_logic_vector(1 downt0 0); Plusout : out std_logic; Minusout : out std_logic)

End hdb3poled2s;

Architecture behave of hdb3poled2s is Signal parity :std_logic;

Signal com : std_logic_vector(2 downto 0); Begin

Com<=plusbin & parity; Process(clk) Begin

If clk’event and clk=’1’ then Case com is When “011”=> Plusout<=’0’; Minusout<=’1’;

Parity<=not parity;---出现“01”时,下次正/负电平信号发生交替

21


基于FPGA的HDB3码的编译码器与译码器设计(软件设计)(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:计量经济学主要复习范围

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: