有人能解释为什么在编写VHDL时的黄金法则是if-then-else语句必须在一个进程中。是不是因为在进程内部,语句是按顺序执行的,而在外部则不是。
发布于 2012-09-17 18:19:47
简单的答案是“因为这就是语言的语法”!
如果您想从一些不在进程中的代码的选项中进行选择,您可以这样做:
sig <= a when sel = 1 else
b when sel = 2 else
default_value;或
with sel select
sig <= a when 1,
b when 2,
default_value when others;See here for many examples of a mux
发布于 2012-09-17 16:52:08
我可能错了,但我认为if语句需要在一个进程中的主要原因是if语句可能会赋值给多个信号,如果你想在进程外做同样的事情,你需要使用多个条件信号赋值。
例如:
process(C0, C1, A, B, C) is
begin
if C0 = '1' then
F <= A;
G <= C;
elsif C1 = '1' then
F <= B;
G <= B;
else
F <= C;
G <= A;
end if;
end process;进程外的等效条件信号分配为:
F <= A when C0 = '1' else B when C1 = '1' else C;
G <= C when C0 = '1' else B when C1 = '1' else A;发布于 2013-02-18 15:26:16
if else语句:-
Syntax:
if then
statements
...
[
elsif then
statements
...
else
statements
...
]
endif;欲了解更多信息,请访问this
https://stackoverflow.com/questions/12452657
复制相似问题