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 assignments.
1) FOR / GENERATE: notice that GENERATE must be labeled.
label: FOR identifier IN range GENERATE
(concurrent assignments)
END GENERATE;
2) IF/GENERATE
An irregular form is also available, which uses IF/GENERATE (with an IF equivalent; recall that originally IF is a sequential statement). Here ELSE is not allowed.
label1: FOR identifier IN range GENERATE
...
label2: IF condition GENERATE
(concurrent assignments)
END GENERATE;
...
END GENERATE;
Example 1
SIGNAL x: BIT_VECTOR ( DOWNTO );
SIGNAL y: BIT_VECTOR ( DOWNTO );
SIGNAL z: BIT_VECTOR ( DOWNTO );
...
G1: FOR i IN x'RANGE GENERATE
z(i) <= x(i) AND y(i+);
END GENERATE;
Example 2 Vector Shifter
The output vector must be a shifted version of the input vector, with twice its width and an amount of shift specified by another input.
For example, if the input bus has width 4, and the present value is ‘‘1111’’, then the output should be one of the lines of the following
matrix (the original vector is underscored):
row(0): 0 0 0 0 1 1 1 1
row(1): 0 0 0 1 1 1 1 0
row(2): 0 0 1 1 1 1 0 0
row(3): 0 1 1 1 1 0 0 0
row(4): 1 1 1 1 0 0 0 0
------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
------------------------------------------------
ENTITY shifter IS
PORT ( inp: IN STD_LOGIC_VECTOR ( DOWNTO );
sel: IN INTEGER RANGE TO ;
outp: OUT STD_LOGIC_VECTOR ( DOWNTO ));
END shifter;
------------------------------------------------
ARCHITECTURE shifter OF shifter IS
SUBTYPE vector IS STD_LOGIC_VECTOR ( DOWNTO );
TYPE matrix IS ARRAY ( DOWNTO ) OF vector;
SIGNAL row: matrix;
BEGIN
row() <= "" & inp;
G1: FOR i IN TO GENERATE
row(i) <= row(i-)( DOWNTO ) & '';
END GENERATE;
outp <= row(sel);
END shifter;
------------------------------------------------
最新文章
- arcgis api for js入门开发系列二不同地图服务展示(含源代码)
- Windows API 函数列表 附帮助手册
- javascript深入理解js闭包
- 帆软报表FineReport中数据连接之Jboss配置JNDI连接
- 使用Ant自动化我们的java项目生成
- Resizing the disk space on Ubuntu Server VMs running on VMware ESXi 5
- Visual Studio: How to change ipch path in Visual Studio 2010 (.sdf, *.opensdf, ...)
- lpxelinux启动linux
- node Later定时任务
- solr安全-tomcat
- solrj:org.apache.solr.common.util.NamedList.java
- Spring的配置文件
- poj 1144 Network【双连通分量求割点总数】
- 【Ruby on Rails学习二】在线学习资料的整理
- html css js 框架
- retain、strong、weak、assign区别
- Android开发相关操作
- webpack打包编译时,不识别src目录以外的js或css
- HTTP之URL分解
- sed 变量替换和Linux的特殊符号大全