EDA技术实用教程深入学习VHDL实用教案

上传人:辰*** 文档编号:73234987 上传时间:2022-04-11 格式:PPT 页数:62 大小:1.47MB
返回 下载 相关 举报
EDA技术实用教程深入学习VHDL实用教案_第1页
第1页 / 共62页
EDA技术实用教程深入学习VHDL实用教案_第2页
第2页 / 共62页
EDA技术实用教程深入学习VHDL实用教案_第3页
第3页 / 共62页
点击查看更多>>
资源描述
2022-4-11 P.1VHDL 与图形化输入与图形化输入(shr)比较比较 易于(yy)修改 功能强大 可移植性更强第1页/共61页第一页,共62页。2022-4-11 P.2 图形化输入 vs VHDL 图形化更所见即所得 VHDL 则是告诉(o s)系统要什麽功能,而编译器给出相应的硬件第2页/共61页第二页,共62页。2022-4-11 P.3学习学习(xux) VHDL 要学习要学习(xux)组合逻辑 Combinatorial Logic时序逻辑 Sequential Logic并行语句(yj) Concurrent Statement顺序语句(yj) Process Statement第3页/共61页第三页,共62页。2022-4-11 P.4组合组合(zh)逻辑逻辑Combinatorial Logic Combinatorial Logic if 输出是由输入决定( judng)的逻辑函数 如译码器 decoders, 多路开关multiplexers和加法器 adders输出随输入立即变换第4页/共61页第四页,共62页。2022-4-11 P.5时序时序(sh x)逻辑逻辑Sequential Logic 时序逻辑(lu j)Sequential Logic 输出是输入和电路原状态共同决定的函数 包含寄存器 如状态机. State Machine,计数器 Counters, 移位寄存器Shift Register, 控制器Controllers输出取决于输入和现态Register is used to hold the previous value第5页/共61页第五页,共62页。2022-4-11 P.6并行并行(bngxng)语句语句Concurrent Statement 同时并发执行 与书写前后无关(wgun) 并行语句是: 输出仅取决于输入Entity test1 IsPort ( a, b : in bit; c, d : out bit);end test1;architecture test1_body of test1 isbeginc = a and b;d = a or b;end test1_body;Entity test1 IsPort ( a, b : in bit; c, d : out bit);end test1;architecture test1_body of test1 isbegind = a or b;c = a and b;end test1_body;并发执行与书写顺序无关输出取决于输入而没有任何条件限制第6页/共61页第六页,共62页。2022-4-11 P.7相同(xin tn)C = A and BD = A OR Bc = a and b;d = a or b;d = a or b;c = a and b;第7页/共61页第七页,共62页。2022-4-11 P.8Process Statement进程进程(jnchng)描述描述 所有进程 Process 并发执行 在进程描述Process中, 代码(di m)按序执行 进程描述是: 输出取决于输入和敏感信号,共同控制事件发生。第8页/共61页第八页,共62页。2022-4-11 P.9Entity test1 isPort ( clk, d1, d2 : in bit; q1, q2 : out bit);end test1;architecture test1_body of test1 isbeginProcess (clk, d1)beginif (clkevent and clk = 1) thenq1 = d1;end if;end process;Process (clk, d2)beginif (clkevent and clk= 1) thenq2 = d2;end if;end process;end test1_body;Entity test1 isPort ( clk, d1, d2 : in bit; q1, q2 : out bit);end test1;architecture test1_body of test1 isbeginProcess (clk, d2)beginif (clkevent and clk = 1) thenq2 = d2;end if;end process;Process (clk, d1)beginif (clkevent and clk= 1) thenq1 = d1;end if;end process;end test1_body;两个PROCESS并发执行在PROCESS中代码顺序执行在条件限制下输出取决于输入第9页/共61页第九页,共62页。2022-4-11 P.10两个PROCESS并发(bngf)执行第10页/共61页第十页,共62页。2022-4-11 P.11How to . ? 组合逻辑Combinational Logic能被下面(xi mian)语句实现 并行赋值语句Concurrent Signal Assigment Statements 单纯描述组合逻辑的Process 语句,没有任何时钟边延的约束第11页/共61页第十一页,共62页。2022-4-11 P.12并行语句并行语句(yj)设计组合逻辑设计组合逻辑第12页/共61页第十二页,共62页。2022-4-11 P.13并行并行(bngxng)语句语句Concurrent Statements 分类(fn li) (1)信号赋值语句Signal Assigments (2)条件赋值语句 Conditional Signal Assigments (3) 选择赋值语句Selected Signal Assigments第13页/共61页第十三页,共62页。2022-4-11 P.14(1)信号信号(xnho)赋值语句赋值语句Signal Assigment 并行(bngxng)运行Entity test1 isport ( a, b, e : in bit; c, d : out bit);end test1;architecture test1_body of test1 isbeginc = a and b;d = e;end test1_body;第14页/共61页第十四页,共62页。2022-4-11 P.15支持支持(zhch)的逻辑的逻辑 AND NAND OR NOR XOR NOT more .第15页/共61页第十五页,共62页。2022-4-11 P.16我要我要 5输入输入(shr)与门与门Entity test1 isport ( a, b, c, d, e : in bit; f : out bit);end test1;architecture test1_body of test1 isbeginf = a and b and c and d and e;end test1_body;第16页/共61页第十六页,共62页。2022-4-11 P.17(2) 条件条件(tiojin)赋值语句赋值语句Conditional Signal Assigments当条件(tiojin)成立时赋值例如选多路开关 2 to 1 multiplexerEntity test1 isport (in1, in2, sel : in bit; d : out bit);end test1;architecture test1_body of test1 isbegind = in1 when sel = 0 else in2;end test1_body;第17页/共61页第十七页,共62页。2022-4-11 P.18要更多要更多 - 4 选选1 多路开关多路开关(kigun)Entity test1 isport (in1, in2, in3, in4 : in bit; sel1, sel2 : in bit; d : out bit);end test1;architecture test1_body of test1 isbegind = in1 when sel1 = 0 and sel2 = 0 else in2 when sel1 = 0 and sel2 = 1 else in3 when sel1 = 1 and sel2 = 0 else in4;end test1_body;第18页/共61页第十八页,共62页。2022-4-11 P.19(3) 选择选择(xunz)信号赋值信号赋值Select Signal Assignments 输出随相应(xingyng)的选择条件被赋值Entity test1 isport (a, b: in bit; sel : in bit; c : out bit);end test1;architecture test1_body of test1 isbeginwith sel select c = a when 1, b when 0;end test1_body;第19页/共61页第十九页,共62页。2022-4-11 P.20想要想要(xin yo)更多更多If I want more choice - It is easyEntity test1 isport (in1, in2, in3, in4 : in bit; sel : in integer; out1 : out bit);end test1;architecture test1_body of test1 isbeginwith sel select out1 = in1 when 0, in2 when 1, in3 when 2, in4 when 3;end test1_body;第20页/共61页第二十页,共62页。2022-4-11 P.21练习练习(linx)将图形(txng)转化为 VHDL第21页/共61页第二十一页,共62页。2022-4-11 P.22设计设计(shj)要求要求 用 WHEN-ELSE实现(shxin)100010001other第22页/共61页第二十二页,共62页。2022-4-11 P.23示例示例(shl)Entity test1 isport (high, medium, low : in bit; highest_level3, highest_level2 : out bit; highest_level1, highest_level0 : out bit);end test1;architecture test1_body of test1 isbeginhighest_level3 = 1 when high=1 and medium=0 and low=0 else 0;highest_level2 = 1 when high=0 and medium=1 and low=0 else 0;highest_level1 = 1 when high=0 and medium=0 and low=1 else 0; highest_level0 = 0 when high=1 and medium=0 and low=0 else 0 when high=0 and medium=1 and low=0 else 0 when high=0 and medium=0 and low=1 else 1;end test1_body;第23页/共61页第二十三页,共62页。2022-4-11 P.24仿真仿真(fn zhn)第24页/共61页第二十四页,共62页。2022-4-11 P.25用用Process 语句语句设计组合设计组合(zh)电路电路第25页/共61页第二十五页,共62页。2022-4-11 P.26进程进程(jnchng)语句语句Process Statement 规则 Process中语句顺序执行 所有 Process 必须有敏感信号表 SENITIVITY LIST 一旦敏感信号变了,触发Process运行(ynxng) 除非有Wait语句第26页/共61页第二十六页,共62页。2022-4-11 P.27第27页/共61页第二十七页,共62页。2022-4-11 P.28模板模板(mbn) Process Statement用敏感(mngn)信号表 “SENSITIVITY LIST”name : PROCESS (sensitivity_list)begin sequential statement #1 sequential statement #2 . sequential statement # NEND PROCESS name; 通用写法Process ( )begin.end process敏感信号表顺序执行语句名称可选第28页/共61页第二十八页,共62页。2022-4-11 P.29举例举例(j l)Entity test1 isport (a, b, sel1, sel2 : in bit; result : out bit);end test1;architecture test1_body of test1 isbeginprocess (sel1, sel2,a, b)beginif (sel1 = 1) thenresult = a;elsif (sel2 = 1) thenresult = b;elseresult = 0;end if;end process;end test1_body;输出随 sel1, sel2, a 或 b 变化而变化等一下: 我可以用并行语句(yj)完成第29页/共61页第二十九页,共62页。2022-4-11 P.30Entity test1 isport (a, b, sel1, sel2 : in bit; result : out bit);end test1;architecture test1_body of test1 isbeginresult = a when sel1 = 1 else b when sel2 = 1 else 0;end test1_body;Entity test1 isport (a, b, sel1, sel2 : in bit; result : out bit);end test1;architecture test1_body of test1 isbeginprocess (sel1, sel2,a, b)beginif (sel1 = 1) thenresult = a;elsif (sel2 = 1) thenresult = b;elseresult = 0;end if;end process;end test1_body;同样功能,不同实现方式Concurrent StatementProcess Statement第30页/共61页第三十页,共62页。2022-4-11 P.31Q : 两者区别 Concurrent and Process Statement?A : 对简单例子, Concurrent and Process 都可. 但一些复杂(fz)例子只有用Process Statement。第31页/共61页第三十一页,共62页。2022-4-11 P.32How to . ? 时序逻辑Sequential Logic可以这样实现: Process Statement 描述(mio sh)逻辑 ,附加时钟限制第32页/共61页第三十二页,共62页。2022-4-11 P.33用用Process 设计设计(shj)时序逻辑时序逻辑第33页/共61页第三十三页,共62页。2022-4-11 P.34怎样怎样(znyng)做锁存器做锁存器 LatchEntity test1 isport (clk, d , reset : in bit; q : out bit);end test1;architecture test1_body of test1 isbeginprocess (clk, d, reset)begin if (reset = 1) then q = 0; elsif (clk = 1) then q = d; end if;end process;end test1_body;Reset 先取得控制权Clk后取得控制权在 process中语句顺序执行第34页/共61页第三十四页,共62页。2022-4-11 P.35这是 LATCH第35页/共61页第三十五页,共62页。2022-4-11 P.36如果如果(rgu)我如下修改我如下修改.Entity test1 isport (clk, d , reset : in bit; q : out bit);end test1;architecture test1_body of test1 isbeginprocess (clk)begin if (reset = 1) then q = 0; elsif (clk = 1) then q = d; end if;end process;end test1_body;注意(zh y) : 结果完全不同这是什麽?第36页/共61页第三十六页,共62页。2022-4-11 P.37这是触发器 Flip-Flop 不是(b shi)锁存器 LATCH第37页/共61页第三十七页,共62页。2022-4-11 P.38为什麽我得到为什麽我得到(d do)Flip-Flop 而不是而不是 Latch 锁存器的Sensitivity list process (clk, d, reset) 触发器的 Sensitivity list process(clk) Q : Sensitivity list 用来(yn li)干什麽 ? A : 输出随 Sensitivity list 变第38页/共61页第三十八页,共62页。2022-4-11 P.39 我们现在知道 VHDL 是强大(qingd)的, 但如果你不知道自己作什麽, 你不会得到想要的结果 你想要 latch 但事实上你得到了 Flip-Flop第39页/共61页第三十九页,共62页。2022-4-11 P.40sequential statements 的顺序的顺序(shnx)有何影响有何影响 ?ex1: PROCESS (a, b)BEGIN IF a=1 THEN c=0; - 若 a 、 b 都为 END IF; IF b=1 THEN c=1; - b 优先(yuxin) END IF;- 故c = 1;END PROCESS ex1;ex2: PROCESS (a, b)BEGIN IF b=1 THEN c=1; -若 a 、 b 都为 END IF; - IF a=1 THEN c=0; - a优先(yuxin) END IF; -故c = 1;END PROCESS ex2;第40页/共61页第四十页,共62页。2022-4-11 P.41Processes中信号中信号(xnho)赋值的注意事项赋值的注意事项看下列的代码,那种电路是综合的结果(ji gu)?PROCESS (clock)BEGINIF rising_edge(clock) THENb = a; - 在 clock 上升延后, a 赋给 bc = b; -在 clock 上升延后, b赋给 c END IF;END PROCESS ;aclockcbacclock OR第41页/共61页第四十一页,共62页。2022-4-11 P.42Signal Assignment in Processes在进程中,信号不是被立即更新,而是在预定的时间被更新信号事实上直到执行到END PROCESS才被更新所以,前面综合出两个寄存器 (c = b 中的是原来的状态 b)在某些时候(sh hou),外面用并行语句会解决此问题,但不是总有效。如何解决 ?第42页/共61页第四十二页,共62页。2022-4-11 P.43Variables当并行信号赋值不能在process 外使用时, 可用 variable解决问题Variables 和 signals类似, 但只用在 PROCESS中. 不能在 processes间传输信息Variables 可以(ky)是VHDL中任何数据类型赋给 variable 的值立即生效用分号结束赋值 (:), 如下:c := a AND b;第43页/共61页第四十三页,共62页。2022-4-11 P.44cVariables vs. Signals用 variable 解决( jiju)前面的问题:PROCESS (clock)VARIABLE b : std_logic ;BEGIN IF rising_edge(clock) THEN b := a ; - 立即赋值生效立即赋值生效(shng xio)c = b ; - 按预定时间赋值生效按预定时间赋值生效(shng xio) END IF;END PROCESS ;aclock第44页/共61页第四十四页,共62页。2022-4-11 P.45另外一种另外一种(y zhn)编码编码LIBRARY IEEE;USE IEEE.std_logic_1164.all;ENTITY tdff ISPORT(clk, d: in std_logic; q : out std_logic);END tdff;ARCHITECTURE behaviour OF tdff ISBEGINPROCESSBEGINwait until clk = 1;q = d;END PROCESS;END behaviour;第45页/共61页第四十五页,共62页。2022-4-11 P.46IF-THEN-ELSE vs WATI UNTILLIBRARY IEEE;USE IEEE.std_logic_1164.all;ENTITY tdff ISPORT(clk, d: in std_logic; q : out std_logic);END tdff;architecture behaviour OF tdff ISBEGINPROCESSBEGINwait until clk = 1;q = d;END PROCESS;END behaviour;Entity test1 isport (clk, d : in bit; q : out bit);end test1;architecture test1_body of test1 isbeginprocess (clk)begin if (clk = 1) then q = d; end if;end process;end test1_body;Entity test1 isport (clk, d : in bit; q : out bit);end test1;architecture test1_body of test1 isbeginprocess (clk,d)begin if (clk = 1 and clkevent) then q = d; end if;end process;end test1_body;第46页/共61页第四十六页,共62页。2022-4-11 P.47Review Concurrent Statement 用来(yn li)设计 组合逻辑combinational logic (无触发器) 如译码器 decoders, 多路开关multiplexers和加法器 adders Process Statement 用来(yn li)设计 组合逻辑combinational logic (无触发器) 时序逻辑Sequential logic (触发器) 如状态机. State Machine,计数器 Counters, 移位寄存器Shift Register, 控制器Controllers第47页/共61页第四十七页,共62页。2022-4-11 P.48第48页/共61页第四十八页,共62页。2022-4-11 P.49ENTITY test1 ISPORT( clk, a,b,c : in bit; d : out bit);END test1;architecture test1_body of test1 isbegind = (a and b) xor c);end test1_body;Is this OK ?第49页/共61页第四十九页,共62页。2022-4-11 P.50ENTITY test1 ISPORT( clk, a,b,c : in bit; d, e : out bit);END test1;architecture test1_body of test1 isbegind = (a and b) xor c);e = (a or b) nand c);Is this OK ?end test1_body;第50页/共61页第五十页,共62页。2022-4-11 P.51ENTITY test1 ISPORT( clk, a,b,c : in bit; d : out bit);END test1;architecture test1_body of test1 isbeginprocess(a,b,c)begind = (a and b) xor c);end process;end test1_body;Is this OK ?第51页/共61页第五十一页,共62页。2022-4-11 P.52ENTITY test1 ISPORT( clk, a,b,c : in bit; d,e : out bit);END test1;architecture test1_body of test1 isbeginprocess(a,b,c)begind = (a and b) xor c);e = (a or b) nand c);end process;end test1_body;Is this OK ?第52页/共61页第五十二页,共62页。2022-4-11 P.53ENTITY test1 ISPORT( clk, a,b,c : in bit; d, e : out bit);END test1;architecture test1_body of test1 isbeginif (clkevent and clk=1) thend = (a or b) and c);end test1_body;Is this OK ?第53页/共61页第五十三页,共62页。2022-4-11 P.54ENTITY test1 ISPORT( clk, a,b,c : in bit; d : out bit);END test1;architecture test1_body of test1 isbeginprocess(clk)beginif (clkevent and clk=1) thend = (a or b) and c);end if;end process;end test1_body;Is this OK ?第54页/共61页第五十四页,共62页。2022-4-11 P.55ENTITY test1 ISPORT( clk, a,b,c : in bit; d,e : out bit);END test1;architecture test1_body of test1 isbeginprocess(clk,a,b,c)beginif (clkevent and clk=1) thend = (a xor b) and c);end if;e = (a or b) nand c);end process;end test1_body;Is this OK ?第55页/共61页第五十五页,共62页。2022-4-11 P.56ENTITY test1 ISPORT( clk, a,b,c : in bit; d,e,f : out bit);END test1;architecture test1_body of test1 isbeginprocess(clk,a,b,c)beginif (clkevent and clk=1) thend = (a xor b) and c);end if;if (clkevent and clk=1) thene = (a or b) nand c);end if;if (a = 1) thenf = (a or b);end if;end process;end test1_body;Is this OK ?第56页/共61页第五十六页,共62页。2022-4-11 P.57坐下思考坐下思考(sko)你的设计你的设计D e s ig n F lo wC o n c u rre n ts ta te m e n to rP ro c e s s s ta te m e n tP ro c e s ss ta te m e n tC o n c u rre n t+P ro c e s ss ta te m e n tD o e s th ed e s ig n is ap u res e q u e n tia l c irc u itD o e s th ed e s ig n is ap u rec o m b in a tio n a l c irc u itYNYN第57页/共61页第五十七页,共62页。2022-4-11 P.58学习学习(xux)总结总结 学习(xux)什么是 Combinational Logic/Circuits 学习(xux)什么是 Sequential Logic/Circuits 区别 Concurrent Statement 和 Process Statement第58页/共61页第五十八页,共62页。2022-4-11 P.59 理解用途 Concurrent Statement 组合逻辑 简单赋值语句simple signal assignment statement 条件赋值语句conditional signal assignment statement 选择(xunz)赋值语句selected signal assignement statement Process Statement 组合逻辑 时序逻辑 if-then-else structure for Latch if-then-else structure for Flip-Flop wait until structure for Flip-Flop第59页/共61页第五十九页,共62页。2022-4-11 P.60在在VHDL 语言语言(yyn)中最重要的事中最重要的事“ 确切(quqi)地告诉我你的电路功能如何,VHDL compiler 会给你适合的电路”如 Latch 和d Flip-Flop 是个好例子第60页/共61页第六十页,共62页。2022-4-11 P.61谢谢您的观看(gunkn)!第61页/共61页第六十一页,共62页。NoImage内容(nirng)总结2021/11/12 P.1。第1页/共61页。单纯描述组合逻辑(lu j)的Process 语句,没有任何时钟边延的约束。看下列的代码,那种电路是综合的结果。在某些时候,外面用并行语句会解决此问题,但不是总有效。USE IEEE.std_logic_1164.all。process(a,b,c)。process(clk,a,b,c)。第60页/共61页。谢谢您的观看。第61页/共61页第六十二页,共62页。
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 课件教案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!