码迷,mamicode.com
首页 > 其他好文 > 详细

VHDL之concurrent之when

时间:2015-05-20 23:36:46      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:

WHEN (simple and selected)

  It is one of the fundamental concurrent statements (along with operators and GENERATE).

  It appears in two forms: WHEN / ELSE (simple WHEN) and WITH / SELECT / WHEN (selected WHEN).

  1) WHEN / ELSE:

assignment  WHEN  condition  ELSE
assignment  WHEN  condition  ELSE
...;

  2) WITH / SELECT / WHEN:

WITH  identifier  SELECT
assignment  WHEN  value,
assignment  WHEN  value,
...;

 

Example

  技术分享

Solution 1  

1 ------- Solution 1: with WHEN/ELSE --------
2 LIBRARY ieee;
3 USE ieee.std_logic_1164.all;
4 -------------------------------------------
5 ENTITY mux IS
6 PORT ( a, b, c, d: IN STD_LOGIC;
7     sel: IN STD_LOGIC_VECTOR (1 DOWNTO 0);
8     y: OUT STD_LOGIC);
9 END mux;
10 -------------------------------------------
11 ARCHITECTURE mux1 OF mux IS
12 BEGIN
13   y <=  a WHEN sel="00" ELSE
14       b WHEN sel="01" ELSE
15       c WHEN sel="10" ELSE
16       d;
17 END mux1;
18 -------------------------------------------

 

Solution 2

1 --- Solution 2: with WITH/SELECT/WHEN -----
2 LIBRARY ieee;
3 USE ieee.std_logic_1164.all;
4 -------------------------------------------
5 ENTITY mux IS
6 PORT ( a, b, c, d: IN STD_LOGIC;
7     sel: IN STD_LOGIC_VECTOR (1 DOWNTO 0);
8     y: OUT STD_LOGIC);
9 END mux;
10 -------------------------------------------
11 ARCHITECTURE mux2 OF mux IS
12 BEGIN
13 WITH sel SELECT
14  y <= a WHEN "00",   -- notice "," instead of ";"
15     b WHEN "01",
16     c WHEN "10",
17     d WHEN OTHERS;  -- cannot be "d WHEN "11" "
18 END mux2;
19 --------------------------------------------

 

VHDL之concurrent之when

标签:

原文地址:http://www.cnblogs.com/mengdie/p/4518340.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!