《EDA信号与变量》PPT课件.ppt

上传人:pu****.1 文档编号:576987022 上传时间:2024-08-20 格式:PPT 页数:22 大小:265.60KB
返回 下载 相关 举报
《EDA信号与变量》PPT课件.ppt_第1页
第1页 / 共22页
《EDA信号与变量》PPT课件.ppt_第2页
第2页 / 共22页
《EDA信号与变量》PPT课件.ppt_第3页
第3页 / 共22页
《EDA信号与变量》PPT课件.ppt_第4页
第4页 / 共22页
《EDA信号与变量》PPT课件.ppt_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《《EDA信号与变量》PPT课件.ppt》由会员分享,可在线阅读,更多相关《《EDA信号与变量》PPT课件.ppt(22页珍藏版)》请在金锄头文库上搜索。

1、物理与电子工程学院物理与电子工程学院信号与变量区别&联系物理与电子工程学院物理与电子工程学院非静态与静态数据对象n非静态数据处理signal, variablen静态数据处理constant, genericn常量和信号是全局的,用于顺序代码及并行代码n变量是局部的,只用于顺序代码(process,function,procedure)且值不能直接直接向外传递。2物理与电子工程学院物理与电子工程学院常量n常量可以在包集、实体或结构中声明。包集调用包集的所有实体使用实体对该实体的所有结构体可用结构仅在结构体中使用3物理与电子工程学院物理与电子工程学院信号n代表逻辑电路的“硬”连线,用作输入/出端

2、口、内部连接n所有端口默认为信号n定义的地方同常量n当信号用在顺序描述语句(如当信号用在顺序描述语句(如process)内部,)内部,其值不立刻更新,信号值是在相应的进程、函其值不立刻更新,信号值是在相应的进程、函数或过程完成后才进行更新数或过程完成后才进行更新n对同一个信号进行多重赋值:编译器可能给出警告并退出综合过程或仅认为最后一次赋值是有效的。(Maxplus II给出警告)4物理与电子工程学院物理与电子工程学院计数向量中1的个数n信号不立即更新n变量立即更新5library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity count_ones ispor

3、t( din: in std_logic_vector(7 downto 0);ones: out integer range 0 to 8 ); end count_ones;architecture not_ok of count_ones issignal temp: integer range 0 to 8;beginprocess(din)begintemp=0;for i in 0 to 7 loopif (din(i)=1) thentemp=temp+1;end if;end loop;ones = temp;end process;end architecture not_o

4、k;6library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity count_ones isport( din: in std_logic_vector(7 downto 0);ones: out integer range 0 to 8 );end count_ones;architecture ok of count_ones isbeginprocess(din)variable temp: integer range 0 to 8;begintemp:=0;for i in 0 to 7 loopif (din(i)=1) thentemp:=tem

5、p+1;end if;end loop;ones = temp;end process;end architecture ok;7物理与电子工程学院物理与电子工程学院分频器设计library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity freq_divider isport(clk,clr: in std_logic;out1,out2: buffer std_logic );end freq_divider;architecture Behavioral of freq_divider issignal count1: integer range 0 to

6、 7;begin 8process(clk,clr)variable count2: integer range 0 to 7;beginif(clr=1)thencount1=0;count2:=0;out1=0;out2=0;elseif(clkevent and clk=1)thencount1 = count1+1;count2 := count2+1;if(count1 = ?) thenout1 = not out1;count1 = 0;end if;if(count2 = ?) thenout2 = not out2;count2 := 0;end if;end if;end

7、if;end process;end Behavioral;9物理与电子工程学院物理与电子工程学院Cnt1:sigCnt2:var 2,22,34,410物理与电子工程学院物理与电子工程学院触发器设计library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity dff isport( d,clk:in std_logic;q: buffer std_logic;qbar: out std_logic);end dff;architecture not_ok of dff isbeginprocess(clk)beginif(clkevent and clk=1

8、)thenq=d; -进程结束后才生效qbar=not q;-进程结束后才生效,q的值此时还没更新!end if;end process;end architecture not_ok;11物理与电子工程学院物理与电子工程学院qbar延迟了一个周期12物理与电子工程学院物理与电子工程学院改进的设计library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity dff isport( d,clk:in std_logic;q: buffer std_logic;qbar: out std_logic);end dff;architecture ok of dff

9、isbeginprocess(clk)beginif(clkevent and clk=1)thenq=d;end if;end process;qbar=not q;end architecture ok;13物理与电子工程学院物理与电子工程学院qbar赋值与进程并发,q变化,qbar立即更新14物理与电子工程学院物理与电子工程学院寄存器数量n一个信号的赋值是以另一个信号的跳变为条件时(即发生同步赋值时),编译后产生寄存器。(process、function、procedure中)n如果一个变量在还没有进行赋值操作时已被使用,那么综合后就好产生寄存器。n一个变量在一个信号跳变时赋值,并且该值

10、最终又被赋给了另外的信号,则综合后会产生寄存器。n如果变量的值没有被进程(函数或过程)以外的代码调用,那么不一定产生寄存器。15物理与电子工程学院物理与电子工程学院16物理与电子工程学院物理与电子工程学院17物理与电子工程学院物理与电子工程学院library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity dff isport( d,clk:in std_logic;q: buffer std_logic;qbar: out std_logic);end dff;architecture not_ok of dff isbeginprocess(clk)begi

11、nif(clkevent and clk=1)thenq=d; -进程结束后才生效qbar=not q;-进程结束后才生效,q的值此时还没更新!end if;end process;end architecture not_ok;18物理与电子工程学院物理与电子工程学院改进的设计library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity dff isport( d,clk:in std_logic;q: buffer std_logic;qbar: out std_logic);end dff;architecture ok of dff isbeginpr

12、ocess(clk)beginif(clkevent and clk=1)thenq=d;end if;end process;qbar=not q;end architecture ok;19物理与电子工程学院物理与电子工程学院移位寄存器entity shift isport(din,clk: in bit;dout: out bit );end shift;architecture shift of shift isbeginprocess(clk)variable a,b,c: bit;beginif(clkevent and clk=1) thendout = c;c := b;b :

13、= a;a := din;end if;end process;end architecture shift ;20entity shift isport(din,clk: in bit;dout: out bit );end shift;architecture shift of shift isbeginprocess(clk)variable a,b,c: bit;beginif(clkevent and clk=1) thena := din;b := a;c := b;dout = c;end if;end process;end architecture shift ;21entity shift isport(din,clk: in bit;dout: out bit );end shift;architecture shift of shift issignal a,b,c: bit;beginprocess(clk)beginif(clkevent and clk=1) thena = din;b = a;c = b;dout = c;end if;end process;end architecture shift ;22

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 研究生课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号