正如小高斯曾告诉他的老师:
N *(1 + N)/ 2
或者用VHDL中的数字:
平均值以下为原文
Hi,
as little Gauss once told his teacher:
N*(1+N)/2
or with your numbers in VHDL:
mean <= 10*(1+10)/2;
Or did you ask for sth. different?
Have a nice synthesis
Eilert
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛扫一扫,分享给好友
|
大家好,有人可以给我一个关于如何平均给定数据的想法(例如小数1到10)。
谢谢。 以上来自于谷歌翻译 以下为原文 Hi everyone, can anyone please give me an idea about how to average the given data (for exampale say decimal 1 to 10). thank you. |
|
相关推荐
11个回答
|
|
|
嗨,
正如小高斯曾告诉他的老师: N *(1 + N)/ 2 或者用VHDL中的数字: 平均值以下为原文 Hi, as little Gauss once told his teacher: N*(1+N)/2 or with your numbers in VHDL: mean <= 10*(1+10)/2; Or did you ask for sth. different? Have a nice synthesis Eilert |
|
|
|
|
|
感谢您的回复,
很抱歉不提,平均值需要随机数(例如1234,5642,-1236 ...........最多10个数字)。 再次感谢你。 以上来自于谷歌翻译 以下为原文 Thanks for your reply, Sorry not for mentioning, the average is requires for random numbers(for ex. 1234,5642,-1236...........upto 10 numbers). once again thank you. |
|
|
|
|
|
您想要将十个数字加在一起并除以10.您如何做到这一点取决于
数字是如何进入的。它是串行的 - 例如,在连续的时钟周期中一次一个? 或者他们都会立刻出现,你需要每N个时钟处理10个新数字 周期? 或者有人在键入它们并且你有数以万计的时钟周期来进行数学运算? - Gabor 以上来自于谷歌翻译 以下为原文 You want to add the ten numbers together and divide by 10. How you do that depends on how the numbers come in. Is it serial - one at a time on successive clock cycles for example? Or do they all show up at once and you need to deal with 10 new numbers every N clock cycles? Or is someone keying them in and you have zillions of clock cycles to do the math? -- Gabor |
|
|
|
|
|
输入是来自DDS的正弦波,因为我必须采集连续数据Upto245个样本,然后我必须平均总结果。一个时钟脉冲中的一个样本。
谢谢... 以上来自于谷歌翻译 以下为原文 The input is a sine wave from a DDS, in that I have to take a continuous data Upto 245 samples, and then I have to average the total result., one sample in one clock pulse. Thank you... |
|
|
|
|
|
它必须是那样吗?
可以是256而不是吗? 如果2的幂,则容易得多 -------------------------------------------------- -------------------------------我喜欢这些书:Free Range VHDL(免费),http://www.freerangefactory .org / site / pmwiki.php / Main / BooksVHDL for Logic Synthesis,Andrew RushtonFPGA Prototyping by VHDL examples,Pong P Chu 以上来自于谷歌翻译 以下为原文 Does it have to be that? Can it be 256 instead? Much easier if a power of 2 --------------------------------------------------------------------------------- I like these books: Free Range VHDL (free), http://www.freerangefactory.org/site/pmwiki.php/Main/Books VHDL for Logic Synthesis, Andrew Rushton FPGA Prototyping by VHDL Examples, Pong P Chu |
|
|
|
|
|
是的,平均2 ^ n个数字很容易。
但在我的设计中,我只能停止使用245个样品......! 谢谢。 以上来自于谷歌翻译 以下为原文 Yes, It's easy to average 2^n numbers. But in my design i have to stop it with 245 samples only...! thank you. |
|
|
|
|
|
kumar1355f写道:
是的,平均2 ^ n个数字很容易。 但在我的设计中,我只能停止使用245个样品......! 谢谢。 那你就有了一个真正的问题。 与指定设计的人交谈并说出所要求的内容是不可能的。 ----------------------------是的,我这样做是为了谋生。 以上来自于谷歌翻译 以下为原文 kumar1355f wrote:Then you've got a real problem. Talk to the person who specified the design and say that what is being requested is not possible. ----------------------------Yes, I do this for a living. |
|
|
|
|
|
您可以通过缩放(并避免必须实现分频器电路)获得相当准确的平均值,例如:
avg = [sum(N)* 133] / 2 ^ 15(注意括号(N)* 133附近的括号) 基本上优化此等式:1/245 = x / 2 ^ n,以获得所需的精度。 因为你在2000年左右使用整数,所以应该没问题。 当然需要确保你不要溢出。 否则我建议你读一下整数分频器,你可以在这里找到:分区算法 -------------------------------------------------- -------------------------------我喜欢这些书:Free Range VHDL(免费),http://www.freerangefactory .org / site / pmwiki.php / Main / BooksVHDL for Logic Synthesis,Andrew RushtonFPGA Prototyping by VHDL examples,Pong P Chu 以上来自于谷歌翻译 以下为原文 You can get a reasonably accurate average by scaling (and avoiding having to implement a divider circuit) with something like: avg = [sum(N) * 133] / 2^15 (note the brackets around sum(N) * 133) Basically optimize this equation: 1/245 = x/2^n for your desired accuracy. Since you are working with integers around 2000 this should be fine. Of course need to ensure you don't overflow. Otherwise I would suggest reading up on integer dividers which you can find here: Division Algorithm --------------------------------------------------------------------------------- I like these books: Free Range VHDL (free), http://www.freerangefactory.org/site/pmwiki.php/Main/Books VHDL for Logic Synthesis, Andrew Rushton FPGA Prototyping by VHDL Examples, Pong P Chu |
|
|
|
|
|
嗨库马尔,
这只是一些“让他忙碌”的任务吗? 为您的老板/教授提供计算无限样本平均值的设计。 这会为你节省很多工作。 ;-) mean(sin(t = -inf - > + inf))= 0; 或者您可以用不太明显的方式表达它: 一种自适应算法,用于计算一个周期的平均值,与输入频率无关。 开玩笑吧。 :-) 但是你得到这个奇怪的规范背后的原因可能是什么? 它背后的真正意图是什么? 有一个很好的综合 Eilert 以上来自于谷歌翻译 以下为原文 Hi Kumar, Is this just some "keep-him-busy" assignment? Offer your boss/professor to make a design that calculates the average of infinite samples. That would save you a lot of work. ;-) mean(sin(t=-inf -> +inf)) = 0; Or you might phrase it in a less obvious way: An adaptive algorithm to calculate the average of one period, regardless of the input frequency. OK, just kidding. :-) But what might be the reason behind this strange specification you got? What's the true intention behind it? Have a nice synthesis Eilert |
|
|
|
|
|
有些事情需要注意:
平均N个样本需要求和,并除以N(或乘以1 / N)。 根据 根据你想要的平均值,有可能摆脱分裂/多重化。 例如 如果你想比较平均值和阈值,而不是除以N,你可以多次 阈值乘以N,然后与总和进行比较。 如果您事先知道N,并且N非常大(如果您想要平均值,可能就是这种情况 全帧视频的亮度)你通常可以通过连续减法来除法 当你总结数字。 即,在每个周期,您添加输入数字,如果总和大于 N同时减去N并递增翻转计数器。 在帧结束时,如果总和 仍然大于N,继续减去N并递增计数,直到总和小于 N.翻转计数将是平均值的整数部分,总和将具有余数。 当N与您平均的值处于同一数量级时,此方法效果最佳。 - Gabor 以上来自于谷歌翻译 以下为原文 Some things to note: Averaging N samples requires a summation, and division by N (or multiplication by 1/N). Depending on what you wanted the average for, it may be possible to get rid of the division/mulitiplication. For example if you wanted to compare the average to a threshold, instead of dividing by N, you could multiple the threshold by N and then do the compare against the sum. If you know N beforehand, and N is very large (this might be the case if you want the average brightness of a full frame of video) you can often get away with a division by successive subtraction as you sum the numbers. i.e. on each cycle, you add the input number and if the sum is greater than N subtract N at the same time and increment a roll-over counter. At the end of the frame, if the sum is still greater than N, continue to subtract N and increment the count until the sum becomes less than N. The roll over count will then be the integer part of the average, and the sum will have the remainder. This method works best when N is on the same order of magnitude as the values you're averaging. -- Gabor |
|
|
|
|
|
谢谢你们提出的很好的建议,我现在试图平均我对256个样本而不是245个样本的要求。
在最后阶段之后,我可能通过比较理论上的实际值来了解其差异。 以上来自于谷歌翻译 以下为原文 thankyou all for your great suggestions, im now trying to average my requirement for 256 samples instead of 245 samples. And after final stage only i might know the difference by comparing the theoritical n practical values. |
|
|
|
|
只有小组成员才能发言,加入小组>>
3141 浏览 7 评论
3435 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2897 浏览 9 评论
4097 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
3081 浏览 15 评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
1357浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
1195浏览 1评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-10 14:10 , Processed in 1.108495 second(s), Total 94, Slave 77 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
22016
