加 V 模块代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;------------调用的库
entity hdb3plusv is-------------------实体声明
port(clk : in std_logic;
datain : in std_logic;
plusvout : out std_logic_vector(1 downto 0));
end hdb3plusv;
architecture behave of hdb3plusv is
signal plusvregh : std_logic_vector(3 downto 0);
signal plusvregl : std_logic_vector(3 downto 0);
signal dataregn : std_logic_vector(2 downto 0);----------内部信号声明
begin
process(clk)-------将输入代码放入寄存器
begin
if clk'event and clk = '1' then
if datain = '1' then
dataregn <= '0' & dataregn(2 downto 1);
else
dataregn <= '1' & dataregn(2 downto 1);
end if;
end if;
end process;
process(clk)--------完成加 V 功能
begin
if clk'event and clk = '1' then
if (datain = '0') and (dataregn = "111") and (plusvregh(3 downto 1) = "000") then
plusvregh <= '1' & plusvregh(3 downto 1);
plusvregl <= '0' & plusvregl(3 downto 1);
elsif datain = '1' then
plusvregh <= '0' & plusvregh(3 downto 1);
plusvregl <= '1' & plusvregl(3 downto 1);