Safe state machine design problem

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hi all,

I've been going through the archives trying to find a hint to the problem I
am having with a state machine (it occasionaly enters illegal states and
doesn't come out) and I found this post:
---------------------------------------------------------------------
From: iglam (rluking@deletethispart.home.com)
Subject: Re: safe state machine design problem
Newsgroups: comp.lang.vhdl, comp.arch.fpga
Date: 2001-06-08 08:26:41 PST


If you are using enumerated types, then your
when others clause is doing nothing.  You've already listed
all of the elements of the state type when you built your
case statement.  So, the first thing is, your synthesis tool
tosses that line.

Next, your synthesis engine decides to one-hot build the state machine.
OK, great.  Then, you screw up the state by forcing two bits high, and
it goes out to lunch.  Makes sense.  The synthesis tool was not
instructed to put in logic to avoid or get out of lockout states.

Either enumerate the Illegal states and get the synthesis tool to
build a regulare state machine

or

Get the synthesis tool to put the lockout state protection in.  I'm not
familiar with Leonardo, so someone else will have to suggest specific
solutions.

Bob
---------------------------------------------------------------------

So, I was wondering if ignoring illegal states when using enumerated types
is true for XST? That would explain at least some of my problems... Can I
somehow force XST to make a state machine safe without manually coding all
the states?


Thanks,
/Mikhail


0
Reply MM 10/2/2003 6:26:15 PM

See related articles to this posting


MM wrote:

> I've been going through the archives trying to find a hint to the problem I
> am having with a state machine (it occasionaly enters illegal states and
> doesn't come out) 

The most likely reason for *getting* into an illegal state
is missing input synchronization.

The most likely reason for *staying* in an illegal state
is not covering all the state cases in your code.

Consider binary encoding.

  -- Mike Treseler

0
Reply Mike 10/2/2003 8:20:50 PM

"Mike Treseler" <mike.treseler@flukenetworks.com> wrote in message
news:3F7C88A2.7040200@flukenetworks.com...
> The most likely reason for *getting* into an illegal state
> is missing input synchronization.

Understood...

> The most likely reason for *staying* in an illegal state
> is not covering all the state cases in your code.

That's what my original question was about. I do have a statement covering
all other states:
when others =>
     fsm_reg <= idle;
however it doesn't seem to do anything...

> Consider binary encoding.

You mean manual?

Thanks,
/Mikhail


0
Reply MM 10/2/2003 9:26:51 PM

MM wrote:

> That's what my original question was about. I do have a statement covering
> all other states:
> when others =>
>      fsm_reg <= idle;
> however it doesn't seem to do anything...
> 
>>Consider binary encoding.
> 
> You mean manual?

No. I mean change the synthesis seting from one-hot to binary.

Synthesis does not always cover the "others" case
completely for one-hot encoding.


    -- Mike Treseler

0
Reply Mike 10/2/2003 9:36:57 PM

Silly question but, is your design meeting timing? (how fast is the design
in question?)
Have you tried over constraining?


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Euredjian

To send private email:
0_0_0_0_@pacbell.net
where
"0_0_0_0_"  =  "martineu"




"MM" <mbmsv@yahoo.com> wrote in message
news:blhqhd$cijqt$1@ID-204311.news.uni-berlin.de...
> Hi all,
>
> I've been going through the archives trying to find a hint to the problem
I
> am having with a state machine (it occasionaly enters illegal states and
> doesn't come out) and I found this post:
> ---------------------------------------------------------------------
> From: iglam (rluking@deletethispart.home.com)
> Subject: Re: safe state machine design problem
> Newsgroups: comp.lang.vhdl, comp.arch.fpga
> Date: 2001-06-08 08:26:41 PST
>
>
> If you are using enumerated types, then your
> when others clause is doing nothing.  You've already listed
> all of the elements of the state type when you built your
> case statement.  So, the first thing is, your synthesis tool
> tosses that line.
>
> Next, your synthesis engine decides to one-hot build the state machine.
> OK, great.  Then, you screw up the state by forcing two bits high, and
> it goes out to lunch.  Makes sense.  The synthesis tool was not
> instructed to put in logic to avoid or get out of lockout states.
>
> Either enumerate the Illegal states and get the synthesis tool to
> build a regulare state machine
>
> or
>
> Get the synthesis tool to put the lockout state protection in.  I'm not
> familiar with Leonardo, so someone else will have to suggest specific
> solutions.
>
> Bob
> ---------------------------------------------------------------------
>
> So, I was wondering if ignoring illegal states when using enumerated types
> is true for XST? That would explain at least some of my problems... Can I
> somehow force XST to make a state machine safe without manually coding all
> the states?
>
>
> Thanks,
> /Mikhail
>
>


0
Reply Martin 10/3/2003 2:38:13 AM

"Mike Treseler" <mike.treseler@flukenetworks.com> wrote in message
news:3F7C9A79.8090106@flukenetworks.com...
> No. I mean change the synthesis seting from one-hot to binary.
>
> Synthesis does not always cover the "others" case
> completely for one-hot encoding.

I tried gray and it didn't help. I will try binary tomorrow, but I would
like to know when XST covers the "others" case and when it doesn't....

/Mikhail


0
Reply MM 10/3/2003 4:52:03 AM

"Martin Euredjian" <0_0_0_0_@pacbell.net> wrote in message
news:pi5fb.8964$5P7.7307@newssvr27.news.prodigy.com...
> Silly question but, is your design meeting timing? (how fast is the design
> in question?)
> Have you tried over constraining?

The design isn't really fast, only 50 MHz. The state machines in question
are not on critical path. Overconstraining doesn't work well because of a
big 3rd party core, which if overconstrained doesn't meet the timing at all.
I think Mike is right and my problem is related to asynchronous inputs, but
I still want to know more about how XST extracts state machines...

/Mikhail


0
Reply MM 10/3/2003 4:56:35 AM

You can apply a different set of constraints (tigher) just to the logic of
your state machine while other parts of the design are governed by a
(presumably) looser PERIOD constraint.

What you need to do is define FROM/TO constraints to the logic related to
the state machine.  The easiest way to do it might be to use the constraints
editor and find all the FF's related to that module.  It's pretty easy from
there forward.  The PERIOD constraint has the lowest priority of all, so
FROM/TO will override it only for the specified logic.

So, you could have a PERIOD set to 20ns while FROM/TO is specified to 10ns.

Also, I forgot to ask.  Does this happen during/around any reset signals?  I
suffered the pain of having one-hot state machines wake up in illegal
states.  Ultimately it was due to not handling reset properly and having
FF's cleared/set at different times.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Euredjian

To send private email:
0_0_0_0_@pacbell.net
where
"0_0_0_0_"  =  "martineu"



"MM" <mbmsv@yahoo.com> wrote in message
news:blivi5$ckn15$1@ID-204311.news.uni-berlin.de...
> "Martin Euredjian" <0_0_0_0_@pacbell.net> wrote in message
> news:pi5fb.8964$5P7.7307@newssvr27.news.prodigy.com...
> > Silly question but, is your design meeting timing? (how fast is the
design
> > in question?)
> > Have you tried over constraining?
>
> The design isn't really fast, only 50 MHz. The state machines in question
> are not on critical path. Overconstraining doesn't work well because of a
> big 3rd party core, which if overconstrained doesn't meet the timing at
all.
> I think Mike is right and my problem is related to asynchronous inputs,
but
> I still want to know more about how XST extracts state machines...
>
> /Mikhail
>
>


0
Reply Martin 10/3/2003 5:38:47 AM
comp.arch.fpga 18432 articles. 20 followers. Post

7 Replies
185 Views

Similar Articles

[PageSpeed] 6


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Safe State Machine Design in AHDL
Hello, I was curious if anyone can comment on writing safe state machines in AHDL. I often use One-hot encoding in my state machines and am curious how safe it is. I set the State Machine setting in Quartus for One-hot Encoding, does this force all my state machines to be safe. If I just add the line to my state machine: When Others => StateMachine = StateA; -- go back to start will the state machine be considered safe? thanks, joe Yes and no. The real questions is: "safe from what?". State machines just don't go wild out of blue. In fact, this question is very hard to a...

Safe finite state machine design
Hi, I am programming a Xilinx FPGA using Xilinx Project Navigator tool and FPGA Express for synthesis. I want to design a "safe" FSM, where the machine would fall back to reset state when it goes in an illegal state (I am using one-hot encoding). At the end of the case statement listing all states, I included a "when others" clause that should make the machine go back to reset state if it is stuck in a state that is not listed (an illegal state). In FPGA Express, I selected the option "FSM Synthesis: Interpretation of VHDL 'when others': safest (all possibl...

Monolithic state machine or structured state machine?
I am designing a state machine that will be fit into a CPLD (Xilinx XC95xx). The state machine needs to wait certain number of clockes here and there ( for example, 80 clockes here, and 160 clockes there ). If I design everthing with hand, I whould choose structured state machine; that is, a state machine plus a counter. But since I am using VHDL, and the compiler would take care of everything, I think I might be able to make a monolithic state machine with the counter built in ( that is, to add 80 states here, and 160 states there ). Excluding the counter, the state machine has about 100 stat...

problem with a state machine
Hello! I've got a problem with a state machine that i'm modeling for the communication with the PDIUSB12-chip for USB communication: (By the way - do you know if there is already an existing vhdl-code for this task to download somewhere?) I did a state machine for writing with 5 states, and in the state "WRITE_INIT" i need to do a write of 3 bytes (one every clock cycle). But as I simulate my code with modelsim, it never gets to the 2nd byte, it just stops. I cannot understand it! THANK YOU! :-) Simone Here is the part of my code: PROCESS (reset,CLK, next_sreg) BEGIN ...

How to stop a while loop inside one of the state in a state machine using the state machine buttons
I have created a state machine with the different states as follows: -Idle -data acquisition -stop &nbsp; Accordingly, on the front panel, there are two buttons for the user (boolean controls inside a cluster): -data acquisition button -stop button &nbsp; When the program starts, it stays at the "idle" state until the user pushes either one of the button. Inside the data acquistion state, I have a while loop that runs until the pre-set time is met. Is there anyway to stop this while loop inside the "data acquisition" state using just the stop button from the Menu cl...

State machine problem
Hi,This is my first attempt to use state machine&nbsp; in my project. I adopted the standart machine from LV. I tried to add a new frame "Hardware Init" and LV started to give me an error which has to do with the ENUM value. Could someone explain how to properly add states to my state machine? Also I would like to know how to make sure that all inputs will be on the left and all outputs will be on the right, so that my wires will stay neat and&nbsp; program will be easy to read. Thanks.Message Edited by RSibagatullin on 06-25-2008 02:20 PM Instr_Read 3.vi: http://forums.ni...

State Machine with a for loop problem...
I'm working on a state machine where I need to implement basically a for-loop with in a state machine and have run into a problem. I'm using Xilinx Foundation 7.1SP4, working in VHDL, targeting a Virtex-II. I have it setup where I can ouput signals to a logic analyzer to see what's going on. Here's how I define my states: type MAIN_STATE_TYPE is (M0, M1, M2, M3, M4, M4A, M4B, M5, M5A, M6, M7, M8, M9, M10, M11, M12, M13, M14, M15, M16, M17, M18, M19, M20); signal MCS, MNS: MAIN_STATE_TYPE; Here's my process to go from one state to the next: process(clk_int2, status0) b...

state machine dead problem
I am having a very stange problem with my state machine. The state machine turns dead after some uncertain time(20min ~ 2 days) and all outputs of the statemachine are 0. All other logics in the chips work properly at the same time. The state machine is very simple, only with 8 states. I tried with StateCAD and programming manually with VHDL and they behave the same. Anybody know what's possibly the problem? I have been working on this for a week and really cannot find a way out. Thanks. Lathi.Tan@gmail.com wrote: > I am having a very stange problem with my state machine. The state &...

Get information inside a state machine from outside state machine
HI, I have a UPD RX vi which is a&nbsp; subprogram which outputs some data couple times a second. This vi is being run outside of my state machine (SM).&nbsp; Inside my SM, in one of the states ("Measure") I have a need to stop and wait for the UDP RX&nbsp; vi to receive a specific type of data.&nbsp; Is there a way to iplement this data transition from outside SM to inside&nbsp; SM? The UDP RX sends only false or true type of data several tymes a second and I pretty much need to wait untill&nbsp; UDP RX will receiv a true. I have attached the pic of my code. ...

Designing my finite state machine
Greetings! As you might have guessed from the title of my post, I got a question related to the design of a finite state machine for my current project. I have read a lot about FSMs now, but I could not find an appropriate solution for my problem, which is the following: I got a rather simple FSM, which presently consists of only 4 states. There aren't many transitions either, however, the conditions for the latter are rather complex. The examples I found in various tutorials always used only a single condition for a transition, for example the user pressing a button. In my FSM, the con...

problem with synthesis of a state machine
The following code runs well in simulation mode but synthesis fails. Please let me know how I can get this synthesized, thanks! Fei `timescale 1ns / 1ps module blink_led(clk, d, led); input clk; input d; output wire led; parameter blink_freq = 2; reg [blink_freq:0] count = 0; reg [1:0] state = 0; reg [1:0] next_state = 0; assign led = !count[blink_freq]; always @(posedge clk) begin state <= next_state; if(state == 2'b01) begin count <= count + 1; if(count[blink_freq]) next_state <= 2'b10; else next_state <= 2'b01; end end always @(state o...

State machine design question
I am designing a a/v capture application. The user can monitor a live scene and at any time start capturing to file. While capturing to file he can mark the start and end times of interesting regions so that a playback application later can just playback the clips of interesting regions. I thought this might be represented well with a state machine. There seem to be several overlapping states. - Stopped - Streaming - Streaming & Capturing - Streaming & Capturing & Marking In order to switch between streaming and Streaming & Capturing, the system needs to be stopped ...

state machine problem in vhdl
Hi alls, I am facing problem with the following process. state machine from state "0001" goes to state "0011" instead of "0010" when the wr signal is low. Can u suggest something ? Regards, Anupam PROCESS (rst, extclk) --PROCESS no 01 BEGIN IF rst = '0' THEN temp_w <= "0000"; wrpointer_tx <= (OTHERS => (OTHERS => '0')); wren_txram <= '0'; wraddress_txram <= (OTHERS => '0'); ELSIF rising_edge(extclk) THEN ...

State Machine and Design Pattern
Hi I have a question. I have implemented a state machine by singleton design. Now I change my algorithm, so I will have two state machines which transtions diagrams are about the same, however at each state they perform different functions. I could have two classes, with the same transtion but different functions for each states, but it sounds so stupid. What kind of design patterns are good for this situation? Thank you very much! On 23 Des, 06:19, wudehui2...@gmail.com wrote: > Hi I have a question. I have implemented a state machine by singleton > design. Now I change my algorithm, s...

Strange problem with very simple state machine
Dear group, I'm teaching myself VHDL and to that end, I got a prototype board with a Xilinx Spartan 2 and WebPack 6.3.02 plus service packs. I was working on a small design when I started having some strange problems with a state machine. To locate the problem, I separated out the state machine and simplified it as much as I could while still retaining the problem. So I now have a complete design with an extremely simple state machine that exhibits the problem, but I still can't see that I made any mistakes. I've included that design in VHDL below. The state machine has two stat...

Drawing finite state machine for this problem
Hi, I had a question in a recent exam paper that i couldn't answer, and my lecturer won't tell me the answer to. The problem is : a string made up of anything from the language {0,1}, decide whether the string has an equal number of 0's and 1's. The question formally said that the string was written onto a turing machine, decide whether the TM halts on yes. Does anyone know how to draw a finite state machine for this??? Thanks. arun.hallan@gmail.com wrote: > Hi, > > I had a question in a recent exam paper that i couldn't answer, and my > lecturer won...

is there any doc about state machine design pattern ?
Version: 5.5.8 host: windows xp sp2, suse linux enterprise server 9 sp2 compiler: vs.net 2003, gcc 3.3.3 I searched doc about state machine design pattern in http://www.cs.wustl.edu/~schmidt/, but can not find any. I googled but find there are many using java or pascal. Can anyone help (to give me a better one)? thanks in advance! ...

weird problem printing Xilinx state machine
I'm having a problem printing the state machine generated using Xilinx IDE 6.3.03i to a Samsung ML-1740 printer. The text of the state machine prints but the bubbles of the states and the connecting lines do not print. I've tried printing to a different printer and it appears to work OK there. I've looked at the printer setup options and there is nothing listed that would indicate this kind of control. Has anyone else seen this kind of behavior? Thanks. Dave starfire wrote: > I'm having a problem printing the state machine generated using Xilinx IDE > 6.3.0...

State machine: how to stay in a state?
Hi, When writing a vhdl state machine, is there an easy way to stay in a given state for n clock cycles? I always end up having another process with a counter, enable the counter in that particular state, and having a <if count = n> statement in the state transition process. However, the counter needs to be reset in the state before and it ends up being very confusing. Is it possible to do this directly in the state machine process? Thanks Here is the type of state machine I usually use: FSM_transitions: PROCESS (reset, clock) -- synchronous FSM BEGIN If reset = '1' THEN ...

looking for design patterns of interacting state machine
Hi, I would like to ask if there is design patterns of 2 interacting state machine? I have following scenario in my project: There are 2 state machines A and B. 1. A and a timer control B. 2. B checks some variables when time out. The variables are set by A. 2. A's state change depends on the B's state/signals, and also user input. Any ideas will be very appreciated. Steven Responding to Steven P... > I would like to ask if there is design patterns of 2 interacting state > machine? I think the only "pattern" is making events announcements (I'm Done vs. ...

Data between states of the states machine
So I have two tables that I generate in one state of the state machine.&nbsp; My question is what is a proper, aesthetic way to propogate these two tables into one another state of the state machine. Please see the attached&nbsp; code.&nbsp; State machines rock! :smileyhappy: flag.jpg: http://forums.ni.com/attachments/ni/170/336748/1/flag.jpg But I need to pass only the data from one state to another. Wouldn't be the shift register an overkill becasue I will have to route&nbsp; the signal through all states? One nice way to pass data in a statemachine is to bundle up yo...

problems problems problems
(The short(?) summary) I've got an Access MDB file and a DAO connect with it.. Problem 1 of 2 The below gives me a runtime error 91 Object variable or With block variable not set. I've got the db stuff after the form.show (to make sure all the objects on the form are loaded before attempting to utilize/manipulate them) But it doesn't like it when I use the data object in the form load anyway for some reason.. pffft. Private Sub Form_Load() frmTest1Project.Show datGallery.Recordset.MoveLast datGallery.Recordset.MoveFirst Call LockTextBoxes(frmTest...

having a state machine in a datapath element a bad design practice?
hi, having a state machine in a datapath element a bad design practice? CMOS CMOS wrote: > hi, > > having a state machine in a datapath element a bad design practice? > > CMOS It depends. Give the name of your tutor, so replies can be sent straight to him/her. -jg "CMOS" <manusha@millenniumit.com> wrote in message news:1175743403.927787.98160@e65g2000hsc.googlegroups.com... > hi, > > having a state machine in a datapath element a bad design practice? > > CMOS > no Mike ...

Verilog problems with SelectRAM clocking within a finite state machine
I'm quite new to FPGA/Verilog and I'm not sure if this is the correct news group to use for this kind of posting - appologies if I've posted to the wrong place. Anyway, I'm having problems using memory within a FSM. I'm currently using Xilinx ISE for a VirtexII. I'm trying to use the RAMB16_S18 memory primitive (SelectRAM). I've written a short test which writes the sequence 0, 1, 2, 3 .... 14, 15 to the RAM in one state, then in another it reads it back. However, I read back the memory as 15, 0, 1, 2 .... 13, 14. I'm assuming that the 15 in the first read-bac...