EDA实验七八程序及仿真波形

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1.8位序列信号检测器

LIBRARY IEEE ;

USE IEEE.STD_LOGIC_1164.ALL;

ENTITY SCHK IS

PORT(DIN, CLK, CLR : IN STD_LOGIC;

AB : OUT STD_LOGIC_VECTOR(3 DOWNTO 0));

END SCHK;

ARCHITECTURE behav OF SCHK IS

SIGNAL Q : INTEGER RANGE 0 TO 8 ;

SIGNAL D : STD_LOGIC_VECTOR(7 DOWNTO 0);

BEGIN

D <="11100101";

PROCESS( CLK, CLR )

BEGIN

IF CLR ='1' THEN Q <= 0 ;

ELSIF 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 ;

仿真波形

2.可预置的8位序列信号检测器

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL;

USE IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY SCHK2 IS

PORT (DIN,CLK,CLR: IN STD_LOGIC;

SHR: IN STD_LOGIC_VECTOR(7 DOWNTO 0);

AB : OUT STD_LOGIC_VECTOR(3 DOWNTO 0));

END ENTITY SCHK2;

ARCHITECTURE behav OF SCHK2 IS

SIGNAL Q : INTEGER RANGE 0 TO 8;

SIGNAL D : STD_LOGIC_VECTOR(7 DOWNTO 0);

BEGIN

D<=SHR;

PROCESS(CLK,CLR)

BEGIN

IF CLR='1' THEN Q<=0;

ELSIF 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 ARCHITECTURE behav;

仿真波形

正弦信号发生器的顶层设计程序

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL;

USE IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY SINGT IS

PORT ( CLK : IN STD_LOGIC;

DOUT : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) );

END;

ARCHITECTURE DACC OF SINGT IS

COMPONENT data_rom

PORT(address : IN STD_LOGIC_VECTOR (5 DOWNTO 0);

inclock : IN STD_LOGIC ;

q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) );

END COMPONENT;

SIGNAL Q1 : STD_LOGIC_VECTOR (5 DOWNTO 0);

BEGIN

PROCESS(CLK )

BEGIN

IF CLK'EVENT AND CLK = '1' THEN

Q1<=Q1+1;

END IF;

END PROCESS;

u1 : data_rom PORT MAP(address=>Q1, q => DOUT,inclock=>CLK); END;

仿真波形

相关文档
最新文档