- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数字系统与VHDL程序设计语言 自控系王新刚 我们曾举过一个二输入的与门电路的例子: Library ieee; Use ieee.std_logic_1164.all; Entity and2 is Port(d1,d2 : in std_logic; op : out std_logic); End and2; Architecture m1 of and2 is Begin op= ‘1’ when(d1=’1’ and d2=’1’)else ‘0’; End m1; Library ieee; Use ieee.std_logic_1164.all; Entity mux is Port(a,b,c : in bit; p1,p2 : in bit z : out bit); End and2; Architecture m1 of mux is Begin z= a when p1=‘1’ else b when p2=‘1’ else c; End m1; 允许有重叠 三、选择式信号设置语句:With-Select-When With expression Select 赋值目标=表达式 When constant_value1 表达式 When constant_value2 … 表达式 When Others; 选择式信号设置语句本身不能在进程中应用其功能与进程中 的CASE语句相同。 例:不允许有重叠现象;必须含盖所有条件 Architecture m2 of and2 is Signal tmp : std_logic_vector(1 down to 0); Begin tmp=d1 d2; With tmp select f=’1’ when “11”; ‘0’ when others; End m2; When-else语句和With-select-When语句的差别 两个语句的关键不同是:对于条件的要求程度不同,前者 要求较松,后者要求严格。 a With-select-When语句中When后的constant_value必须 是互不相同的; b 而When-else语句中When后的logic_expression则不需要这样 的严格条件,因为其When后的logic_expression的优先权次序 为由先到后排列。 4.3 进程语句(process) Process 语句的格式为: [进程标号:] Process [(敏感信号列表)] [变量声明] Begin 顺序语句; End Process [进程标号]; 敏感表(Sensitivity list)包括进程的一些信号,当敏感表中的某个信号变化时进程才 被激活,进程内的顺序语句被执行。当进程结束时,进程内的输出信号值被更新, 进程进入等待(睡眠)状态,直到敏感表中的某一信号发生变化,进程被再次激活。? 下面举一个应用示例,如下面电路: 用用不同VHDL语句对电路的描述如下: library ieee; use ieee.std_logic_1164.all; Entity exam1 is Port (a,b : in std_logic; c,d : out std_logic); End exam1; Architecture m1 of exam1 is Begin c=a and b; d=a or b ; End m1; architecture m2 of exam1 is begin process begin c=a and b; d= a or b ; end process; end m2; architecture m2 of exam1 is begin process begin c=a and b; d=
文档评论(0)