Forum Discussion
Quirk with my clocks
I'm building a Binary Game for my final project in Digital Logic and Design and a small portion of this game I'm building uses a countdown timer to show how much time you have left in your round.
I hooked up a clock to my output and got it running, counting down 1 second at a time. Then I hooked up a second clock (same clock but I changed the clock divider by a factor of 10) to my other output and was wanting to have it countdown in 10 second intervals. And it does countdown in 10 second intervals the issue is that it counts down at the wrong time. The 10 second countdown is triggered on the 5 sec of the 1 sec. clock countdown. So I get 99.98.98.97.96.85.84.83.82.81.80.89.88.87.86.75.74.73.72.71.70.79....and so on..... Any quick fixes? Or has anyone had this issue before? I'm a complete newbie so talk slow and use small words :-P13 Replies
- Altera_Forum
Honored Contributor
I just wanted to give a big thank you to everyone who attempted to help me with my project...I've finally gotten to a point where I could turn it in right now if I had to which is a pretty awesome feeling since I still have a week and a half to work on it.
The only functionality that I have not yet been able to meet that I had set out for myself is retaining a high score for my game, and then displaying that score on the LCD screen. My thought is that I could use the lpm_compare megafunction to determine if the new number is higher than the old number and then output the higher of the 2 but it doesn't seem to work, the lpm_compare works just not when I make my circuit dynamic and have changing values. Does anybody have any ideas or things that I should check out that might point me in the right direction? We haven't covered any sort of rom or ram in our class...I tried figuring out the different memory megafunctions but I'm struggling. I appreciate any help... - Altera_Forum
Honored Contributor
If I understood your requirement, you want to get maximum of a stream of values. Then you can use a register with a bit of logic(assuming your stream is reg1 with positive values only):
Good luck with your scoresprocess(reset,clk) begin if reset = '1' then reg2 <= (others => '0'); elsif rising_edge(clk) then if reg1 > reg2 then reg2 <= reg1; end if; end if; end process; - Altera_Forum
Honored Contributor
Thanks Kaz, I got my high score working now, I didn't end up using the code you wrote but it got me thinking in the right way and I was able to build what I needed in the block diagram because of it.
Last question, I swear...as of right now I've got a 8 bit wire just dangling out there in my schematic and I need to convert it's output to display on the LCD display on the DE2 board. Ideally I'd like for the display to read "The Binary Game High Score: XX" Where the 2 Xs are the 2 digit high score...I've been reading on this site but I have absoluetly no coding experience and haven't a clue where to even begin or what I would even need to write to get it to display that way. We didn't use the LCD at all in my labs and was just something I wanted to see if I could get to work to make my project just a little something extra. When I get this thing working I'll throw a video on youtube and post the link here.