VHDL之concurrent之when

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 --------------------------------------------
时间: 2024-10-01 05:17:10

VHDL之concurrent之when的相关文章

VHDL之concurrent之generate

GENERATE It is another concurrent statement (along with operators and WHEN). It is equivalent to the sequential statement LOOP in the sense that it allows a section of code to be repeated a number of times, thus creating several instances of the same

VHDL之concurrent之operators

Using operators Operators can be used to implement any combinational circuit. However, as will become apparent later, complex circuits are usually easier to write using sequential code, even if the circuit does not contain sequential logic. Example M

how to forget about delta cycles for RTL design

A delta cycle is a VHDL construct used to makeVHDL, a concurrent language, executable on asequential computer. For RTL design, you can adopt some simple rules andforget about delta cycles. For testbenches, often you must have a good understandingof w

VHDL基础1

Description Structure 一个可综合的VHDL描述中一般由3部分组成:LIBRARY declarations.ENTITY.ARCHITECTURE Library(库)用来设计重用和代码共享,使代码结构更清晰 1 LIBRARY library_name; 2 USE library_name.package_name.package_parts; 常用的三个Libray:ieee.std.work 其中std.work是默认可见的,不需声明,ieee需要明确的声明 Ent

ConCurrent in Practice小记 (2)

Java-ConCurrent2.html :first-child{margin-top:0!important}img.plugin{box-shadow:0 1px 3px rgba(0,0,0,.1);border-radius:3px}iframe{border:0}figure{-webkit-margin-before:0;-webkit-margin-after:0;-webkit-margin-start:0;-webkit-margin-end:0}kbd{border:1p

ConCurrent in Practice小记 (3)

高级同步技巧 Semaphore Semaphore信号量,据说是Dijkstra大神发明的.内部维护一个许可集(Permits Set),用于发放许可和回收许可,存在内部计数器,主要用来计数能否得到资源(一般用来限制同时访问资源数).当一个线程拿到许可,计数器减一:当线程释放资源则计数器加一:当计数器为0则阻塞线程. 特别地: Semaphore的同步锁机制仅仅用于对访问许可的同步,对于需要访问对象的池等的同步锁并不保证.如一个线程池需要访问一个资源池,此时对于每一个需要访问资源的线程,要先获

Java并发编程:Concurrent锁机制解析

.title { text-align: center } .todo { font-family: monospace; color: red } .done { color: green } .tag { background-color: #eee; font-family: monospace; padding: 2px; font-size: 80%; font-weight: normal } .timestamp { color: #bebebe } .timestamp-kwd

有限状态机VHDL模板

逻辑设计, 顾名思义, 只要理清了逻辑和时序, 剩下的设计就是做填空题了. 简单总结了有限状态机的一种设计方式, 详细参见 <<Circuit Design with VHDL>>  chapter 8  State Machines 1  有限状态机 2  VHDL模板之一 1)  端口定义 library IEEE; use ieee.std_logic_1164.all; --! 端口定义 entity <entity_name> is port ( INPUT

VHDL:信号、端口以及和Verilog的区别

1.信号 信号是描述硬件系统的基本数据对象,它的性质类似于连接线.信号可以作为设计实 体中并行语句模块间的信息交流通道.      信号作为一种数值容器,不但可以容纳当前值,也可以保持历史值(这决定于语句的表达方式).这一属性与触发器的记忆功能有很好的对应关系,只是不必注明信号上数据流动的方向.信号定义的语句格式与变量相似,信号定义也可以设置初始值,定义格式是:   SIGNAL 信号名: 数据类型 := 初始值 :      同样,信号初始值的设置也不是必需的,而且初始值仅在 VHDL 的行为