完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我想通过VHDL代码制作模数程序,我已经制作了这个代码库IEEE;使用IEEE.std_logic_1164.all;使用IEEE.std_logic_arith.all;使用IEEE.STD_LOGIC_UNSIGNED.ALL;实体模数isport(clk:in std_logic; x:
在std_logic_vector中(2 downto 0); y:在std_logic_vector(2 downto 0); p:out std_logic_vector(5 downto 0)); end modulous; architecture modulus_arch of modulus issignal n:std_logic_vector(2 downto 0); signal s1:std_logic_vector (5 downto 0); beginmain:process(x,y,n,clk)beginif(rising_edge(clk))thenwhile s1ns1end loop; pn1end if; end process main; end modulus_arch;确实没有错误,编译,模拟,合成 ,实现已经完成,但是当我想看到测试台波形时,警告已经看到//警告:模拟器:29 - 在10.000 ns(1):警告:有一个'U'|'X'| 'W'|'Z'|' - '//并且没有显示所需的输出,我在'x'中给出了“110”。&amp; “011”在y中,我想计算5 mod 3,所以输出应为2,但我发现'6hXX' 以上来自于谷歌翻译 以下为原文 I want to make a modulus program by VHDL code, I have made this code library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity modulus is port (clk : in std_logic; x: in std_logic_vector(2 downto 0); y: in std_logic_vector(2 downto 0); p: out std_logic_vector(5 downto 0)); end modulous; architecture modulus_arch of modulus is signal n : std_logic_vector(2 downto 0); signal s1: std_logic_vector(5 downto 0); begin main: process(x,y,n,clk) begin if(rising_edge(clk)) then while s1<=x loop n<=n+"001"; s1<=n*y; end loop; p<=x-y*(n-"001"); n1<=n; end if; end process main; end modulus_arch; there is no error indeed, compilation,simulation, synthesize , implementation have been done , but when i want to see in test bench wave form following warning has been seen //WARNING:Simulator:29 - at 10.000 ns(1): Warning: There is an 'U'|'X'|'W'|'Z'|'-'// and dont show the desired output here i gave "110" in 'x'.& "011" in y, i want to calculate 5 mod 3, so output should be 2, but i found '6hXX' |
|
相关推荐
9个回答
|
|
在硬件中,“n”应该从零开始。
然而,在模拟中存在 模块中没有初始化值,因此它以'U'或'X'开头,因为 这取决于它自己永远不会离开这个状态。 尝试添加初始化 信号声明中的值为“n”。 HTH, 的Gabor - Gabor 以上来自于谷歌翻译 以下为原文 In the hardware "n" should start up as zero. In simulation, however there is no initialization value in your module, so it starts up as 'U' or 'X' and because it depends on itself never gets out of this state. Try adding an initialization value to "n" in the signal declaration. HTH, Gabor -- Gabor |
|
|
|
现在我初始化'n'和's',
但问题是一样的 输出是'你' 以上来自于谷歌翻译 以下为原文 now i initialize 'n' and 's', but the problem is same output is 'u' |
|
|
|
你确定while循环正在做你认为的吗?
请记住,您正在描述硬件,而不是编写微处理器。 为了合成一个while循环,合成器将需要展开循环,实质上是通过它在每个路径的硬件中重新创建循环内容 - 并且由于合成器可能无法推断出展开循环的次数,我可以' 真的看到你如何能够首先综合你的代码?... 以上来自于谷歌翻译 以下为原文 Are you sure the while loop is doing what you think it is? Remember that you are describing hardware, not programming a mircoprocessor. To synthesize a while loop, the synthesizer will need to unroll the loop, essentially recreating the loop contents in hardware for each path through it - and since the synthesizer probably wont be able to infer the number of times to unroll your loop, I can't really see how you have been able to synthesize your code in the first place?... |
|
|
|
rourabpaul写道:
我想通过VHDL代码制作模数程序,我已经制作了这个代码库IEEE;使用IEEE.std_logic_1164.all;使用IEEE.std_logic_arith.all;使用IEEE.STD_LOGIC_UNSIGNED.ALL;实体模数isport(clk:in std_logic; x: 在std_logic_vector中(2 downto 0); y:在std_logic_vector(2 downto 0); p:out std_logic_vector(5 downto 0)); end modulous; architecture modulus_arch of modulus issignal n:std_logic_vector(2 downto 0); signal s1:std_logic_vector (5 downto 0); beginmain:process(x,y,n,clk)beginif(rising_edge(clk))thenwhile s1ns1end loop; pn1end if; end process main; end modulus_arch;确实没有错误,编译,模拟,合成 ,实现已经完成,但是当我想看到测试台波形时,警告已经看到//警告:模拟器:29 - 在10.000 ns(1):警告:有一个'U'|'X'| 'W'|'Z'|' - '//并且没有显示所需的输出,我在'x'中给出了“110”。&amp; “011”在y中,我想计算5 mod 3,所以输出应为2,但我发现'6hXX' 哇,这是一些糟糕的代码。 敏感列表是错误的。 而且你真的需要了解非阻塞信号分配的整个概念。 信号不要以您明确期望的方式更新。 ----------------------------是的,我这样做是为了谋生。 以上来自于谷歌翻译 以下为原文 rourabpaul wrote:Wow, that's some awful code. The sensitivity list is wrong. And you really need to understand the whole notion of non-blocking signal assignments. Signals DO NOT update in the manner that you clearly expect. ----------------------------Yes, I do this for a living. |
|
|
|
“
哇,这是一些糟糕的代码。 敏感列表是错误的。 而且你真的需要了解非阻塞信号分配的整个概念。 信号不要以您明确期望的方式更新。 -------------------------------------------------- --------------请不要给我一个PM请求你的项目/家庭作业的帮助。 “ 它可能是我的项目或家庭工作,但我期待从这个网站的解决方案,但当你告诉一个问题 然后它也有必要表明问题,我的代码中的问题是什么?如果你不知道,那么你也不应该在这个主题上捅你的鼻子, 我也试过这个程序从敏感列表中删除'clk',并将's1'初始化为“000001”,将'n'初始化为“000”, 但问题是一样的, 你也可以在你的模拟器中试试这个代码, “ 你确定while循环正在做你认为的吗? 请记住,您正在描述硬件,而不是编写微处理器。 为了合成一个while循环,合成器将需要展开循环,实质上是通过它在每个路径的硬件中重新创建循环内容 - 并且由于合成器可能无法推断出展开循环的次数,我可以' 真的看到你如何能够首先综合你的代码?... “ 找到模数还有其他过程吗? 以上来自于谷歌翻译 以下为原文 " Wow, that's some awful code. The sensitivity list is wrong. And you really need to understand the whole notion of non-blocking signal assignments. Signals DO NOT update in the manner that you clearly expect. ---------------------------------------------------------------- PLEASE do NOT send me a PM asking for help with your project/homework." it may be my project or home work,but im expecting a solution from this site,but when u are telling about a problem then its also necessary to indicate the problem,whats the problem in my code ?if you dnt, then you also should not poke your nose in this topic, im have also tried this program removing 'clk' from sensitivity list,and also initialized 's1' as "000001" and 'n' as "000" , but the problem is same, u can also try this code in your simulator, " Are you sure the while loop is doing what you think it is? Remember that you are describing hardware, not programming a mircoprocessor. To synthesize a while loop, the synthesizer will need to unroll the loop, essentially recreating the loop contents in hardware for each path through it - and since the synthesizer probably wont be able to infer the number of times to unroll your loop, I can't really see how you have been able to synthesize your code in the first place?... " is there any other process to find modulus? |
|
|
|
rourabpaul写道:
“ 哇,这是一些糟糕的代码。 敏感列表是错误的。 而且你真的需要了解非阻塞信号分配的整个概念。 信号不要以您明确期望的方式更新。 -------------------------------------------------- --------------请不要给我一个PM请求你的项目/家庭作业的帮助。 “ 它可能是我的项目或家庭工作,但我期待从这个网站的解决方案,但当你告诉一个问题 然后它也有必要表明问题,我的代码中的问题是什么?如果你不知道,那么你也不应该在这个主题上捅你的鼻子, 首先 - 我会在我希望的地方戳我的鼻子。 第二 - 你不应该期待一个解决方案。 第三 - 问题是你的代码。 我也试过这个程序从敏感列表中删除'clk',并将's1'初始化为“000001”,将'n'初始化为“000”, 但问题是一样的, 你也可以在你的模拟器中试试这个代码, A)clk是唯一应该在灵敏度列表上的信号! B)信号n1从未在任何地方声明,因此代码甚至不编译。 C)你不应该使用std_logic_arith,而是使用numeric_std。 ----------------------------是的,我这样做是为了谋生。 以上来自于谷歌翻译 以下为原文 rourabpaul wrote: ----------------------------Yes, I do this for a living. |
|
|
|
当我编译它时,n1线必须关闭,否则它显然不会编译,(我使用信号而不考虑它,哇,我真的不是那种类型的婴儿)
实际上我想检查'n',所以我写了那行, 我也试过withnumeric_std,但结果是一样的。 你也可以在你的模拟器中尝试它(删除'n','x','y'), 我知道你真的很忙,有时间帮助学习者,但有时间戳, 我想在这种情况下你应该忽略这个话题, 以上来自于谷歌翻译 以下为原文 when i was compiling it the n1 line must be off,otherwise it obviously doesnt compile,( im using a signal without considering it,wow im not really that such type of infant) actually i want to check the 'n',so i wrote that line, and i also tried with numeric_std,but the result is same. u can try it also in your simulator(removing 'n','x','y'), i know you are really busy person who havnt time to do help a learner but hav time to poke, i think in this case you should ignore this topic, |
|
|
|
首先,您需要记住,您编写的代码需要是可以转换为硬件的代码。
如果您不理解这一点,那么编写一些实际可行的FPGA代码将非常困难...... 如果你正在模拟某个数n,即2的幂,那么模数运算符可以非常容易地实现 - 在这种情况下,你可以取出最后的n-1位作为结果,就是这样。 但是对于任何其他数字,在VHDL中没有快速的方法。 我能想到的两个最佳解决方案是: 1:创建一个小型状态机来执行计算 - 这需要一些额外的编码,并且需要一个以上的时钟周期才能完成,但应该可以非常巧妙地完成。 2:实例化一个分隔符,例如使用CoreGen - 这里的分隔符有一个余数输出,它与模数相同。 但是,这些将使用多个时钟,具体取决于操作数的大小。 但同样,最重要的是要了解您编写的不同编码语句与哪种硬件相关 - 一本好的VHDL书籍可能能够帮助您解决这个问题。 以上来自于谷歌翻译 以下为原文 First of all, you need to remember that the code you write needs to be something that can be turned into hardware. If you do not understand this, then it's going to be very hard to write some FPGA code that actually works... A modulus operator can be implemented very easily if you're doing modulus of some number, n, that's a power of 2 - in this case you can just take out the last n-1 bits as the result, and that's it. For any other numbers though, there is no fast way to do it in VHDL. The two best solutions I can think of is to: 1: Create a small state machine to perform the calculation - this will take some additional coding, and will take more than one clock cycle to complete, but it should be possible to do it pretty neatly. 2: Instantiate a divider, for instance using CoreGen - the dividers in here have a remainder output, which is the same number as the modulus. These will use more than a single clock also though, depending on the size of the operands. But again, the most important thing is to understand what kind of hardware the different coding statements you write relate to - a good VHDL book might be able to help you with this. |
|
|
|
通常虽然不推荐使用循环进行合成,但即使在for循环中,两个限制也必须是静态的。
例如。 对于i在0到7循环 - 是一个有效的声明。 然而, for i in 0 to user_in loop --user_in是输入端口信号无效。 顺便说一句,你的目标是什么。 FPGA怪胎 以上来自于谷歌翻译 以下为原文 Generally while loop is not recommended for synthesize, even in the for loop both the limits must be static. for example. for i in 0 to 7 loop --is a valid statement. whereas, for i in 0 to user_in loop --user_in is an input port signal is not valid. BTW, what is your objective. FPGA freak |
|
|
|
只有小组成员才能发言,加入小组>>
2378 浏览 7 评论
2793 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2260 浏览 9 评论
3334 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2426 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
753浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
540浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
363浏览 1评论
1957浏览 0评论
680浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-20 19:26 , Processed in 1.240399 second(s), Total 91, Slave 75 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号