完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
|
你好,
我是VHDL的新手,已被分配了使用VHDL生成随机数的任务。 我接受了'设计师; Ashenden的VHDL指南'的帮助。 但是,我已经遇到了代码,无法进行相同的调试。 我随函附上以下代码: _____________________________________________________________________________________________ 库IEEE;使用IEEE.STD_LOGIC_1164.ALL;使用IEEE.STD_LOGIC_ARITH.ALL;使用IEEE.STD_LOGIC_UNSIGNED.ALL;包random_types是子类型ALU_func是无符号的(3 downto 0); 子类型数据字是无符号的(15 downto 0); end random_types; ___________________________________________________________________________________________ 库IEEE;使用IEEE.STD_LOGIC_1164.ALL;使用IEEE.STD_LOGIC_UNSIGNED.ALL;使用IEEE.NUMERIC_STD.ALL;使用IEEE.NUMERIC_bit.ALL;使用IEEE.MATH_REAL.ALL;库工作;使用work.random_types.all; entity random_number_gen 是端口(结果:输出数据字);结束random_number_gen;架构random_number_gen的行为信号a:数据字;共享变量seed1,seed2:positive:= 1;共享变量a_real:real; begin uniform(seed1,seed2,a_real); 结果行为结束; _________________________________________________________________________ 我得到的错误是: HDLParsers:800 - “C:/Xilinx/work/random_number_gen/random_number_gen.vhd”第44行.a的类型与to_unsigned的类型不兼容。 请帮我调试!!!! 我突出了错误的一行。 以上来自于谷歌翻译 以下为原文 Hello, I am new to VHDL and have been assigned the task of generating random numbers with VHDL. I have taken help from 'The Designer;s Guide to VHDL by Ashenden'. However, I have got stuck with the code and cannot debug the same. I am enclosing the code herewith: _____________________________________________________________________________________________ library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; package random_types is subtype ALU_func is unsigned (3 downto 0); subtype dataword is unsigned (15 downto 0); end random_types; ___________________________________________________________________________________________ library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; use IEEE.NUMERIC_STD.ALL; use IEEE.NUMERIC_bit.ALL; use IEEE.MATH_REAL.ALL; library work; use work.random_types.all; entity random_number_gen is Port ( result : out dataword); end random_number_gen; architecture Behavioral of random_number_gen is signal a: dataword; shared variable seed1, seed2 : positive := 1; shared variable a_real:real; begin uniform(seed1, seed2, a_real); a <= to_unsigned(natural(a_real*real(2**integer'(dataword'length))-0.5),dataword'length); result <= a; end Behavioral; _________________________________________________________________________ The error that i get is: HDLParsers:800 - "C:/Xilinx/work/random_number_gen/random_number_gen.vhd" Line 44. Type of a is incompatible with type of to_unsigned. Please help me in debugging it!!!! I have highlighted the line in error. |
|
相关推荐
4个回答
|
|
|
嗨,
首先,你不应该将std_logic_arit / unsigned与数字标准混合使用。 然后,您的包随机类型也应该使用numeric_std。 如果仍然存在错误,您应该检查,ISE已经在实体之前识别并编译了包裹。 如果您想完全确定它,可以将子类型定义放入您的体系结构中,以进行测试。 只是为了看它是否有所作为。 有一个很好的综合 Eilert 以上来自于谷歌翻译 以下为原文 Hi, first of all, you shouldn't mix std_logic_arit /unsigned with numeric std. Then, your package random types should use numeric_std too. If the eror still remains you should check, wether ISE has recognized and compiled the package before the entity. If you want to be absolutely sure about it, you can put the subtype definitions into your architecture, for testing purposes. Just to see if it makes a difference. Have a nice synthesis Eilert |
|
|
|
|
|
如果你真的想要伪随机数,我强烈推荐XAPP052.http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf我真的无法用真正的随机数帮你...
------------------------------------------“如果它不起作用 模拟,它不会在板上工作。“ 以上来自于谷歌翻译 以下为原文 If you actually want psuedorandom numbers, I strongly recommend XAPP052. http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf I can't help you at all with really random numbers... ------------------------------------------ "If it don't work in simulation, it won't work on the board." |
|
|
|
|
|
我也试过了,但它不起作用。
我需要根据概率分布生成0到20范围内的随机数。 我不确定vhdl是否支持!!! 我已经阅读了一些关于实数不可合成的文档! 你可以告诉我在哪里可以找到有关vhdl内置包的详细信息的材料??? 以上来自于谷歌翻译 以下为原文 I have tried that also but it does not work. I need to generate random numbers in the range of zero to twenty according to a probibility distribution. I am not sure if vhdl supports that!!! I have read some documents on real numbers being not synthsizable! Can u please tell me where i can find materials on the details of the built-in packages of vhdl??? |
|
|
|
|
|
我认为你在这里提出了错误的问题.XAPP052提供了有关实现不同字深的统一伪随机数的信息。那么你需要的是从Uniform到你所需的概率分布的转换函数。
对高斯/普通的那个是众所周知的,其他一些也是如此。然后缩放到你想要的范围。或者,用C语言写它并在PicoBlaze / MicroBlaze /等上运行它。 ------------------------------------------“如果它不起作用 模拟,它不会在板上工作。“ 以上来自于谷歌翻译 以下为原文 I think that you are asking the wrong question here. XAPP052 gives information on implementing essentially Uniform pseudorandom numbers of varying word depths. What you then need is a transformation function from Uniform to your required probability distributuon. That to Gaussian/Normal is well known, so are some others. Then scale to your desired range. Or, write it in C and run it on a PicoBlaze/MicroBlaze/etc. ------------------------------------------ "If it don't work in simulation, it won't work on the board." |
|
|
|
|
只有小组成员才能发言,加入小组>>
3118 浏览 7 评论
3407 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2874 浏览 9 评论
3966 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
3057 浏览 15 评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
1325浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
1167浏览 1评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 13:24 , Processed in 0.963084 second(s), Total 81, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2088
