Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Want flag to keep value through all states

 
Thread Tools Search this Thread
Old 06-15-2009, 09:34 PM   #1
Default Want flag to keep value through all states


I am using a single-process state-machine style of coding. I have a
flag that gets set or cleared in one state. I want it to keep
whatever value that is throughout the rest of the state machine until
the machine returns to that state. What is the correct way of doing
this?

Please note that I am not referring to a "default" state. That much I
understand. I just want the flag to be set once and then stay that
way regardless of the condition that set it changing later.

Process (clk)
begin
if rising_edge(clk) then
case state
when one =>
flag <= input;
...
when two =>
if flag = '1' then
....
else
....
etc...

Thanks,
Shannon


Shannon
  Reply With Quote
Old 06-15-2009, 09:45 PM   #2
Shannon
 
Posts: n/a
Default Re: Want flag to keep value through all states
On Jun 15, 1:34*pm, Shannon <sgo...@sbcglobal.net> wrote:
> I am using a single-process state-machine style of coding. *I have a
> flag that gets set or cleared in one state. *I want it to keep
> whatever value that is throughout the rest of the state machine until
> the machine returns to that state. *What is the correct way of doing
> this?
>
> Please note that I am not referring to a "default" state. *That much I
> understand. *I just want the flag to be set once and then stay that
> way regardless of the condition that set it changing later.
>
> Process (clk)
> begin
> * if rising_edge(clk) then
> * * case state
> * * * when one =>
> * * * * *flag <= input;
> * * * * *...
> * * * when two =>
> * * * * *if flag = '1' then
> * * * * * ....
> * * * * *else
> * * * * *....
> etc...
>
> Thanks,
> Shannon


I'm suffering post traumatic "send" disorder....

I'm betting that I don't have to do anything since it is in a clocked
process and will become a register.

Shannon


Shannon
  Reply With Quote
Old 06-15-2009, 09:47 PM   #3
Dave
 
Posts: n/a
Default Re: Want flag to keep value through all states
On Jun 15, 4:34*pm, Shannon <sgo...@sbcglobal.net> wrote:
> I am using a single-process state-machine style of coding. *I have a
> flag that gets set or cleared in one state. *I want it to keep
> whatever value that is throughout the rest of the state machine until
> the machine returns to that state. *What is the correct way of doing
> this?
>
> Please note that I am not referring to a "default" state. *That much I
> understand. *I just want the flag to be set once and then stay that
> way regardless of the condition that set it changing later.
>
> Process (clk)
> begin
> * if rising_edge(clk) then
> * * case state
> * * * when one =>
> * * * * *flag <= input;
> * * * * *...
> * * * when two =>
> * * * * *if flag = '1' then
> * * * * * ....
> * * * * *else
> * * * * *....
> etc...
>
> Thanks,
> Shannon


If you simply don't assign the signal's value in those states where
the signal should remain unchanged, then the value will remain the
same until the next clock tick. The synthesizer will implement this by
making the clock enable for the signal's register '0' for those states
where the signal is not assigned. This is one of the nice things about
single-process state machines.

Dave


Dave
  Reply With Quote
Old 06-16-2009, 06:22 PM   #4
Mike Treseler
 
Posts: n/a
Default Re: Want flag to keep value through all states
Dave wrote:

> If you simply don't assign the signal's value in those states where
> the signal should remain unchanged, then the value will remain the
> same until the next clock tick. The synthesizer will implement this by
> making the clock enable for the signal's register '0' for those states
> where the signal is not assigned. This is one of the nice things about
> single-process state machines.


Yes.
Describing changes takes less text
than describing the full state and output.

It is unfortunate that asynchronous processes
and the default assignments they require,
are so well covered in vhdl instruction.

Some designers retain this verbose
style in all cases, out of habit.

-- Mike Treseler



Mike Treseler
  Reply With Quote
Old 06-16-2009, 06:36 PM   #5
Andy
 
Posts: n/a
Default Re: Want flag to keep value through all states
On Jun 16, 12:22*pm, Mike Treseler <mtrese...@gmail.com> wrote:
> Dave wrote:
> > If you simply don't assign the signal's value in those states where
> > the signal should remain unchanged, then the value will remain the
> > same until the next clock tick. The synthesizer will implement this by
> > making the clock enable for the signal's register '0' for those states
> > where the signal is not assigned. This is one of the nice things about
> > single-process state machines.

>
> Yes.
> Describing changes takes less text
> than describing the full state and output.
>
> It is unfortunate that asynchronous processes
> and the default assignments they require,
> are so well covered in vhdl instruction.
>
> Some designers retain this verbose
> style in all cases, out of habit.
>
> * * * * -- Mike Treseler


What's worse, most texts that promote dual processes also don't
promote the best way to avoid latches in the combinatorial processes:
default assignments right up front in the process. With those, you
have your choice of default signal behavior being unchanged, set or
reset for each signal. Most texts try to focus on an else for every
if, and complete assignment lists in every state, both of which are
much harder to write, read and update/maintain.

You still have all the default behavior choices with a single clocked
process, which is much better in the first place.

Andy


Andy
  Reply With Quote
Old 06-17-2009, 12:53 AM   #6
Shannon
 
Posts: n/a
Default Re: Want flag to keep value through all states
On Jun 16, 10:36*am, Andy <jonesa...@comcast.net> wrote:
> On Jun 16, 12:22*pm, Mike Treseler <mtrese...@gmail.com> wrote:
>
>
>
> > Dave wrote:
> > > If you simply don't assign the signal's value in those states where
> > > the signal should remain unchanged, then the value will remain the
> > > same until the next clock tick. The synthesizer will implement this by
> > > making the clock enable for the signal's register '0' for those states
> > > where the signal is not assigned. This is one of the nice things about
> > > single-process state machines.

>
> > Yes.
> > Describing changes takes less text
> > than describing the full state and output.

>
> > It is unfortunate that asynchronous processes
> > and the default assignments they require,
> > are so well covered in vhdl instruction.

>
> > Some designers retain this verbose
> > style in all cases, out of habit.

>
> > * * * * -- Mike Treseler

>
> What's worse, most texts that promote dual processes also don't
> promote the best way to avoid latches in the combinatorial processes:
> default assignments right up front in the process. With those, you
> have your choice of default signal behavior being unchanged, set or
> reset for each signal. Most texts try to focus on an else for every
> if, and complete assignment lists in every state, both of which are
> much harder to write, read and update/maintain.
>
> You still have all the default behavior choices with a single clocked
> process, which is much better in the first place.
>
> Andy


thanks for the help. I suspected the answer moments after I pressed
send. I used to be a two-process person but you guys convinced me
otherwise. I never was a three-process person.

Shannon


Shannon
  Reply With Quote
Old 06-18-2009, 06:49 PM   #7
Mike Treseler
 
Posts: n/a
Default Re: Want flag to keep value through all states
Shannon wrote:

> I'm suffering post traumatic "send" disorder....


And yet the "send" button is the source of all enlightenment


Mike Treseler
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Judge: File-swapping tools are legal Citizen Bob DVD Video 140 11-08-2006 06:42 PM
"The biggest scandal to ever hit American politics" Jas DVD Video 149 12-05-2004 02:47 PM
BREAKING: Kerry leading in key states, PA, FL, OH, WI, MI .... Official Election Guide 2004 DVD Video 89 11-08-2004 03:40 PM
Swiftboat Veterans for Truth = Nixon phony pro-war veterans group: John Kerry DVD jasmine DVD Video 57 10-13-2004 10:30 PM
Can you play dvd's from europe in the united states? Darmin DVD Video 14 03-05-2004 06:36 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46