B
better_cs_now@yahoo.com
Guest
Hello all,
I'm having difficulties with the code below on my Spartan 3.
I've created an 8-bit RAM with 256 locations. It has the following
inputs:
wr_en
addr
data_in
My goal is to write the numbers 1 - 4 to addresses 1 - 4 of the RAM
(and then read them back).
In the code below, I never get out of the state SETUP_WRITE. I have a
feeling this has something to do with the way I'm using variables (as
opposed to signals), but I just don't see what I'm doing wrong.
In the code below, data_out is tied to some LEDs on my board.
Thanks,
Dave
seq: process(clk)
begin
if (rising_edge(clk)) then
if (reset = '1') then
current_state <= INIT;
else
current_state <= next_state;
end if;
end if;
end process seq;
comb: process(current_state)
variable addr_to_write: natural;
begin
case current_state is
when INIT =>
addr_to_write := 1;
next_state <= SETUP_WRITE;
when SETUP_WRITE =>
wr_en <= '1';
addr <= addr_to_write;
data_in <= std_logic_vector(to_unsigned(addr_to_write, 8));
addr_to_write := addr_to_write + 1;
if (addr_to_write /= 5) then
next_state <= SETUP_WRITE;
else
next_state <= READ_ADDR_1;
end if;
.
.
.
I'm having difficulties with the code below on my Spartan 3.
I've created an 8-bit RAM with 256 locations. It has the following
inputs:
wr_en
addr
data_in
My goal is to write the numbers 1 - 4 to addresses 1 - 4 of the RAM
(and then read them back).
In the code below, I never get out of the state SETUP_WRITE. I have a
feeling this has something to do with the way I'm using variables (as
opposed to signals), but I just don't see what I'm doing wrong.
In the code below, data_out is tied to some LEDs on my board.
Thanks,
Dave
seq: process(clk)
begin
if (rising_edge(clk)) then
if (reset = '1') then
current_state <= INIT;
else
current_state <= next_state;
end if;
end if;
end process seq;
comb: process(current_state)
variable addr_to_write: natural;
begin
case current_state is
when INIT =>
addr_to_write := 1;
next_state <= SETUP_WRITE;
when SETUP_WRITE =>
wr_en <= '1';
addr <= addr_to_write;
data_in <= std_logic_vector(to_unsigned(addr_to_write, 8));
addr_to_write := addr_to_write + 1;
if (addr_to_write /= 5) then
next_state <= SETUP_WRITE;
else
next_state <= READ_ADDR_1;
end if;
.
.
.