EDA ppt程序未整理全部的.docx
- 文档编号:12408835
- 上传时间:2023-04-18
- 格式:DOCX
- 页数:36
- 大小:216.34KB
EDA ppt程序未整理全部的.docx
《EDA ppt程序未整理全部的.docx》由会员分享,可在线阅读,更多相关《EDA ppt程序未整理全部的.docx(36页珍藏版)》请在冰豆网上搜索。
EDAppt程序未整理全部的
二选一
mux21aarchitecture
【例3-1】
ENTITYmux21aIS
PORT(a,b:
INBIT;
s:
INBIT;
y:
OUTBIT);
ENDENTITYmux21a;
ARCHITECTUREoneOFmux21aIS
BEGIN
y<=aWHENs='0'ELSEb;
ENDARCHITECTUREone;
【例3-2】
ENTITYmux21aIS
PORT(a,b:
INBIT;
s:
INBIT;
y:
OUTBIT);
ENDENTITYmux21a;
ARCHITECTUREoneOFmux21aIS
SIGNALd,e:
BIT;
BEGIN
d<=aAND(NOTS);
e<=bANDs;
y<=dORe;
ENDARCHITECTUREone;
【例3-3】
ENTITYmux21aIS
PORT(a,b,s:
INBIT;
y:
OUTBIT);
ENDENTITYmux21a;
ARCHITECTUREoneOFmux21aIS
BEGIN
PROCESS(a,b,s)
BEGIN
IFs='0'THEN
y<=a;ELSE
y<=b;
ENDIF;
ENDPROCESS;
ENDARCHITECTUREone;
(ok)例【3-4】D触发器
LIBRARYIEEE;
USEIEEE.STD_LOGIC_1164.ALL;
ENTITYDFF1IS
PORT(CLK:
INSTD_LOGIC;
D:
INSTD_LOGIC;
Q:
OUTSTD_LOGIC);
END;
ARCHITECTUREbhvOFDFF1IS
SIGNALQ1:
STD_LOGIC;--类似于在芯片内部定义一个数据的暂存节点
BEGIN
PROCESS(CLK,Q1)
BEGIN
IFCLK'EVENTANDCLK='1'
THENQ1<=D;
ENDIF;
ENDPROCESS;
Q<=Q1;--将内部的暂存数据向端口输出(双横线--是注释符号)
ENDbhv;
【例3-7】D触发器VHDL描述的语言现象说明
ENTITYCOMP_BADIS
PORT(a1,b1:
INBIT;
q1:
OUTBIT);
END;
ARCHITECTUREoneOFCOMP_BADIS
BEGIN
PROCESS(a1,b1)
BEGIN
IFa1>b1THENq1<='1';
ELSIFa1 ENDIF; ENDPROCESS; END; 【例3-11】实现时序电路的不同表述 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; ENTITYDFF3IS PORT(CLK,D: INSTD_LOGIC; Q: OUTSTD_LOGIC); END; ARCHITECTUREbhvOFDFF3IS SIGNALQ1: STD_LOGIC; BEGIN PROCESS(CLK) BEGIN IFrising_edge(CLK)--必须打开STD_LOGIC_1164程序包 THENQ1<=D; ENDIF; ENDPROCESS; Q<=Q1;--在此,赋值语句可以放在进程外,作为并行赋值语句 END; 【例3-15】异步时序电路设计 ... ARCHITECTUREbhvOFMULTI_DFFIS SIGNALQ1,Q2: STD_LOGIC; BEGIN PRO1: PROCESS(CLK) BEGIN IFCLK'EVENTANDCLK='1' THENQ1<=NOT(Q2ORA); ENDIF; ENDPROCESS; PRO2: PROCESS(Q1) BEGIN IFQ1'EVENTANDQ1='1' THENQ2<=D; ENDIF; ENDPROCESS; QQ<=Q2; ... 3.3.1半加器描述和CASE语句 【例3-16】 LIBRARYIEEE;--半加器描述 (1): 布尔方程描述方法 USEIEEE.STD_LOGIC_1164.ALL; ENTITYh_adderIS PORT(a,b: INSTD_LOGIC; co,so: OUTSTD_LOGIC); ENDENTITYh_adder; ARCHITECTUREfh1OFh_adderis BEGIN so<=NOT(aXOR(NOTb));co<=aANDb; ENDARCHITECTUREfh1; 图3-11全加器f_adder电路图及其实体模块 【例3-17】 LIBRARYIEEE;--半加器描述 (2): 真值表描述方法 USEIEEE.STD_LOGIC_1164.ALL; ENTITYh_adderIS PORT(a,b: INSTD_LOGIC; co,so: OUTSTD_LOGIC); ENDENTITYh_adder; ARCHITECTUREfh1OFh_adderis SIGNALabc: STD_LOGIC_VECTOR(1DOWNTO0);--定义标准逻辑位矢量数据类型 BEGIN abc<=a&b;--a相并b,即a与b并置操作 PROCESS(abc) BEGIN CASEabcIS--类似于真值表的CASE语句 WHEN"00"=>so<='0';co<='0'; WHEN"01"=>so<='1';co<='0'; WHEN"10"=>so<='1';co<='0'; WHEN"11"=>so<='0';co<='1'; WHENOTHERS=>NULL; ENDCASE; ENDPROCESS; ENDARCHITECTUREfh1; 【例3-18】 LIBRARYIEEE;--或门逻辑描述 USEIEEE.STD_LOGIC_1164.ALL; ENTITYor2aIS PORT(a,b: INSTD_LOGIC; c: OUTSTD_LOGIC); ENDENTITYor2a; ARCHITECTUREoneOFor2aIS BEGIN c<=aORb; ENDARCHITECTUREone; 【例3-19】 LIBRARYIEEE;--1位二进制全加器顶层设计描述 USEIEEE.STD_LOGIC_1164.ALL; ENTITYf_adderIS PORT(ain,bin,cin: INSTD_LOGIC; cout,sum: OUTSTD_LOGIC); ENDENTITYf_adder; ARCHITECTUREfd1OFf_adderIS COMPONENTh_adder--调用半加器声明语句 PORT(a,b: INSTD_LOGIC; co,so: OUTSTD_LOGIC); ENDCOMPONENT; COMPONENTor2a PORT(a,b: INSTD_LOGIC; c: OUTSTD_LOGIC); ENDCOMPONENT; SIGNALd,e,f: STD_LOGIC;--定义3个信号作为内部的连接线。 BEGIN u1: h_adderPORTMAP(a=>ain,b=>bin,co=>d,so=>e);--例化语句 u2: h_adderPORTMAP(a=>e,b=>cin,co=>f,so=>sum); u3: or2aPORTMAP(a=>d,b=>f,c=>cout); ENDARCHITECTUREfd1; 【例3-20】计数器设计 ENTITYCNT4IS PORT(CLK: INBIT; Q: BUFFERINTEGERRANGE15DOWNTO0); END; ARCHITECTUREbhvOFCNT4IS BEGIN PROCESS(CLK) BEGIN IFCLK'EVENTANDCLK='1'THEN Q<=Q+1; ENDIF; ENDPROCESS; ENDbhv; 【例3-21】计数器设计的另一种表述 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; USEIEEE.STD_LOGIC_UNSIGNED.ALL; ENTITYCNT4IS PORT(CLK: INSTD_LOGIC; Q: OUTSTD_LOGIC_VECTOR(3DOWNTO0)); END; ARCHITECTUREbhvOFCNT4IS SIGNALQ1: STD_LOGIC_VECTOR(3DOWNTO0); BEGIN PROCESS(CLK) BEGIN IFCLK'EVENTANDCLK='1'THEN Q1<=Q1+1; ENDIF; ENDPROCESS; Q<=Q1; ENDbhv; 【例3-22】一般加法计数器设计 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; USEIEEE.STD_LOGIC_UNSIGNED.ALL; ENTITYCNT10IS PORT(CLK,RST,EN: INSTD_LOGIC; CQ: OUTSTD_LOGIC_VECTOR(3DOWNTO0); COUT: OUTSTD_LOGIC); ENDCNT10; ARCHITECTUREbehavOFCNT10IS BEGIN PROCESS(CLK,RST,EN) VARIABLECQI: STD_LOGIC_VECTOR(3DOWNTO0); BEGIN IFRST='1'THENCQI: =(OTHERS=>'0');--计数器异步复位 ELSIFCLK'EVENTANDCLK='1'THEN--检测时钟上升沿 IFEN='1'THEN--检测是否允许计数(同步使能) IFCQI<9THENCQI: =CQI+1;--允许计数,检测是否小于9 ELSECQI: =(OTHERS=>'0');--大于9,计数值清零 ENDIF; ENDIF; ENDIF; IFCQI=9THENCOUT<='1';--计数大于9,输出进位信号 ELSECOUT<='0'; ENDIF; CQ<=CQI;--将计数值向端口输出 ENDPROCESS; ENDbehav; 【例3-23】含并行置位的移位寄存器设计 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; ENTITYSHFRTIS--8位右移寄存器 PORT(CLK,LOAD: INSTD_LOGIC; DIN: INSTD_LOGIC_VECTOR(7DOWNTO0); QB: OUTSTD_LOGIC); ENDSHFRT; ARCHITECTUREbehavOFSHFRTIS BEGIN PROCESS(CLK,LOAD) VARIABLEREG8: STD_LOGIC_VECTOR(7DOWNTO0); BEGIN IFCLK'EVENTANDCLK='1'THEN IFLOAD='1'THENREG8: =DIN;--由(LOAD='1')装载新数据 ELSEREG8(6DOWNTO0): =REG8(7DOWNTO1); ENDIF; ENDIF; QB<=REG8(0);--输出最低位 ENDPROCESS; ENDbehav; 4.1十进制计数器实现流程 4.1十进制计数器实现流程 【例5-3】 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; ENTITYDFF3IS PORT(CLK,D1: INSTD_LOGIC; Q1: OUTSTD_LOGIC); END; ARCHITECTUREbhvOFDFF3IS SIGNALA,B: STD_LOGIC; BEGIN PROCESS(CLK)BEGIN IFCLK'EVENTANDCLK='1'THEN A<=D1; B<=A; Q1<=B; ENDIF; ENDPROCESS; END; 图5-1例5-3的RTL电路图5-2D触发器电路 【例5-4】 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; ENTITYDFF3IS PORT(CLK,D1: INSTD_LOGIC; Q1: OUTSTD_LOGIC); END; ARCHITECTUREbhvOFDFF3IS BEGIN PROCESS(CLK) VARIABLEA,B: STD_LOGIC; BEGIN IFCLK'EVENTANDCLK='1'THEN A: =D1; B: =A; Q1<=B; ENDIF; ENDPROCESS; END; 【例5-6】四选一 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; ENTITYmux4IS PORT(i0,i1,i2,i3,a,b: INSTD_LOGIC; q: OUTSTD_LOGIC); ENDmux4; ARCHITECTUREbody_mux4OFmux4IS signalmuxval: integerrange7downto0; BEGIN process(i0,i1,i2,i3,a,b) begin muxval<=0; if(a='1')thenmuxval<=muxval+1;endif; if(b='1')thenmuxval<=muxval+2;endif; casemuxvalis when0=>q<=i0; when1=>q<=i1; when2=>q<=i2; when3=>q<=i3; whenothers=>null; endcase; endprocess; ENDbody_mux4; 【例5-7】 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; ENTITYmux4IS PORT(i0,i1,i2,i3,a,b: INSTD_LOGIC; q: OUTSTD_LOGIC); ENDmux4; ARCHITECTUREbody_mux4OFmux4IS BEGIN process(i0,i1,i2,i3,a,b) variablemuxval: integerrange7downto0; begin muxval: =0; if(a='1')thenmuxval: =muxval+1;endif; if(b='1')thenmuxval: =muxval+2;endif; casemuxvalis when0=>q<=i0; when1=>q<=i1; when2=>q<=i2; when3=>q<=i3; whenothers=>null; endcase; endprocess; ENDbody_mux4;图5-6例5-7中正确的工作时序 【例5-8】 LibraryIEEE; USEIEEE.STD_LOGIC_1164.ALL; ENTITYSHIFTIS PORT(CLK,C0: INSTD_LOGIC;--时钟和进位输入 MD: INSTD_LOGIC_VECTOR(2DOWNTO0);--移位模式控制字 D: INSTD_LOGIC_VECTOR(7DOWNTO0);--待加载移位的数据 QB: OUTSTD_LOGIC_VECTOR(7DOWNTO0);--移位数据输出 CN: OUTSTD_LOGIC);--进位输出 ENDENTITY; ARCHITECTUREBEHAVOFSHIFTIS SIGNALREG: STD_LOGIC_VECTOR(7DOWNTO0); SIGNALCY: STD_LOGIC; BEGIN PROCESS(CLK,MD,C0) BEGIN IFCLK'EVENTANDCLK='1'THEN CASEMDIS WHEN"001"=>REG(0)<=C0; REG(7DOWNTO1)<=REG(6DOWNTO0);CY<=REG(7);--带进位循环左移 WHEN"010"=>REG(0)<=REG(7); REG(7DOWNTO1)<=REG(6DOWNTO0);--自循环左移 WHEN"011"=>REG(7)<=REG(0); REG(6DOWNTO0)<=REG(7DOWNTO1);--自循环右移 WHEN"100"=>REG(7)<=C0; REG(6DOWNTO0)<=REG(7DOWNTO1);CY<=REG(0);--带进位循环右移 WHEN"101"=>REG(7DOWNTO0)<=D(7DOWNTO0);--加载待移数 WHENOTHERS=>REG<=REG;CY<=CY;--保持 ENDCASE; ENDIF; ENDPROCESS; QB(7DOWNTO0)<=REG(7DOWNTO0);CN<=CY;--移位后输出 ENDBEHAV; 图5-7例5-8中带进位循环左移仿真波形(MD="001") 【例5-9】三态门设计 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; ENTITYtri_sIS port(enable: INSTD_LOGIC; datain: INSTD_LOGIC_VECTOR(7DOWNTO0); dataout: OUTSTD_LOGIC_VECTOR(7DOWNTO0)); ENDtri_s; ARCHITECTUREbhvOFtri_sIS BEGIN PROCESS(enable,datain) BEGIN IFenable='1'THENdataout<=datain; ELSEdataout<="ZZZZZZZZ"; ENDIF; ENDPROCESS; ENDbhv; 【例5-10】双向端口设计 libraryieee; useieee.std_logic_1164.all; entitytri_stateis port(control: instd_logic; in1: instd_logic_vector(7downto0); q: inoutstd_logic_vector(7downto0); x: outstd_logic_vector(7downto0)); endtri_state; architecturebody_trioftri_stateis begin process(control,q,in1) begin if(control='0')thenx<=q; elseq<=in1;x<="ZZZZZZZZ"; endif; endprocess; endbody_tri; 双向端口设计 【例5-12】三态总线电路设计 LIBRARYIEEE; USEIEEE.STD_LOGIC_1164.ALL; ENTITYtristate2IS port(input3,input2,input1,input0: INSTD_LOGIC_VECTOR(7DOWNTO0); enable: INSTD_LOGIC_VECTOR(1DOWNTO0); output: OUTSTD_LOGIC_VECTOR(7DOWNTO0)); ENDtristate2; ARCHITECTUREmultiple_driversOFtris
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- EDA ppt程序未整理全部的 ppt 程序 整理 全部