Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21069 Discussions

StateMachine issue

Altera_Forum
Honored Contributor II
981 Views

Hello, 

 

just started AHDL programming for a uni project. 

Now I have encoutered an issue that I just cant solve. 

 

The StateMachine should switch states on an alterning Signal "Track.Pulse". 

Somehow it seems to run through the states on a stable Signal though. 

The HEX[0] jumpes from 2 to 9 (state indicator), q (indicated by LEDs) seems to stay in another state (or flicker through). 

 

Two things which make the issue even more mysterious to me: 

- works fine with a KEY as clock instead of 24MHz-Clock 

- worked when I changed the State "START = B"0000"" to "START = B"1111"" 

 

Edit: I guess its connected to these warnings, but cant make anything out of em. 

Warnings: 

- Info: Found 5 Registers with very high hold time requirements 

Info: Node "Scan:Scanner|WAIT2" 

Info: Node "Scan:Scanner|WAIT3" 

Info: Node "Scan:Scanner|WAIT1" 

Info: Node "Scan:Scanner|START" 

Info: Node "Scan:Scanner|ENDSCAN" 

- Found 51 node(s) in clock paths which may be acting as ripple and/or gated clocks -- node(s) analyzed as buffer(s) resulting in clock skew 

 

 

Happy for any help or suggestions. 

Cheers 

 

The Code is kind of long, but I am really lost of where to locate the issue. 

 

FUNCTION DEBOUNCE (Clk, Signal) RETURNS (Pulse); SUBDESIGN Scan ( IRTrack, IRSignal, MSwitch, Clock, Reset :INPUT; LastBrick, HEX3, HEX2, HEX1, HEX0, q :OUTPUT; ) -- VARIABLE LastBrickTemp : DFF; Track : Debounce; ScanState : MACHINE OF BITS (q) WITH STATES ( START = B"0000", INIT = B"0001", BIT3 = B"0010", WAIT3 = B"0011", BIT2 = B"0100", WAIT2 = B"0101", BIT1 = B"0110", WAIT1 = B"0111", BIT0 = B"1000", ENDSCAN = B"1001", ERR = B"1010" ); BEGIN DEFAULTS LastBrickTemp.clk = GND; LastBrickTemp = GND; HEX0 = B"1000000"; -- 0 END DEFAULTS; LastBrick = LastBrickTemp; ScanState.reset = Reset; ScanState.clk = Clock; Track.Clk = Clock; Track.Signal = IRTrack; CASE ScanState IS WHEN START => LastBrickTemp.clk = GND; HEX0 = B"1000000"; -- 0 If (!Track.Pulse & !MSwitch) Then -- CounterWhite ScanState = INIT; end if; WHEN INIT => HEX0 = B"1111001"; -- 1 LastBrickTemp = VCC; LastBrickTemp.clk = VCC; If !MSwitch Then -- MSwitch not ScanState = BIT3; else ScanState = ERR; end if; WHEN BIT3 => LastBrickTemp.clk = GND; HEX0 = B"0100100"; -- 2 If !MSwitch Then -- MSwitch not If Track.Pulse Then -- CounterBlack LastBrickTemp = IRSignal; LastBrickTemp.clk = VCC; ScanState = WAIT3; end if; else ScanState = ERR; end if; WHEN WAIT3 => LastBrickTemp.clk = GND; HEX0 = B"0110000"; -- 3 If !MSwitch Then -- MSwitch not If !Track.Pulse Then -- CounterWhite ScanState = BIT2; end if; else ScanState = ERR; end if; WHEN BIT2 => HEX0 = B"0011001"; -- 4 If !MSwitch Then -- MSwitch not If Track.Pulse Then -- CounterBlack LastBrickTemp = IRSignal; LastBrickTemp.clk = VCC; ScanState = WAIT2; end if; else ScanState = ERR; end if; WHEN WAIT2 => LastBrickTemp.clk = GND; HEX0 = B"0010010"; -- 5 If !MSwitch Then -- MSwitch not If !Track.Pulse Then -- CounterWhite ScanState = BIT1; end if; else ScanState = ERR; end if; WHEN BIT1 => HEX0 = B"0000010"; -- 6 If !MSwitch Then -- MSwitch not If Track.Pulse Then -- CounterBlack LastBrickTemp = IRSignal; LastBrickTemp.clk = VCC; ScanState = WAIT1; end if; else ScanState = ERR; end if; WHEN WAIT1 => LastBrickTemp.clk = GND; HEX0 = B"1111000"; -- 7 If !MSwitch Then -- MSwitch not If !Track.Pulse Then -- CounterWhite ScanState = BIT0; end if; else ScanState = ERR; end if; WHEN BIT0 => HEX0 = B"0000000"; -- 8 If !MSwitch Then -- MSwitch not If Track.Pulse Then -- CounterBlack LastBrickTemp = IRSignal; LastBrickTemp.clk = VCC; ScanState = ENDSCAN; end if; else ScanState = ERR; end if; WHEN ENDSCAN => HEX0 = B"0010000"; -- 9 LastBrickTemp.clk = GND; If MSwitch Then -- MSwitch ScanState = START; end if; WHEN ERR => -- Error HEX3 = B"0010010"; -- S HEX2 = B"1000110"; -- C HEX1 = B"1001000"; -- N HEX0 = B"0000110"; -- E LastBrickTemp = GND; LastBrickTemp.clk = VCC; If Reset Then ScanState = START; end if; WHEN OTHERS => -- BUGS !! HEX0 = B"0010010"; -- S END CASE; END;
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
317 Views

Found this thread and I looks like my problem is of this kind: 

 

http://www.alteraforum.com/forum/showthread.php?p=8500 

 

Well, this article is above my knowledge. 

 

Followed Guideline#4 and got less warnings, but I still have got these: 

 

Info: Minimum slack time is -8.105 ns for clock "CLOCK_24" between source register "SCN" and destination register "Scan:Scanner|LastBrickTemp[2]" 

Info: Minimum slack time is -7.876 ns for clock "CLOCK_24" between source register "SCN" and destination register "Scan:Scanner|LastBrickTemp[3]" 

Info: Minimum slack time is -7.681 ns for clock "CLOCK_24" between source register "SCN" and destination register "Scan:Scanner|LastBrickTemp[1]" 

Info: Minimum slack time is -6.995 ns for clock "CLOCK_24" between source register "Scan:Scanner|BIT0" and destination register "Scan:Scanner|LastBrickTemp[0]" 

Info: Minimum slack time is -4.697 ns for clock "CLOCK_24" between source register "Scan:Scanner|INIT" and destination register "Scan:Scanner|LastBrickTemp[0]" 

 

Happy for any kind of answer. 

 

Cheers
0 Kudos
Reply