Altera_Forum
Honored Contributor
16 years agoNeed help creating a simple 32bit counter
I'm trying to learn VHDL so I thought I'd try converting the "my_first_fpga" example from verilog to VHDL (how complicated can adding one to a number be?), three hours later, lots of googling and searching through books has yielded no result. Sorry if this is the wrong place to ask (if so where is a better place?)
So I run this code through the simulator, apply a 50Mhz clock to CLK and get nothing from the counter bus. to make sure the process is running I output CLK to OUT, if I hard code a value ie X"FFFF0000" to counter it outputs that value but counter := counter +1 gets me no where. Also is it possible to step through code as with C? Here is my code:-- import std_logic from the IEEE library
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
-- this is the entity
entity counter_example is
port (
CLK : in std_logic;
OUT1: out std_logic;
Q : out std_logic_vector(31 downto 0));
end counter_example;
architecture counter_code of counter_example is
begin
process (CLK)
variable counter : std_logic_vector(31 downto 0);
begin
counter := counter + 1;
OUT1 <= CLK; -- Sanity Check that I am actually outputting something
Q <= counter;
end process;
end counter_code;Thanks.