[工学]VHDL程序设计语言.ppt

[工学]VHDL程序设计语言

数字系统与VHDL程序设计语言 自控系王新刚 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= a or b ; end process; end m2; architecture m3 of exam1 is begin process begin c=a and b; end process D1 ; process begin d= a or b ; end process D2 ; end m3; a 在一个结构体当中可以有多个Process 语句; b Process 语句是同时执行的并行语句; c 但是Process内的语句却是顺序执行的顺序

文档评论(0)

1亿VIP精品文档

相关文档