Altera_Forum
Honored Contributor
18 years agoFSM behaving strangely
I have a simple set of VHDL code that steps through an FSM doing certain things. It compiles fine and I can design my test waveform. However when I run the simulation some of the pins don't show up in the results and outputs that are goverened by what happens to those pins don't get any values.
Specifically the pins that don't show up are the isLoadInstruction,isStoreInstruction etc.LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all ;
USE ieee.std_logic_unsigned.all;
ENTITY fsm IS
PORT(clock,reset,isLoadInstruction,isStoreInstruction,isAddInstruction,isMultiplyInstruction,regSource1,regSource2,regDestination: IN STD_LOGIC;
PC: BUFFER STD_LOGIC_VECTOR(15 DOWNTO 0);
readInstructionMemory,readRegs,writeRegs,performAdd,performMultiply,readDataMemory,writeDataMemory: OUT STD_LOGIC);
END fsm;
ARCHITECTURE Behavior OF fsm IS
TYPE State_type IS(A,B,C,D,E);
SIGNAL state: State_type;
BEGIN
PROCESS(clock)
BEGIN
IF Reset = '1' THEN
state<=A;
PC<="0000000000000000";
ELSIF(clock'EVENT AND clock='1') THEN
CASE state IS
WHEN A=>
readInstructionMemory <= '1';
readRegs <= '0';
writeRegs <='0';
performAdd <= '0';
performMultiply<='0';
readDataMemory<='0';
writeDataMemory<='0';
state<=B;
WHEN B=>
readRegs <= '1';
PC <= PC + 1;
readInstructionMemory <= '0';
writeRegs <='0';
performAdd <= '0';
performMultiply<='0';
readDataMemory<='0';
writeDataMemory<='0';
state<=C;
WHEN C=>
IF isAddInstruction ='1' OR isLoadInstruction='1' OR isStoreInstruction ='1' THEN
performAdd<='1';
ELSE performAdd<='0';
END IF;
IF isMultiplyInstruction ='1' THEN
performMultiply<='1';
ELSE performMultiply<='0';
END IF;
readRegs <= '0';
readInstructionMemory <= '0';
writeRegs <='0';
readDataMemory<='0';
writeDataMemory<='0';
state<=D;
WHEN D=>
IF isLoadInstruction='1' THEN
readDataMemory<='1';
ELSE readDataMemory<='0';
END IF;
IF isStoreInstruction ='1' THEN
writeDataMemory<='1';
ELSE writeDataMemory<='0';
END IF;
readRegs <= '0';
readInstructionMemory <= '0';
writeRegs <='0';
performAdd<='0';
performMultiply<='0';
state<=E;
WHEN E=>
IF isStoreInstruction='1' THEN
writeRegs<='0';
ELSE writeRegs<='1';
END IF;
readRegs <= '0';
readInstructionMemory <= '0';
performAdd<='0';
performMultiply<='0';
readDataMemory<='0';
writeDataMemory<='0';
state<=A;
END CASE;
END IF;
END PROCESS;
END Behavior;