L
logitech
Guest
Hi!
I have one question about this code I wrote:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity sm is
port (mclk : in std_logic;
load_en : in bit;
output : out std_logic_vector(3 downto 0));
end sm;
architecture RTL of sm is
type state is (a,
b,
c);
signal current_state, next_state: state;
begin
state_machine: process
begin
wait until mclk = '1';
if load_en = '0' then
wait until load_en = '1';
current_state <= b;
else
current_state <= next_state;
end if;
case current_state is
when a =>
output <= "1000";
next_state <= b;
when b =>
output <= "0100";
next_state <= c;
when c =>
output <= "0010";
next_state <= a;
end case;
end process;
end architecture RTL;
-----------------------------
Question is: why ins't state changed on every rising clock? And how can
"current_state" and "next_state" be the same (like state "c" on 5th clock
period)... Here is picture:
http://i107.photobucket.com/albums/m308/tante_01/statemachine.gif?t=1218982255
I can't use sensitivity list because I must have "wait until" in my
states...
Thank you!
I have one question about this code I wrote:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity sm is
port (mclk : in std_logic;
load_en : in bit;
output : out std_logic_vector(3 downto 0));
end sm;
architecture RTL of sm is
type state is (a,
b,
c);
signal current_state, next_state: state;
begin
state_machine: process
begin
wait until mclk = '1';
if load_en = '0' then
wait until load_en = '1';
current_state <= b;
else
current_state <= next_state;
end if;
case current_state is
when a =>
output <= "1000";
next_state <= b;
when b =>
output <= "0100";
next_state <= c;
when c =>
output <= "0010";
next_state <= a;
end case;
end process;
end architecture RTL;
-----------------------------
Question is: why ins't state changed on every rising clock? And how can
"current_state" and "next_state" be the same (like state "c" on 5th clock
period)... Here is picture:
http://i107.photobucket.com/albums/m308/tante_01/statemachine.gif?t=1218982255
I can't use sensitivity list because I must have "wait until" in my
states...
Thank you!