2个回答
展开全部
其实所谓“条件信号赋值语句”,不过是if语句与信号赋值语句的结合而已。一个并行的条件信号赋值语句是可以用一个进程来代替的:这个进程体是由if语句和信号赋值语句构成的。
而所谓“选择信号赋值语句”,则是case语句与信号赋值语句的结合。一个并行的选择信号赋值语句也可以用一个进程来代替:这个进程体是由case语句和信号赋值语句构成的。
看一下下面的例子:
4选1多路选择器
ENTITY mux4 IS
PORT(in0,in1,in2,in3:IN Bit;
sel:IN Bit_Vector(0 TO 1);
q:OUT Bit);
END mux4;
ARCHITECTURE behav1 OF mux4 IS
BEGIN
mux4_p1:PROCESS(in0,in1,in2,in3,sel)
BEGIN
IF sel = ″00″ THEN q <= in0;
ELSIF sel = ″01″ THEN q <= in1;
ELSIF sel = ″10″ THEN q <= in2;
ELSE q <= in3;
END IF;
END PROCESS mux4_p1;
END behav1;
ARCHITECTURE behav2 OF mux4 IS
BEGIN
q <= in0 WHEN sel = ″00″ ELSE
in1 WHEN sel = ″01″ ELSE
in2 WHEN sel = ″10″ ELSE
in3; -- 这个条件信号赋值语句与进程mux4_p1等价
END behav2;
ARCHITECTURE behav3 OF mux4 IS
BEGIN
mux4_p2:PROCESS(in0,in1,in2,in3,sel)
BEGIN
CASE sel IS
WHEN ″00″ => q <= in0;
WHEN″01″ => q <= in1;
WHEN ″10″ => q <= in2;
WHEN OTHERS => q <= in3;
END CASE;
END PROCESS mux4_p2;
END behav3;
ARCHITECTURE behav4 OF mux4 IS
BEGIN
WITH sel SELECT
q <= in0 WHEN ″00″,
in1 WHEN ″01″,
in2 WHEN ″10″,
in3 WHEN OTHERS; -- 这个选择信号赋值语句与进程mux4_p2等价
END behav4;
展开全部
其实所谓“条件信号赋值语句”,不过是if语句与信号赋值语句的结合而已。一个并行的条件信号赋值语句是可以用一个进程来代替的:这个进程体是由if语句和信号赋值语句构成的。
而所谓“选择信号赋值语句”,则是case语句与信号赋值语句的结合。一个并行的选择信号赋值语句也可以用一个进程来代替:这个进程体是由case语句和信号赋值语句构成的。
看一下下面的例子:
4选1多路选择器
ENTITY mux4 IS
PORT(in0,in1,in2,in3:IN Bit;
sel:IN Bit_Vector(0 TO 1);
q:OUT Bit);
END mux4;
ARCHITECTURE behav1 OF mux4 IS
BEGIN
mux4_p1:PROCESS(in0,in1,in2,in3,sel)
BEGIN
IF sel = ″00″ THEN q <= in0;
ELSIF sel = ″01″ THEN q <= in1;
ELSIF sel = ″10″ THEN q <= in2;
ELSE q <= in3;
END IF;
END PROCESS mux4_p1;
END behav1;
ARCHITECTURE behav2 OF mux4 IS
BEGIN
q <= in0 WHEN sel = ″00″ ELSE
in1 WHEN sel = ″01″ ELSE
in2 WHEN sel = ″10″ ELSE
in3; -- 这个条件信号赋值语句与进程mux4_p1等价
END behav2;
ARCHITECTURE behav3 OF mux4 IS
BEGIN
mux4_p2:PROCESS(in0,in1,in2,in3,sel)
BEGIN
CASE sel IS
WHEN ″00″ => q <= in0;
WHEN″01″ => q <= in1;
WHEN ″10″ => q <= in2;
WHEN OTHERS => q <= in3;
END CASE;
END PROCESS mux4_p2;
END behav3;
ARCHITECTURE behav4 OF mux4 IS
BEGIN
WITH sel SELECT
q <= in0 WHEN ″00″,
in1 WHEN ″01″,
in2 WHEN ″10″,
in3 WHEN OTHERS; -- 这个选择信号赋值语句与进程mux4_p2等价
END behav4;
而所谓“选择信号赋值语句”,则是case语句与信号赋值语句的结合。一个并行的选择信号赋值语句也可以用一个进程来代替:这个进程体是由case语句和信号赋值语句构成的。
看一下下面的例子:
4选1多路选择器
ENTITY mux4 IS
PORT(in0,in1,in2,in3:IN Bit;
sel:IN Bit_Vector(0 TO 1);
q:OUT Bit);
END mux4;
ARCHITECTURE behav1 OF mux4 IS
BEGIN
mux4_p1:PROCESS(in0,in1,in2,in3,sel)
BEGIN
IF sel = ″00″ THEN q <= in0;
ELSIF sel = ″01″ THEN q <= in1;
ELSIF sel = ″10″ THEN q <= in2;
ELSE q <= in3;
END IF;
END PROCESS mux4_p1;
END behav1;
ARCHITECTURE behav2 OF mux4 IS
BEGIN
q <= in0 WHEN sel = ″00″ ELSE
in1 WHEN sel = ″01″ ELSE
in2 WHEN sel = ″10″ ELSE
in3; -- 这个条件信号赋值语句与进程mux4_p1等价
END behav2;
ARCHITECTURE behav3 OF mux4 IS
BEGIN
mux4_p2:PROCESS(in0,in1,in2,in3,sel)
BEGIN
CASE sel IS
WHEN ″00″ => q <= in0;
WHEN″01″ => q <= in1;
WHEN ″10″ => q <= in2;
WHEN OTHERS => q <= in3;
END CASE;
END PROCESS mux4_p2;
END behav3;
ARCHITECTURE behav4 OF mux4 IS
BEGIN
WITH sel SELECT
q <= in0 WHEN ″00″,
in1 WHEN ″01″,
in2 WHEN ″10″,
in3 WHEN OTHERS; -- 这个选择信号赋值语句与进程mux4_p2等价
END behav4;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询