vhdl代码(for循环) [英] vhdl code (for loop)

查看:1921
本文介绍了vhdl代码(for循环)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想编写vhdl代码,它发现数组A中包含20个整数的最大整数。

问题:
我的算法应该是什么样的,输入顺序语句的位置?

我的vhdl代码:

  highnum:为0到19循环
i = 0;
i< 20;
i <= i + 1;
end loop highnum;

这并不需要综合,但我不知道如何形成循环的详细例子如何才能被赞赏。

解决方案

首先你应该知道你是如何在vhdl中定义数组的。
让我为你定义一个数组。

  type整数的array_of_integer数组(19 downto 0) 
信号A:array_of_integer:=(others => 0);
信号最大值:整数;
- 现在上面是整数的vhdl中的数组,所有的都被初始化为值0.

A(0)< = 1;
A(1)<= 2;
-
-
A(19)<= 19;
- 现在计算最大
max <= A(0)的for循环; (i(i)> max),则
max <= A(i);如果(A(i)> max)
end if;
结束循环;

- 现在如果您有问题需要下载哪部分代码---- vhdl实体格式..即进程,端口等...你可以回复!

Description: I want to write vhdl code that finds the largest integer in the array A which is an array of 20 integers.

Question:
what should my algorithm look like, to input where the sequential statements are?

my vhdl code:

highnum: for i in 0 to 19 loop
i = 0; 
i < 20; 
i<= i + 1;
end loop highnum;

This does not need to be synthesizable but I dont know how to form this for loop a detailed example explaining how to would be appreciated.

解决方案

First of all you should know how have you defined the array in vhdl. Let me define an array for you.

    type array_of_integer array(19 downto 0) of integer;
    signal A : array_of_integer :=(others => 0);
    signal max : integer;
    -- Now above is the array in vhdl of integers all are initialized to value 0.

    A(0) <= 1;
    A(1) <= 2;
    --
    --
    A(19)<= 19;
    -- Now the for loop for calculating maximum 
    max <= A(0);
    for i in 0 to 19 loop 
      if (A(i) > max) then 
        max <= A(i);
      end if;
    end loop;

-- Now If you have problems in understating that where to put which part of code .. in a ----vhdl entity format .. i.e process, ports, etc... you can reply !

这篇关于vhdl代码(for循环)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆