Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > fsm 4 states only one state displaying other 3 no..

Reply
Thread Tools

fsm 4 states only one state displaying other 3 no..

 
 
harrama harrama is offline
Junior Member
Join Date: Oct 2011
Posts: 9
 
      12-15-2011
HI ..i written code for 4 states fsm behav model and testbench model after ran in ghdl simulator only one state is displaying ...whats the problem?

entity mealy is
port (clk : in std_logic;
reset : in std_logic;
input : in std_logic;
output : out std_logic_vector(3 downto 0)
);
end mealy;
architecture behav of mealy is
type state_type is (s0,s1,s2,s3);
signal current_s,next_s: state_type;
begin
process (clk,reset)
begin
if (reset='1') then
current_s <= s0;
elsif (rising_edge(clk)) then
current_s <= next_s;
end if;
end process;

process (current_s,input)
begin
case current_s is
when s0 =>
if(input ='0') then
output <= '0';
next_s <= s1;
else
output <= '1';
next_s <= s2;
end if;

when s1 =>
if(input ='0') then
output <= '0';
next_s <= s3;
else
output <= '0';
next_s <= s1;
end if;

when s2 =>
if(input ='0') then
output <= '1';
next_s <= s2;
else
output <= '0';
next_s <= s3;
end if;


when s3 =>
if(input ='0') then
output <= '1';
next_s <= s3;
else
output <= '1';
next_s <= s0;
end if;
end case;
end process;
end;

entity mealy_tb is
end mealy_tb;
architecture test of mealy_tb is
signal clk,reset,input:std_logic;
signal output: std_logic;
begin
uut: entity work.mealy port map(clk=>clk,reset=>reset,input=>input,output=>out put);
process is
begin
input<='0';
wait for 2 ns;
input<='1';
wait for 2 ns;
input<='0';
wait for 2 ns;
input<='1';
wait for 2 ns;
input<='0';
wait for 2 ns;
input<='1';
wait for 2 ns;
input<='0';
wait for 2 ns;
input<='1';
wait for 2 ns;
wait;
end process;
end;
thanks in advance
Regards
Raghavendra Reply With Quote
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fsm state encodings Caterpillar VHDL 1 02-10-2006 05:42 PM
FSM with more than 1 input at each state swiss student VHDL 2 05-26-2005 10:49 AM
Which FSM State? Jake VHDL 0 10-25-2004 09:52 PM
FSM in illegal state Jerker Hammarberg \(DST\) VHDL 48 07-21-2004 06:05 PM
FSM (Finite State Machine) Generator - Open Source Roberto Nunnari Java 2 02-04-2004 07:16 AM



Advertisments