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 18395 articles. 19 followers. Post

7 Replies
151 Views

Similar Articles

[PageSpeed] 51


  • 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...

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 ...

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 &...

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...

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. ...

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...

Designing a Finite State Machine DFA Recognizer for UTF-8
State 0 00-7F ASCII C2-DF goto State 1 // Two Byte E0-EF goto State 2 // Three Byte F0-F4 goto State 4 // Four Byte else Error State 1 80-BF else Error State 2 80-BF goto State 3 else Error State 3 80-BF else Error State 4 80-BF goto State 5 else Error State 5 80-BF goto State 6 else Error State 6 80-BF goto State 7 else Error State 7 80-BF else Error // Holds ActionCodes Indexed by NextState and Data[N] uint8 States[256][8]; // This is the input data to be transformed std::vector<uint8> Data; // LastByte hold se...

problem using state machine with structure event (mouse clicking)
Hi, &nbsp; I use state machine sequence, but&nbsp;I have a problem with using event structure. I want this structure to&nbsp;handle click on the mouse. But it doesn't work, the vi bugs. When I use the function timeout of the event structure, it works. I don't know why?&nbsp;&nbsp;&nbsp; I send here the vi. &nbsp; Thanks for your help.&nbsp; &nbsp; &nbsp; <a href="http://forums.ni.com/attachments/ni/170/182147/1/paint%20renf.zip" target="_blank"><img height="22 alt=Attachment hspace=5 src= http://forums.ni.c...

Multi threaded embedded linux application state machine design
Problem definition: We are designing an application for an industrial embedded system running L= inux. The system is driven by events from the outside world. The inputs to the sy= stem could be any of the following: Few inputs to the system in the form of Digital IO lines(connected to t= he GPIOs of the processor like e-stop) The system runs a web-server which allows for the system to be controll= ed via the web browser. The system runs a TCP server. Any PC or HMI device could send commands = over TCP/IP. The system needs to drive or control RS485 slave devices o...

Multi threaded embedded linux application state machine design
Problem definition: We are designing an application for an industrial embedded system running L= inux. The system is driven by events from the outside world. The inputs to the sy= stem could be any of the following: Few inputs to the system in the form of Digital IO lines(connected to t= he GPIOs of the processor like e-stop) The system runs a web-server which allows for the system to be controll= ed via the web browser. The system runs a TCP server. Any PC or HMI device could send commands = over TCP/IP. The system needs to drive or control RS485 slave devices o...

Design for deriving one state-machine / double-dispatch class from another
Hello Group! I am experimenting with a design for implementing a state machine in a single class in such a way that a new state machine can be derived from an existing state machine. One part of this design has a cost that grows linearly with the depth of the inheritance hierarchy. My specific question: Is there some way to avoid this linear cost (while still respecting the basic design philosophy)? I give a complete and compilable example program at the end of this post that illustrates the design and the question. I will ask my question in more detail by quoting from the ex...

Fizzim
fizzim (www.fizzim.pl) is a free, open source fsm design tool. The gui runs in java and the backend code generator is in perl. It was originally written to output verilog, then systemverilog was added, and now vhdl. The vhdl version is in beta test. You can download it from www.fizzim.com. Feedback is appreciated. Paul Zimmer Zimmer Design Services ...