Hi Don,
Excellent work.
Its much better for you to find things, try them, and then ask questions, and the questions are then meaningful to you.
--- Quote Start ---
I went online to find examples so I could see what they are doing and hopefully cobble some bits together to make mine
So far I had only used STD_LOGIC_1164 but looking online the example that looked most usefull used IEEE.Numeric.STD
From this I think they used " Unsigned " .
To be honest I dont understand why they used it but gave it a go anyway
--- Quote End ---
VHDL is a type-safe language. It will not let you do something without first seeing a function that says a particular function is safe. For example, std_logic_vector just defines a vector of bits, whereas signed and unsigned define vectors of bits with mathematical operations, eg., you can add and subtract to signed and unsigned numbers, since they are supposed to be interpreted as numbers, not just bits on a bus or in a regsiter.
--- Quote Start ---
I made my entity with a clk input and q output (27 downto 0)
for the architecture I declared a signal called count and told it
on the rising edge of clk to assign the value of " count + 1 " to the present value of "count"
then told it that "q" is assigned this new updated value of "count"
It took a few goes to get the syntax right so that everything compiled ok
but eventually got there
--- Quote End ---
Great!
--- Quote Start ---
I assigned the pins so that the 50Mhz clk went to the clk input and I chose several tries at which "q" I used for the output
till I found that q(24) seemed a good speed
--- Quote End ---
log2(50M) = 25.6-bits, i.e., a toggle rate of about 1 second will occur for a 26-bit counter, so your LED would have appeared to blink once every second or so.
--- Quote Start ---
I programed it to the DE2-115 and it did exactly as I wanted , flashing the first LED on and off , but for some reason there are random characters running across
the LCD screen too, I dont know why as I have assigned no other pins ?
--- Quote End ---
If you checked the .pin file and the LCD pins were defined as INPUT or INPUT_WITH_WEAK_PULLUP or something like that (maybe it is RESERVED, I forget, its been a while since I've looked at a .pin file), then those characters could just be left over from the default design that loads at power-on.
--- Quote Start ---
Once this was working I made a second copy of the program but this time assigned the outputs Q24-Q27 to four LEDs and instead of feeding pulses from the
50Mhz clock I used one of the push buttons , so that it gave a binary count on the LEDs that increased with each push of the button
It skipped now and again but I expect that is just switch bounce
--- Quote End ---
That sounds about right. Although if you connected the LEDs to the MSBs of your counter, you would have had to press the switch about 50 million times to see them blink ...
--- Quote Start ---
I have been thinking about the 7 segment display and decoding it
I can see that if I take my 4 bit binary output from this last design that I could possibly work out how to decode it using case statements.
If I make it have (3 downto 0) for the 4 inputs and (6 downto 0) for the 7 outputs to the segments
What I am not sure of is can I make this second entity and architecture for the decoder in the same file as the counter section or can I only have one entity per VHD file
in which case I am not sure how I make one file talk to the other , thats something else I must read up on
--- Quote End ---
You've described the right circuit. You can start to cheat now. I've posted a DE2 example to the forum in the past (different board than you have);
See Post#5
http://www.alteraforum.com/forum/showthread.php?t=33462 See Post#2
http://www.alteraforum.com/forum/showthread.php?t=35687 See Post#9
http://www.alteraforum.com/forum/showthread.php?t=45770 This last one includes a Modelsim simulation. You'll want to learn how to use the simulator.
If you take a look at my examples that blink an LED, you'll see them parameterized using generics. This is so that you can change the generics in simulation. For example, there is no point in waiting 1 second for an LED to blink in simulation, as that takes way too long to run. Using generics allows you to change the functionality of the design without changing the code (since the generics can be changed on the "command-line" of the synthesis or simulation tool).
Cheers,
Dave