集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2883|回复: 4

vhdl中的component的定义及使用

[复制链接]
fpga_feixiang 发表于 2017-12-4 10:21:18 | 显示全部楼层 |阅读模式
对于你的问题1,2,3,4点我就以你举的这个8位寄存器来回答:
首先你的8位寄存器加入了clr这个复位信号,那么你的DFF也应该有这个信号,因此你的DFF中的PROCESS就应该改为:
process(clk)
begin
     if clr = '1' then
        Q <= '0'; --或者'X'
    elsif(clk'event and clk='1') then
         Q<=D;
    end if; --你这里忘写了
end process;
好,这下你的DFF正确了,我接着你的代码写8位的:
另外,不造成概念混淆,我把你8位的entity改成这样:
entity reg_8bit is
  port( clk_8, clr_8 : in std_logic;
           x : in std_logic_vector(7 downto 0); --downto 中间没有空格
           y: out std_logic_vector(7downto 0)
           );
end reg_8bit;
architecture arch_reg_8bit of reg_8bit is
component dff
generic(参数); --这个例子没有参数,所以不写这句。如果有,那么这个参数为定值,FPGA运行过程中无法被改变(因为在综合过程中已经被翻译成电路了)。 至于参数的使用方法,你百度一下很容易知道了。
port(
    clk,clr,D : in std_logic;
    Q : out std_logic
);
end component;
begin
generate_8_dff : for i in 0 to 7 generate
    dff_x : dff port map(
        clk => clk_8,
        clr => clr_8,
        D => x(i),
        Q => y(i)
    );
end generate generate_8_dff,
end arch_reg_8bit;
上面的for i in n to m generate 的目的只是为了复制m-n+1次电路,没有任何时序因素在其中,不要和C语言中的FOR循环搞混了。

点评

海!外直播 t.cn/RxlBL8s 禁闻视频 t.cn/Rxlbuea 把地表的资源用光,把地下的矿藏挖空,把子女财产转移到外国去,现在又把全球的垃圾运进来……他们和中国人民有血海深仇吗?到底是谁亡我之心不死?  发表于 2017-12-13 19:44
zxopenlz 发表于 2017-12-16 09:39:11 | 显示全部楼层
vhdl中的component的定义及使用
zxopenljx 发表于 2019-8-6 10:19:46 | 显示全部楼层
感谢楼主分享
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-4-25 10:30 , Processed in 0.073127 second(s), 32 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表