Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Hardware > Variable in state Machine going Crazy (VHDL)

Reply
Thread Tools

Variable in state Machine going Crazy (VHDL)

 
 
matrixofdynamism matrixofdynamism is offline
Junior Member
Join Date: Apr 2010
Posts: 1
 
      04-08-2010
OK here is the code for my state machine. I am using it to control a serial multiplier in my circuit/


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity seq_mult_stateMachine is
port(clk, reset, start : in std_logic;
load_multiplier, shift_multiplier, load_multiplicand : out std_logic;
reset_product, load_product, shift_product : out std_logic;
done : out std_logic;
the_state : out std_logic_vector(1 downto 0); -- for debugging purpose only
counter_out : out std_logic_vector(3 downto 0)
);

end entity seq_mult_stateMachine;

architecture seq_mult_stateMachine_Architecture of seq_mult_stateMachine is
type theStat is (S0, S1, S2, S3);
signal present_state: theStat := S0;
signal next_state: theStat;
signal counter : std_logic_vector(3 downto 0);
begin

seq: process (clk) is
begin
if(rising_edge(clk)) then
if(reset = '1') then
present_state <= S0;
elsif(reset = '0') then
report "reached here";
present_state <= next_state;
end if;
end if;
end process seq;

com: process(start, present_state) is

begin
load_multiplier <= '0';
shift_multiplier <= '0';
load_multiplicand <= '0';
reset_product <= '0';
load_product <= '0';
shift_product <= '0';
done <= '0';

-- using signal the_state for debugging
case present_state is
when S0 => the_state <= "00";
when S1 => the_state <= "01";
when S2 => the_state <= "10";
when S3 => the_state <= "11";
end case;
--

case present_state is

when S0 =>
if(start = '1') then
--Initializing
load_multiplier <= '1';
load_multiplicand <= '1';
reset_product <= '1';
counter <= "0000";
next_state <= S1;
else
next_state <= S0;
end if;

when S1 =>
load_product <= '1';
counter <= counter + '1';
next_state <= S2;

when S2 =>
shift_product <= '1';
shift_multiplier <= '1';

if(counter = "1111") then
next_state <= S3;
else
next_state <= S1;
end if;

when S3 =>
done <= '1';
next_state <= S0;

when others =>
next_state <= S0;

end case;
counter_out <= counter;
end process;

end seq_mult_stateMachine_Architecture;

When I implemented it, it did Not work correctly. Thus I was forced to put the_state and counter_out signals for debugging purpose. When I run the simulation in Quartus with the other blocks and put the Start input, the output is shown in the Attachment.

Problem: My 'counter' variable goes crazy once the state S1 is entered, it keeps increasing regardless of the state being changed and finally I get the error of setup time violation. It should change ONLY when the state changes right? thats how I wrote the code.

Please tell me why this is happening I have used I integer before but the same result.
Attached Images
File Type: jpg stateMachine_output.jpg (121.7 KB, 2 views)
 
Reply With Quote
 
 
 
 
jettlee1 jettlee1 is offline
Junior Member
Join Date: Apr 2010
Posts: 13
 
      04-27-2010
it have error.
 
Reply With Quote
 
 
 
 
rvndrlt rvndrlt is offline
Junior Member
Join Date: Oct 2010
Posts: 1
 
      10-02-2010
jettlee1 is clearly a brilliant person.
 
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
State machine - Vending machine - strange behaviour fenster VHDL 3 12-23-2011 09:53 AM
State machine going into unknown state axr0284 VHDL 6 07-07-2008 11:57 PM
XP search going all lame on me..explorer going crazy when trying tosearch. fotoobscura Computer Support 8 01-12-2008 01:09 AM
crazy browser go crazy dr greg Computer Support 7 01-14-2005 09:13 PM



Advertisments