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;
------------------------------------------------

最新文章

  1. arcgis api for js入门开发系列二不同地图服务展示(含源代码)
  2. Windows API 函数列表 附帮助手册
  3. javascript深入理解js闭包
  4. 帆软报表FineReport中数据连接之Jboss配置JNDI连接
  5. 使用Ant自动化我们的java项目生成
  6. Resizing the disk space on Ubuntu Server VMs running on VMware ESXi 5
  7. Visual Studio: How to change ipch path in Visual Studio 2010 (.sdf, *.opensdf, ...)
  8. lpxelinux启动linux
  9. node Later定时任务
  10. solr安全-tomcat
  11. solrj:org.apache.solr.common.util.NamedList.java
  12. Spring的配置文件
  13. poj 1144 Network【双连通分量求割点总数】
  14. 【Ruby on Rails学习二】在线学习资料的整理
  15. html css js 框架
  16. retain、strong、weak、assign区别
  17. Android开发相关操作
  18. webpack打包编译时,不识别src目录以外的js或css
  19. HTTP之URL分解
  20. sed 变量替换和Linux的特殊符号大全

热门文章

  1. Problem 28
  2. Matplotlib基本使用简介
  3. Linux - centos7 下 MySQL(mariadb) 和 主从复制
  4. 【7】Django网页视图模板处理
  5. scrapy——8 scrapyd使用
  6. 【Codeforces 63C】Bulls and Cows
  7. 【[Offer收割]编程练习赛13 B】最大子矩阵(别人的思路)
  8. noip模拟赛 PA
  9. nyoj_18_The Triangle_201312071533
  10. Monitor和Lock以及区别