这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » FPGA » VHDL小程序求解

共2条 1/1 1 跳转至

VHDL小程序求解

助工
2013-07-02 16:41:09     打赏
各位大牛,小弟才学VHDL,望指导。程序的本意是设计一个多输入与门。
1.设计一个两输入与门(这个简单能看懂)
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity myand1 is
port(a,b:in std_logic;
           qut std_logic);
end myand1;
architecture rtl of myand1 is
begin
        q<=a and b;
end rtl;
2.通过元件例化语句和generic语句修改输入变量数目,本程序设计为8个输入端口
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity myand is
generic (sreg_width:integer:=8);
port(indata:in std_logic_vector(sreg_width-1 downto 0);
                  qut std_logic);
end myand;

architecture rtl of myand is
signal z:std_logic_vector(sreg_width-1 downto 0);
        component myand1
                port(a,b:in std_logic;
                           qut std_logic);
        end component;
begin
z(sreg_width)<='1';--z是定义个的一个位矢量信号,怎么能给它赋1?最起码应该是“1111 1111”,还有z(sreg—width)这种书写格式没见过?
g1:for i in sreg_width-1 downto 0 generate--有for generate这个语句嘛,它的作用是?
u1:myand1 port map (z(i+1),indata(i),z(i));端口映射时的端口对应关系,还有z(i+1),indata(i),z(i));什么意思?
end generate;--generate都没见过
q<=z(0);
end rtl;



关键词: 程序     求解     logic    

助工
2013-07-05 21:42:51     打赏
2楼
1、z(sreg_width)<='1';--z是定义个的一个位矢量信号,怎么能给它赋1?最起码应该是“1111 1111”,还有z(sreg—width)这种书写格式没见过?
请看上面的:generic (sreg_width:integer:=8);表明sreg_width是个常量,所以z(sreg_width)表示z的第sreg_width位;
2、g1:for i in sreg_width-1 downto 0 generate--有for generate这个语句嘛,它的作用是?、
有,类似于C语言中满足什么条件就调用哪个函数。
3、u1:myand1 port map (z(i+1),indata(i),z(i));端口映射时的端口对应关系,还有z(i+1),indata(i),z(i));什么意思?
z(i+1)表示z的第(i+1)位,下同理

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]