完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有一个简单的8位输入二进制问题,bcd显示为7seg。
我得到最后一个数字显示正常,但前两个仍然是黑暗的。 例如,11111111的8位二进制输入应显示255,但我只能显示5。 我附上了我目前的代码。 我一开始以为这是时钟,但我无法弄明白。 以下是七段显示的代码: 实体x7seg是 港口( x:在STD_LOGIC_VECTOR(15 downto 0); clk:在STD_LOGIC中; clr:在STD_LOGIC中; a_to_g:out STD_LOGIC_VECTOR(6 downto 0); an:out STD_LOGIC_VECTOR(3 downto 0); dp:输出STD_LOGIC ); 结束x7seg; 体系结构x7seg的行为是 信号s:STD_LOGIC_VECTOR(1 downto 0); 信号位:STD_LOGIC_VECTOR(3 downto 0); 信号aen:STD_LOGIC_VECTOR(3 downto 0); 开始 dp digit digit digit digit a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g a_to_g 变流器 实体BINtoBCD是 港口( b:在STD_LOGIC_VECTOR(7 downto 0); p:out STD_LOGIC_VECTOR(9 downto 0) ); 结束BINtoBCD; 建筑BINtoBCD的行为是 开始 bcdl:进程(b) 变量z:STD_LOGIC_VECTOR(17 downto 0); 开始 因为我在0到17循环 z(i):='0'; 结束循环; z(10 downto 3):= b; 因为我在0到4循环 如果z(11 downto 8)> 4那么 z(11 downto 8):= z(11 downto 8)+ 3; 万一; 如果z(15 downto 12)> 4那么 z(15 downto 12):= z(15 downto 12)+ 3; 万一; z(17 downto 1):= z(16 downto 0); 结束循环; p 和顶级 实体BINtoBCD_Top是 港口( mclk:在STD_LOGIC中; clr:在STD_LOGIC中; btn:在STD_LOGIC_VECTOR(3 downto 3); sw:在STD_LOGIC_VECTOR(7 downto 0); ld:out STD_LOGIC_VECTOR(7 downto 0); a_to_g:out STD_LOGIC_VECTOR(6 downto 0); an:out STD_LOGIC_VECTOR(3 downto 0); dp:输出STD_LOGIC ); 结束BINtoBCD_Top; 体系结构BINtoBCD_Top的行为是 组件BINtoBCD是 港口( b:在STD_LOGIC_VECTOR(7 downto 0); p:out STD_LOGIC_VECTOR(9 downto 0) ); 最终组件; 组件x7seg是 港口( x:在STD_LOGIC_VECTOR(15 downto 0); clk:在STD_LOGIC中; clr:在STD_LOGIC中; a_to_g:out STD_LOGIC_VECTOR(6 downto 0); an:out STD_LOGIC_VECTOR(3 downto 0); dp:输出STD_LOGIC ); 最终组件; 组件ClkDiv 港口( mclk:IN std_logic; clr:IN std_logic; clk:OUT std_logic ); 结束组成部分; 信号时钟:STD_LOGIC; 信号x:STD_LOGIC_VECTOR(15 downto 0); 信号p:STD_LOGIC_VECTOR(9 downto 0); 开始 - 连接BINtoBCD的零和输出 x sw, p => p ); X2:x7seg 港口地图( x => x, clk =>时钟, clr => clr, a_to_g => a_to_g, an => an, dp => dp ); X3:ClkDiv PORT MAP( mclk => mclk, clr => clr, clk =>时钟 ); 结束行为; 时钟分频器已连接。 这段代码来自VHDL示例书,但我不能让这个代码工作。 什么缺少的想法? clkdiv.vhd 2 KB 以上来自于谷歌翻译 以下为原文 I am having a problem with a simple 8-bit input binary to bcd displaying to 7seg. I get the last number to display fine, but the first two remain dark. For example 8-bit binary input of 11111111 should display 255 but I can only get the 5 to appear. I have attached my current code. I thought at first that it was the clock but I cannot figure it out. Here is the code for the Seven segment display: entity x7seg isport(x: in STD_LOGIC_VECTOR(15 downto 0);clk : in STD_LOGIC;clr : in STD_LOGIC;a_to_g : out STD_LOGIC_VECTOR(6 downto 0);an : out STD_LOGIC_VECTOR(3 downto 0);dp : out STD_LOGIC);end x7seg;architecture Behavioral of x7seg is signal s: STD_LOGIC_VECTOR(1 downto 0); signal digit : STD_LOGIC_VECTOR(3 downto 0); signal aen : STD_LOGIC_VECTOR(3 downto 0); begindp <= '1';-- set aen(3 downto 0) for leading blanksaen(3) <= x(15) or x(14) or x(13) or x(12);aen(2) <= x(15) or x(14) or x(13) or x(12)or x(11) or x(10) or x(9) or x(8);aen(1) <= x(15) or x(14) or x(13) or x(12)or x(11) or x(10) or x(9) or x(8)or x(7) or x(6) or x(5) or x(4);aen(0) <= '1'; -- digit 0 always on-- Quad 4-to-1 MUX: mux44process(s,x)begincase s is when "00" => digit <= x(3 downto 0);when "01" => digit <= x(7 downto 4);when "10" => digit <= x(11 downto 8);when others => digit <= x(15 downto 12);end case;end process;--// 7-segment decoder: hex7segprocess(digit)begincase digit is WHEN X"0" => a_to_g <= "0000001"; -- 0WHEN X"1" => a_to_g <= "1001111"; -- 1WHEN X"2" => a_to_g <= "0010010"; -- 2WHEN X"3" => a_to_g <= "0000110"; -- 3WHEN X"4" => a_to_g <= "1001100"; -- 4WHEN X"5" => a_to_g <= "0100100"; -- 5WHEN X"6" => a_to_g <= "1100000"; -- 6WHEN X"7" => a_to_g <= "0001111"; -- 7WHEN X"8" => a_to_g <= "0000000"; -- 8WHEN X"9" => a_to_g <= "0001100"; -- 9WHEN X"A" => a_to_g <= "0001000"; -- AWHEN X"B" => a_to_g <= "1100000"; -- BWHEN X"C" => a_to_g <= "0110001"; -- CWHEN X"D" => a_to_g <= "0100010"; -- DWHEN X"E" => a_to_g <= "0110000"; -- EWHEN others => a_to_g <= "0111000"; -- Fend case;end process;--Digit select: ancodeprocess(s, aen)begin an <= "1111";if aen(conv_integer(s)) = '1' thenan(conv_integer(s)) <= '0';end if;end process;-- 2-bit counterprocess(clk, clr)beginif clr = '1' then s <= "00";elsif clk'event and clk = '1' thens <= s+ 1;end if;end process; Converter entity BINtoBCD isport(b : in STD_LOGIC_VECTOR(7 downto 0);p : out STD_LOGIC_VECTOR(9 downto 0) );end BINtoBCD;architecture Behavioral of BINtoBCD i***eginbcdl : process(b)variable z : STD_LOGIC_VECTOR(17 downto 0);beginfor i in 0 to 17 loopz(i) := '0';end loop;z(10 downto 3) := b;for i in 0 to 4 loopif z(11 downto 8) > 4 thenz(11 downto 8) := z(11 downto 8) + 3;end if;if z(15 downto 12) > 4 thenz(15 downto 12) := z(15 downto 12) + 3;end if;z(17 downto 1) := z(16 downto 0);end loop;p <= z(17 downto 8);end process bcdl;end Behavioral; and Top Level entity BINtoBCD_Top isport(mclk : in STD_LOGIC;clr : in STD_LOGIC;btn : in STD_LOGIC_VECTOR(3 downto 3);sw : in STD_LOGIC_VECTOR(7 downto 0);ld : out STD_LOGIC_VECTOR(7 downto 0);a_to_g : out STD_LOGIC_VECTOR(6 downto 0);an : out STD_LOGIC_VECTOR(3 downto 0);dp : out STD_LOGIC);end BINtoBCD_Top;architecture Behavioral of BINtoBCD_Top iscomponent BINtoBCD isport(b : in STD_LOGIC_VECTOR(7 downto 0);p : out STD_LOGIC_VECTOR(9 downto 0));end component;component x7seg isport(x: in STD_LOGIC_VECTOR(15 downto 0);clk : in STD_LOGIC;clr : in STD_LOGIC;a_to_g : out STD_LOGIC_VECTOR(6 downto 0);an : out STD_LOGIC_VECTOR(3 downto 0);dp : out STD_LOGIC);end component;COMPONENT ClkDivPORT(mclk : IN std_logic;clr : IN std_logic; clk : OUT std_logic);END COMPONENT;signal clock : STD_LOGIC;signal x : STD_LOGIC_VECTOR(15 downto 0);signal p : STD_LOGIC_VECTOR(9 downto 0);begin-- concatenate zeros and output of BINtoBCDx <= "000000" & p;-- display binary value of switches on LEDsld <= sw;B1: BINtoBCDport map(b => sw,p => p);X2: x7segport map(x => x,clk => clock,clr => clr,a_to_g => a_to_g,an => an,dp => dp);X3: ClkDiv PORT MAP(mclk => mclk,clr => clr,clk => clock);end Behavioral; The clock divider is attached. This code is from a VHDL example book, I cannot, however, get this one to work. Any ideas what is missing? clkdiv.vhd 2 KB |
|
相关推荐
16个回答
|
|
嗨,
你有没有在行为模拟中检查你的代码? 在那里你可以看到内部信号的不当行为更容易。 如果您想快速浏览一下结果值,可以注释掉数字消隐部分并将其设置为“1111”以启用所有数字。 但我猜你会在那里看到零。 你应该检查你的BCD转换过程。 由于它是完全组合的,因此您需要观察变量在其delta周期中的变化。 不了解ISIM,但是Modelsim至少可以在列表窗口中做到这一点(也许实际版本也可以在波形中完成)。 顺便说一句:将SLV设置为零的循环? 怎么样: z:=(其他=>'0'); 有一个很好的模拟 Eilert 以上来自于谷歌翻译 以下为原文 Hi, have you checked your code in a behavioral simulation? There you could see mi***ehavior of internal signals much easier. If you want to take a quick glance at the resulting value, you might comment out the digit blanking part and set aen to "1111" to enable all digits. But I guess you will just see zeros there. You should check your BCD converting process. Since it is fully combinatorical you need to watch the variables change in their delta cycles. Don't know about ISIM, but Modelsim can do that at least in the list window (maybe actual versions can do it in the waveform too). btw: A loop for setting a SLV to zero? How about: z := (others => '0'); Have a nice simulation Eilert |
|
|
|
谢谢您的回复。
所有输入都来自digilint BASYS板,因此模拟不是很有用。 二进制到bcd转换器来自我的书。 此外,输出总是给我正确的右手编号,因此很明显转换器正在工作,我只是在七段显示器上的前两位数字没有显示时出现问题。 如果十进制数是128,我在显示屏上得到8,而53 ...我只看到3。 以上来自于谷歌翻译 以下为原文 Thank you for your reply. All of the inputs come from the digilint BASYS board, so the simulation isn't very helpful. The binary to bcd converter came from my book. Also, the output always gives me the correct right hand number so it is clear that the converter is working, I am just having a problem with the first two digits on the seven segment display not displaying. If the decimal number is 128, I get 8 on the display, and 53... I only see the 3. |
|
|
|
teerlinc写道:
谢谢您的回复。 所有输入都来自digilint BASYS板,因此模拟不是很有用。 你必须学会如何编写一个合适的测试平台。 然后模拟将非常有用。 ----------------------------是的,我这样做是为了谋生。 以上来自于谷歌翻译 以下为原文 teerlinc wrote:You must learn how to write a proper test bench. And then simulation will be very helpful. ----------------------------Yes, I do this for a living. |
|
|
|
|
|
|
|
teerlinc写道:
我的书中没有提到测试台的任何内容。 这并不意味着适当的测试平台并不重要。 这确实意味着你的书不完整。 基本上是一个测试台。 如果你想在FPGA设计方面有所作为,那么越早了解测试平台就越好。 比如说。 ----------------------------是的,我这样做是为了谋生。 以上来自于谷歌翻译 以下为原文 teerlinc wrote:That doesn't mean that a proper test bench is not important. It does mean that your book is incomplete. A test bench is essentially. If you want to have a career in FPGA design then the sooner you learn about testbenches, the better. See here, for example. ----------------------------Yes, I do this for a living. |
|
|
|
谢谢您的资源,我会检查出来。
但是,直到那时:据我所知,(书中说)我不能同时显示所有数字,时钟比我的眼睛快。可能它仍然是我的时钟造成问题吗? 正如你所看到的,我远离这个主题的任何职业。 这是我第一次。 :-)但是,我确实想了解。 以上来自于谷歌翻译 以下为原文 Thank you for the resource, I will check it out. But, until then: as I understand, (The book says) that I cannot display all of the numbers at once, unles the clock is faster than my eye. Could it still be my clock that is causing a problem? I am far from any career in this subject, as you can see. This is my first time. :-) But, I do want to understand. |
|
|
|
teerlinc写道:
谢谢您的资源,我会检查出来。 但是,直到那时:据我所知,(书中说)我不能同时显示所有数字,时钟比我的眼睛快。可能它仍然是我的时钟造成问题吗? 正如你所看到的,我远离这个主题的任何职业。 这是我第一次。 :-)但是,我确实想了解。 你一直在谈论一些你没有提到的书。 ----------------------------是的,我这样做是为了谋生。 以上来自于谷歌翻译 以下为原文 teerlinc wrote:You keep talking about some book, which you haven't named. ----------------------------Yes, I do this for a living. |
|
|
|
什么是输入时钟频率?
我看到它通过(一些可怕的和大的)织物时钟分频器。 所以,如果你的魔法书告诉你,如果时钟太慢,你就不会看到所有的数字,那么它的频率是多少? 更多详情! 问候, 霍华德 ----------“我们必须学会做的事情,我们从实践中学习。” - 亚里士多德 以上来自于谷歌翻译 以下为原文 What is the input clock frequency? I see that it goes through (some horrible and large) fabric clock divider. So, if you have been told by your magic book that you won't see all numbers if the clock is too slow, what frequency must it be? More detail! Regards, Howard ---------- "That which we must learn to do, we learn by doing." - Aristotle |
|
|
|
哦,谢谢大家,感谢您的亲切和慷慨的回复。
我的神奇书籍被Richard E Haskell和Darrin M Hanna称为“数字设计,使用Digilent FPGA板”。 时钟分频器,如果你看它,表明频率是q(17),或190.73赫兹。 这个特定时钟分频器的代码在第196页,第7.4节,清单7.18中,如果您对代码为何如此长久感到好奇,则必须联系作者。 我在上面列出的代码的描述在第5章,我使用的特定部分是5.3,它被称为“代码转换器”。 我正在使用shift和添加3算法,它在我的魔法书中以完全按照上面列出的形式给出。 该算法有效,前两位数字不显示。 如果有任何其他方式可以帮助您,请告诉我。 以上来自于谷歌翻译 以下为原文 Oh, thank you, everyone for your kind and generous replies. My magic book is called "Digital Design, Using Digilent FPGA Boards" by Richard E Haskell and Darrin M Hanna. The clock divider, if you look at it, shows that the frequency is q(17), or 190.73 hz. The code for this particular clock divider is on page 196, Section 7.4, Listing 7.18, you will have to contact the authors if you are curious about why the code is so long. The description of the codes I listed above are in chapter 5, the particular section I am using is 5.3, it is called "Code Converters". I am using the shift and add 3 algorithm, and it is given in my magic book in exactly the form listed above. The algorithm works, the first two digits are not displaying. If there is any other way that I can help you, let me know. |
|
|
|
暂时忽略时钟分频器的质量,如果增加频率会发生什么,即将低阶位作为输出?
q(8)例如。 ----------“我们必须学会做的事情,我们从实践中学习。” - 亚里士多德 以上来自于谷歌翻译 以下为原文 Ignoring for a moment the quality of the clock divider, what happens if you increase the frequency, i.e. take a lower order bit as an output? q(8) for example. ---------- "That which we must learn to do, we learn by doing." - Aristotle |
|
|
|
另一件事,“clr”输入如何在顶层驱动?
----------“我们必须学会做的事情,我们从实践中学习。” - 亚里士多德 以上来自于谷歌翻译 以下为原文 One other thing, how does the "clr" input get driven at the top level? ---------- "That which we must learn to do, we learn by doing." - Aristotle |
|
|
|
嗨,
你写了: “此外,输出总是给我正确的右手数字,因此显然转换器正在工作。” 好吧,只有一个最多三位数就不是一个很好的证明工作算法。 我会反过来说: 其中两个数字出错(可能为零),因此您的转换器无法正常工作。 您的显示器多路复用方案有点复杂,但应该可行。 频率应该是一个小问题,因为你可以看到一个数字。 如果您的数字多路复用太慢,您会看到数字跳跃,如果它太快,显示可能会变暗一点,但只有当您处于超过1 KHz或更高的范围内时才会发生这种情况。 如果您按照我的上一个建议来禁用数字消隐部分,您至少可以检查您的多路复用是否正常工作。 关于你使用的书: 从标题看,它似乎是如何在BASYS板上实现的指南。 这只是数字和系统设计的一个特殊部分,通常在设计阶段和使用测试平台完成的行为测试之后。 所以我并不感到惊讶,这本书不提模拟。 不过,你应该模拟你的设计。 与其他人一样说:它可以帮助您理解代码,对调试非常有用。 有一个很好的模拟 Eilert 以上来自于谷歌翻译 以下为原文 Hi, you wrote: "Also, the output always gives me the correct right hand number so it is clear that the converter is working." Well, having just one of up to three digits right isn't really a good proof for a working algorithm. I would argue the other way around: Two of the digits come out wrong (probably as zeros) so your converter isn't working correctly. Your multiplexing scheme for the displays is a little complicated, but should work. The frequency should be a minor problem, since you can see one digit. if your digit multiplexing would be too slow, you would see the digits hopping, and if it would be too fast, the displays might get dimmed down a little, but that happens only when you are in a range of over 1 KHz or more. If you would follow my last advice to disable the digit blanking part, you can at least check if your multiplexing is working. About the book you used: From the title it seemed to be some guide how to do implementations on the BASYS board. This is just one special part of digital and system design, which normally comes after the design phase and behavioral testing done with a testbench. So I'm not surprised that this book dosn't mention simulation. Still, you should do simulations of your designs. Like the others said: It helps you understanding your code, and is extremely useful for debugging. Have a nice simulation Eilert |
|
|
|
嗨,
你写了: “此外,输出总是给我正确的右手数字,因此显然转换器正在工作。” 这将(至少对我来说)指示信号s停留在“00” - 这是clr信号仍为“1”的可能信号。 当然,这在模拟中是显而易见的...... ----------“我们必须学会做的事情,我们从实践中学习。” - 亚里士多德 以上来自于谷歌翻译 以下为原文 Hi, you wrote: "Also, the output always gives me the correct right hand number so it is clear that the converter is working." This would indicate (to me, at least) that the signal s is stuck at "00" - a possible sign that the clr signal is still at '1'. Of course, this would be obvious under simulation ... ---------- "That which we must learn to do, we learn by doing." - Aristotle |
|
|
|
感谢大家的无条件支持。
我已经解决了问题,它确实是时钟和计数器之间的连接。 转换器没有改变,它可以完美地工作,如怀疑。 以上来自于谷歌翻译 以下为原文 Thank you, everyone, for your unconditonal support. I have fixed the problem, it was indeed a connection between the clock and the counter. The converter was not altered, it works perfectly, as suspected. |
|
|
|
如果有人能帮我解决这个问题请
开发同步(时钟)2位,模16二进制编码十进制(BCD)递增计数器的行为VHDL模型。 计数器应从0到15计数,然后再从0继续。 计数器应具有有效的高CLR信号,以便随时将其内容重置为0。 计数器的状态应显示在Nexys 2板的7段显示模块上。 CLK和CLR信号都应分别映射到按钮。 注意:当使用来自布什按钮的信号CLOCK为电路计时时,必须添加语句NET“CLOCK”CLOCK_DEDICATED_ROUTE = FALSE; 到您的.ucf文件。 您应该使用FPGA,7段显示器和Nexys 2板上的按钮来实现此计数器.a)分别为您的设计提供.vhd和.ucf文件的硬拷贝.b)映射您的电路 通过运行实施步骤,到位于FPGADevelopment Board上的Xilinx FPGA芯片。 在此之前,将UserConstraints(.ucf)文件添加到项目中,以便为您的设计进行正确的引脚分配。 Nexys 2 Board的Master .ucf文件可通过ClassWeb页面获得。 但是,您需要编辑它以仅保留您的.vhd文件中定义的那些信号。 仅转入设备利用率并分别使用Pad Report.Email的引脚分配部分:mass1311@yahoo.com 以上来自于谷歌翻译 以下为原文 If any one can help me to solve this problem please Develop a behavioral VHDL model of a synchronous (clocked) 2-digit, modulo-16 binary-coded-decimal (BCD) up counter. The counter should count from 0 up to 15 and then continue from 0 again. The counter should have an active high CLR signal to reset its contents to 0 at any time. The counter's state should be displayed on the 7-segment display module of the Nexys 2 Board. Both the CLK and the CLR signals should be mapped to pushbuttons, respectively. Note: when using signal CLOCK from a bush button for clocking your circuit you must add the statement NET "CLOCK" CLOCK_DEDICATED_ROUTE = FALSE; to your .ucf file. You should implement this counter using the FPGA, the 7-segment display and push-buttons on your Nexys 2 Board. a) Turn in a hard copy of the .vhd and .ucf files for your design, respectively. b) Map your circuit to the Xilinx FPGA chip that is located on your FPGA Development Board by running the Implement step. Before doing so, add a User Constraints (.ucf) file to your project to make proper pin assignments for your designs. The Master .ucf file for the Nexys 2 Board is available through the Class Web Page. However, you need to edit it to keep only those signals that are defined in your .vhd file. Turn in only the device utilization and used pin assignments sections, respectively, of the Pad Report. Email : mass1311@yahoo.com |
|
|
|
没有人会为你做功课。
搞清楚,这并不难。 -------------------------------------------------- -------------------------------我喜欢这些书:Free Range VHDL(免费),http://www.freerangefactory .org / site / pmwiki.php / Main / BooksVHDL for Logic Synthesis,Andrew RushtonFPGA Prototyping by VHDL examples,Pong P Chu 以上来自于谷歌翻译 以下为原文 No one is going to do your homework for you. Figure it out, it's not hard. --------------------------------------------------------------------------------- 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 |
|
|
|
只有小组成员才能发言,加入小组>>
2388 浏览 7 评论
2803 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2270 浏览 9 评论
3338 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2438 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
767浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
551浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
382浏览 1评论
1974浏览 0评论
691浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 08:08 , Processed in 1.568795 second(s), Total 106, Slave 90 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号