赛灵思
直播中

李启华

7年用户 188经验值
私信 关注
[问答]

VHDL中的排序算法怎么实现?

大家好!
我想基于几点来实现排序算法:
- 我有一组存储在BRAM中的号码。
这些数字以单精度浮点格式表示,我可以拥有的最大数字是400;
- 电路应该能够读取BRAM中的数字,对它们进行排序并在另一个BRAM中写入已排序的“列表”;
-  BRAM只有一个可用于读/写的端口;
所以我对解决这个问题的最佳方法有几点疑问:
- 由于存储在BRAM中的元素数量是可变的,有没有办法动态分配内存来存储我读取的数字?
我能从中获得一些东西吗?
或者,因为我知道数字的最大大小,即使我不使用某些位置,最好有400大小的数组?
- 由于我只有一个端口可用,这意味着我一次只能读一个号码,对吧?
您是否认为阅读整个BRAM更好,进行排序(使用quicksort或mergesort)然后将结果写入其他BRAM?
或者在我从BRAM阅读的同时,我也正在对已读取的数字进行某种排序(例如,插入排序)?
抱歉这些“新手”问题,但我对VHDL很新。
提前致谢。
最好的祝福!

以上来自于谷歌翻译


以下为原文

Hello everyone!

I want to implement a sorting algorithm based on a few points:
  - I have a set of numbers stored in a BRAM. These numbers are represented in single-precision floating-point format and the maximum numbers that I can have is 400;
  - The circuit should be able to read the numbers from the BRAM, sort them and write the sorted "list" in another BRAM;
  - The BRAM's only have one port available for reading/writting;

So I'm having a few questions on the best way to approach this problem:
  - Since the number of elements stored in the BRAM is variable, is there any way of dynamically allocate memory to store the numbers I read? Do I gain something with this? Or since I know the maximum size of numbers, it is better to have a 400 size array even if I don't use some of its positions?
  - Since I only have one port available, this means I can only read one number at a time, right? Do you think it is better to read the whole BRAM, do the sort (with quicksort or mergesort) and then write the result to the other BRAM? Or at the same time I am reading from the BRAM, I'm also doing some sort with the numbers already read (with insertion sort, for example)?

Sorry about these "newbie" questions but I'm quite new to VHDL.

Thanks in advance. Best regards!

回帖(2)

陈苏文

2019-3-29 13:53:45
*分配:fpga上可用的总内存是固定的。
您只能使用设计所引用的内存,以便实例化您需要的所有BRAM(甚至所有BRAMS)。
有一个存储器,用于存储使用量。*排序算法:确定哪种排序算法适合您的需要。
还注意到brams有一个读取,一个写入端口,它们有不同的宽高比。
实际上你可以制作1个64位宽(也就是2个数字)并且并排放多个来访问你的所有数字,你会有更多的brams但是在极端情况下你可以同时读取所有400个数字并设计400
输入比特式分拣机。
另一个极端是使用一个bram并在适当的位置排序。
- 如果提供的信息有用,请将答案标记为“接受为解决方案”。给予您认为有用且回复的帖子。

以上来自于谷歌翻译


以下为原文

* allocation: the total memory available on fpga is fixed. You can only use memory to which your design refers so instantiate all BRAMS you need (all of them even). Have a register which stores how much is used.
* sort algorithm: decide which sorting algorithm suits your needs. also notice that brams have one read, one write port and they come in different aspect ratios. in fact you can make 1 bram 64 bit wide (ie 2 numbers) and put many side by side to access all your numbers, you would have a lot more brams but in the extreme case you can read all 400 numbers simultaneously and design a 400 input bitonic sorter. Other extreme is use one bram and sort in place.- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
举报

吴萍

2019-3-29 14:10:01
在我的情况下,我有一个Spartan 3E-FPGA,设备是XC3S100E,因此我只有4个BRAM可用,其中一个用于读取无序数字,另一个用于写入已经订购的数字!

以上来自于谷歌翻译


以下为原文

In my case, I have a Spartan 3E-FPGA and the device is the XC3S100E so I only have 4 BRAM availables from which one is just for reading the unordered numbers and another one is for writing the already ordered numbers!
举报

更多回帖

发帖
×
20
完善资料,
赚取积分