求大神帮忙改下HDB3编译码程序testbench文件激励部分
附HDB3编码程序:
--HDB3编码
--输入2.048Mb/s数据流
--占空比为50%的取样时钟
--输出为两路双极性数据流
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std;
use ieee.std_logic_arith;
entity HDB3 is
port(clkin:in std_logic;
datain:in std_logic;
dataouthh:outstd_logic;
dataouthl:out std_logic;
clkout:outstd_logic);
end HDB3;
architecture behavior of HDB3 is
begin
process(clkin)
variable count0,count1,count2:integer:=0 ;
variable county:boolean;
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)OR(count2=0) then--两个四连零 间 1 的 奇偶
count1:=0;
count2:=1;
temp:="0001";
dataouthh<='0';
dataouthl<='0';
county:=notcounty;
else
count1:=0; --两个四连零 间 1 的 偶
temp:="1001";
if county then
dataouthh<='1';
dataouthl<='0';
else
dataouthh<='0';
dataouthl<='1';
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;
看过RTL电路,输入只有clkin和datain。clkin是占空比50%的取样信号,datain是输入的要编码的信息流。求大神帮忙修改下测试文件里这两个激励部分的程序,谢谢~
奖励5积分