📄 encode1.vhd
字号:
-------------------------------------------------------------
--Copyright (C), 2004- , Huangwei. --
--File name:encode1(编码器) --
--Author:huangwei Version:1.0 Date:2004/11/24 --
--Description: --
--该程序主要完成的功能是识别数据流中的4连零破坏点; --
-------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity encode1 is
port(
clk:in std_logic; --输入时钟
datain:in std_logic; --数据流输入
reset:in std_logic; --复位
dataout:out std_logic; --数据输出
countout : out integer range 0 to 4 --破坏点位置记录输出
);
end encode1;
architecture encode1_arc of encode1 is
signal buff:std_logic_vector(3 downto 0); --数据移位寄存器
signal outbuff :std_logic; --输出数据寄存器
constant max:integer := 4; --计数器最大值
signal count:integer range 0 to 4; --计数寄存器
begin
process(reset,clk,buff,count)
begin
if (reset = '1') then
buff <= "1111";
elsif rising_edge(clk) then
buff <= buff(2 downto 0) & datain; --将数据存入移位寄存器
outbuff <= buff(3); --数据输出
dataout <= outbuff;
countout <= count; --计数寄存器数据输出
if (buff = "0000" ) then --发现破坏点,开始计数
if (count < max) then --首次发现的计数方式
count <= count + 1;
else --连续破坏的计数
count <= 1;
end if;
else --未发现破坏点,或破坏点结束
if ((count = 0) or (count >= max)) then --没有破坏点
count <=0;
else --破坏点未结束
count <= count + 1;
end if;
end if;
end if;
end process;
end encode1_arc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -