chk.txt
来自「本程序实现了一个序列检测器。当一串待检测的串行数据进入检测器后」· 文本 代码 · 共 41 行
TXT
41 行
library ieee;
use ieee,std_logic_1164.all;
entity chk is
port(din:in std_logic;
clk,clr:in std_logic;
d:in std_logic_vector(7 downto 0);
ab:out std_logic_vector(3 downto 0));
end chk;
architecture behav of chk is
signal q:integer range 0 to 8;
begin
process(clk,clr)
begin
if clr='1' then q<=0;
else clk'event and clk='1' then
case q is
when 0=> if din=d(7) then q<=1;else q<=0;end if;
when 1=> if din=d(6) then q<=2;else q<=0;end if;
when 2=> if din=d(5) then q<=3;else q<=0;end if ;
when 3=> if din=d(4) then q<=4;else q<=0;end if;
when 4=> if din=d(3) then q<=5;else q<=0;end if;
when 5=> if din=d(2) then q<=6;else q<=0;end if;
when 6=> if din=d(1) then q<=7;else q<=0;end if;
when 7=> if din=d(0) then q<=8;else q<=0;end if;
when others=> q<=0;
end case;
end if;
end process;
process(q)
begin
if q=8 then ab<= "1010";
else ab<= "1011";
end if;
end process;
end behav;
硬件逻辑验证操作方法:待检测串行序列数输入DIN接PIO10(左移,最高位在前),清零信号CLR接PIO8,工作时钟CLK接PIO9,预置8位密码D[7...0]接PIO7~PIO0,指示输出ab[3...0]接PIO43~PIO40(显示于数码管7)。下载文件后,操作步骤是:
(1) 选择实验电路结构图NO.8,按实验板“系统复位”键;
(2) 用键2和键1输入2位十六进制待测序列数;
(3) 利用键4和键3输入2位十六进制预置码;
(4) 按键8,高电平初始化清零,低电平清零结束(平时数码7应显“B”);
(5) 按键6(CLK)8次,这时若串行输入的8位二进制序列码与预置码相同,则数码7应从原来的“B”变成“A”,表示序列检测正确,否则仍为“B”。
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?