- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Greetings
I have a state machine that needs to count down from a given number (0-9) while at the same time toggling back and fourth to another state machine. So if I have the number three come in. I need it to go into state 1 count down (1 second), subtract one, go into state 2 where it is delayed one second, return to state 1 where it will delay 1 second, subtract one (It would be 1 now) and return once again to state 2, where it would delay and finally return to state 2 where the last one will be subratected, it will have a final 1 second delay and exit to the next state after hitting zero. Here is my code. apparently if I load three into it. It will delay the one second for the first number but the 2 and the 1 only have one clock pulse before going to zero and exiting.when HighError2 =>
if (shortwait = 0 and HighBits = "0000" ) then
state <= waitone;
longwait <= twosecdelay;
shortwait <= halfsecdelay;
elsif (HighBits > "0000") then
if(shortwait = 0) then
HighBits <= (HighBits - "0001");
else
shortwait <= (shortwait - 1);
ErrorLED <= '1';
FLTline <= '1';
end if;
else state <= HighError2;
end if;
does anyone see any blatent errors? Thanks
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I assume this process is clocked?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I am counting down from (400) for simulation purposes
Here is my latest... Still having problems with signal tapwhen HighError1 =>
ErrorLED <= '0';
FLTline <= '1';
shortwait <= shortwait - 1;
if (shortwait = 0) then
state <= HighError2;
shortwait <= halfsecdelay;
else state <= HighError1;
end if;
when HighError2 =>
if(HighBits = "0000")then
state <= waitone;
longwait <= twosecdelay;
shortwait <= halfsecdelay;
elsif(HighBits > "0000")then
shortwait <= (shortwait - 1);
ErrorLED <= '1';
FLTline <= '1';
if(shortwait = 0)then
HighBits <= (HighBits - "0001");
longwait <= twosecdelay;
shortwait <= halfsecdelay;
state <= HighError1;
else state <= HighError2;
end if;
else state <= HighError2;
end if;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I dont really understand what you are trying to do.
Where is the input? what are you trying to wait on? is it just mean to wait for N seconds where N is the input (that I dont quite understand from your code).
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page