MEM <= OVERLOAD
Finally sat down today to learn some VHDL on my Spartan 3 Starter Board … which I bought about 2 years ago now…
So far I can do the following:
- Control LEDs with push buttons
- Control the Segment LED array on the board based on switches and pushbuttons
- Blink the decimal point segments at 1Hz.
The first hurdle in this process is actually using the Xilinx ISE. Xilinx has several tutorials but they don’t go very far. I have yet to find a good tutorial on how to use a clock – which was annoying when it came to #3 in the list above.
Once I had learnt my way around the IDE, #1 and #2 were fairly easy. #3 as I mentioned above was trickier because there was somewhat limited information on how to use clocks. So far, I am generating 1Hz using a counter and counting up until my 50MHz clock has reached 1 second of delay.
process(Clk)
variable counter_1Hz:integer range 0 TO 50_000_000;
begin
if Clk'event and Clk = '1' then
counter_1Hz := counter_1Hz + 1;
if counter_1Hz = 50_000_000 then
tmp_clk_1Hz <= not tmp_clk_1Hz;
counter_1Hz := 0;
end if;
end if;
end process;What I am doing above is basically waiting for the clock to generate an event. In that event, I check to see if the value of the clock signal is ’1′ (or high). This basically translates to “wait till a high transition”. When this happens, I increment a counter. When the counter reaches 50000000, 1 second has passed and I toggle the tmp_clk_1Hz signal.
There are some other keywords I still have to look into like PERIOD and TIMESPEC. It looks like you can do some sort of dividing here. It would be more convenient to just generate slower clock signals through the User Constraints File (.ucf) where you map your logical signals to actual pins on the IC.
That said, this is fun. It’s somewhat weird the way VHDL works if you are coming from a procedural world of programming, but it’s fantastic in the sense that things are sort of on automagic. You just tell LED that it’s “equal to” CLK_1Hz and from then on, whatever CLK_1Hz does, LED does too. No loops, no weird threading etc.
I intend to use the board for powering the LavaLamp project. It’s probably overkill. But it’ll be a good excuse to learn more VHDL and actually use this damn board.