Counter in FSM doesn't work

Hello ng,

I have a problem with my fsm.
I use a counter to count numbers of the pass through.

here my vhdl code (simple version):

process(i_rst_n,i_clk_fpt)
begin
  	if (i_rst_n= '0') then
		state <= IDLE;
	elsif rising_edge(i_clk_fpt) then   -- risign edge
		state <= nextstate;

	end if;
end process;


process(state)
begin
	case(state) is
		when IDLE =>
			cnt <= 0;
			nextstate <= COUNT;
		when COUNT =>
			if (cnt < 8) then
 				cnt <= cnt +1;
			else
				cnt <= 0;
			end if;
			nextstate <= COUNT;

	end case;

end process;

Now i get this warning:

Warning: Found 33 combinational loops!
         Each loop is reported with an instance in the loop
         and nets connected to that instance.
@W: BN134 :"d:\logik\counter\cnt.vhd":37:1:37:4|Found combinational
loop during mapping
1) instance o_count[31:0] work.cnt(behavioral)-o_count[31:0], output
net "o_count[0]" in work.cnt(behavioral)
    input nets to instance: .........

0
6/26/2007 10:11:12 AM
comp.lang.vhdl 6336 articles. 14 followers. Post Follow

5 Replies
285 Views

Similar Articles

[PageSpeed] 31
cpudesigner@gmx.at wrote:

> process(state)
> begin
> 	case(state) is
> 		when IDLE =>
> 			cnt <= 0;
> 			nextstate <= COUNT;
> 		when COUNT =>
> 			if (cnt < 8) then
>  				cnt <= cnt +1;
> 			else
> 				cnt <= 0;
> 			end if;
> 			nextstate <= COUNT;
> 
> 	end case;
> 
> end process;

This is not clocked, so it counts all the time while state = COUNT, which
doesn't lead to a useful schematic.

-- 
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
0
Frank
6/26/2007 10:26:02 AM
<cpudesigner@gmx.at> wrote in message 
news:1182852672.393000.317530@w5g2000hsg.googlegroups.com...
> Hello ng,
>
> I have a problem with my fsm.
> I use a counter to count numbers of the pass through.
>
> here my vhdl code (simple version):
>
> process(i_rst_n,i_clk_fpt)
> begin
>  if (i_rst_n= '0') then
> state <= IDLE;
> elsif rising_edge(i_clk_fpt) then   -- risign edge
> state <= nextstate;
>
> end if;
> end process;
>
>
> process(state)
> begin
> case(state) is
> when IDLE =>
> cnt <= 0;
> nextstate <= COUNT;
> when COUNT =>
> if (cnt < 8) then
>  cnt <= cnt +1;
> else
> cnt <= 0;
> end if;
> nextstate <= COUNT;
>
> end case;
>
> end process;
>
> Now i get this warning:
>
> Warning: Found 33 combinational loops!
>         Each loop is reported with an instance in the loop
>         and nets connected to that instance.
> @W: BN134 :"d:\logik\counter\cnt.vhd":37:1:37:4|Found combinational
> loop during mapping
> 1) instance o_count[31:0] work.cnt(behavioral)-o_count[31:0], output
> net "o_count[0]" in work.cnt(behavioral)
>    input nets to instance: .........
>

Since cnt is not inside a clocked process, it is not a register. So when 
state is COUNT you increase the cnt as fast as the simulator can do it (with 
no clock involved). You should recode it so, that cnt is registered, you 
probably want it to be increased only on clock egde.

Jyke. 


0
Jyke
6/26/2007 10:32:17 AM
On Tue, 26 Jun 2007 03:11:12 -0700, cpudesigner@gmx.at wrote:

>Hello ng,
>
>I have a problem with my fsm.

<rant>
The problem arises because you are (imperfectly) following
the advice of idiotic textbooks, instead of following the
advice of experienced members of this newsgroup.
</rant>

>process(i_rst_n,i_clk_fpt)
>begin
>  	if (i_rst_n= '0') then
>		state <= IDLE;
>	elsif rising_edge(i_clk_fpt) then   -- risign edge
>		state <= nextstate;
>	end if;
>end process;
>
>process(state)
>begin
>	case(state) is
>		when IDLE =>
>			cnt <= 0;
>			nextstate <= COUNT;
[and much more]

Your combinational process is trying to represent
a counter on "cnt", but I see no registers for "cnt"
anywhere.  Hence the combinational loops.

Your combinational process is the process that...
* you don't need
* many people here quite correctly tell you not to use
* causes all the trouble
* is a PITA to write

However, let's take it at face value and see what we can do.
FIRST:  This is a state machine.  Consequently, in many 
situations, the next state will be the same as the current
state.  Therefore, it is a VERY good idea to start the 
next-state combinational process with adefault assignment:

> process(state)
> begin
    nextstate <= state;  ----- DEFAULT ASSIGNMENT
>   case(state) is
>     when IDLE =>
>       cnt <= 0;
>       nextstate <= COUNT;

Second, we need registers on "cnt".  So you better put those in
the registered process, along with the state variable.  This means
that you now need two count signals: the registered version, and
the next-state signal (just like your state variable).  This is
getting silly, isn't it?

Wouldn't it all be SO much easier to use a single process for the
whole mess?

If you really insist on keeping your evil do-like-the-textbook-says
two-process state machine, then please separate out the counter into
another clocked process, and use the state machine to create control
outputs that cause the counter to reset, count, decrement, bit-flip
or whatever.  Then you have done something that many good designers
like to do - you have separated control logic from datapath.

Alternatively, if you want to merge the control logic and datapath,
put the whole thing in a single clocked process so that you don't 
have absurd unnecessary next-state signals cluttering your
architecture.  There have been many, many discussions here about
how to do that.

Sorry to flame you for something that's not your fault.  Your
problem is a perfect example of why the textbook/undergraduate
two-process coding style is a diabolical mess.  Leave it behind
you, ignore your prof's criticisms, get on with doing the job
in a sensible way.

Grrrr.
-- 
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which 
are not the views of Doulos Ltd., unless specifically stated.
0
Jonathan
6/26/2007 10:36:47 AM
"Jonathan Bromley" <jonathan.bromley@MYCOMPANY.com> wrote in message 
news:irp183tvlhbbojsomlqtrsvn0i1dukul00@4ax.com...
>
> Sorry to flame you for something that's not your fault.  Your
> problem is a perfect example of why the textbook/undergraduate
> two-process coding style is a diabolical mess.  Leave it behind
> you, ignore your prof's criticisms, get on with doing the job
> in a sensible way.
>
> Grrrr.
> -- 
> Jonathan Bromley, Consultant

SOMEBODY is in a cranky mood today...chill out, relax  ;)

But I do agree with the technical aspects of your post.

KJ 


0
KJ
6/26/2007 11:27:44 AM
On Tue, 26 Jun 2007 11:27:44 GMT, "KJ" 
<kkjennings@sbcglobal.net> wrote:

>> Grrrr.
>
>SOMEBODY is in a cranky mood today...chill out, relax  ;)

Sorry.  Too much blood in the caffeine-stream, or something.
Anyway, at my age I'm allowed the occasional curmudgeonly
rant before Matron comes round with the tea and biscuits.
-- 
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which 
are not the views of Doulos Ltd., unless specifically stated.
0
Jonathan
6/26/2007 11:59:29 AM
Reply:
Similar Artilces:

[rfc-dist] RFC 5528 on Camellia Counter Mode and Camellia Counter with CBC-MAC Mode Algorithms
A new Request for Comments is now available in online RFC libraries. RFC 5528 Title: Camellia Counter Mode and Camellia Counter with CBC-MAC Mode Algorithms Author: A. Kato, M. Kanda, S. Kanno Status: Informational Date: April 2009 Mailbox: akato@po.ntts.co.jp, kanda.masayuki@lab.ntt.co.jp, kanno-s@po.ntts.co.jp Pages: 22 Characters: 56134 Updates/Obsoletes/SeeAlso: None I...

how to use ARM11 cycle/performance counter interrupts
I got code that uses the cycle counter and performance counters that works ok. But I need to use interrupt to track counter overflows. The performance monitor control register has bits to enable interrupts for this but how do you check interrupt status to see which of these interrupts is pending? I'm assuming the IRQ interrupt handler will be triggered for these events. ...

Visual Working Memory
Pennywise brought this intriguing news item to my console: http://cognews.com/1082113590/index_html http://www.nature.com/nsu/040412/040412-3.html Now, researchers can accurately predict the capacity of your visual working memory (how many objects you can recognize / work with at the present) simply by analyzing an image of your brain. The relevant brain area is a small portion of the brain, like a memory chip, and it's not distributed across the entire topology. So far, nobody had predicted they'd find such a thing. What are the philosophical implications? Well, you figure it out! ...

Reset doesn't work. Revo plays indefinite tune
Hi! Does anyone have a clue what's wrong with my Revo Plus? 1. I had it charging and it locked 2. I resetted it by pressing resetbutton 1 3. Every time i turn it on it plays the same 3 tone tune over and over. It does not stop until I reset it again. It is not possible to perform any action on it while it plays. Hope someone can help! /Hans You did a soft reset, have you tried a hard reset as well? Richard "Hans" <hans.edman@chello.se> wrote in message news:KYVwc.1915$9n5.1393@amstwist00... > Hi! > > Does anyone have a clue what'...

Ubuntu Linux Streaming of Debate No Work......
www.foxnews.com the debate does not stream... It opens a window and sits there with: http://www.foxnews.com/video2/live.html?chanId=1&openAIR=true The bottom of the window says: Read airdownload.adobe.com Linux loses again. Works fine under Windows BTW. -- Moshe Goldfarb Collector of soaps from around the globe. Please visit The Hall of Linux Idiots: http://linuxidiots.blogspot.com/ Please Visit www.linsux.org ...

APL work?
Hello from a long-time APL user. I'm wondering if there's any APL work out there? On Jul 23, 5:52=A0pm, Brooklyn <jalexandermo...@gmail.com> wrote: > Hello from a long-time APL user. I'm wondering if there's any APL work > out there? How about creating a home page on the APL Wiki to display your experience? See http://aplteam2.com/aplwiki/moin.cgi/CategoryHomepage Stephen Taylor editor@vector.org.uk http://www.vector.org.uk http://aplwiki.aplteam.com In article <e0dae433-fb24-40e0-beea-0403d06546c7@m3g2000hsc.googlegroups.com>, Brookly...

Working with Google Analytics
[Note: parts of this message were removed to make it a legal post.] Hi Guys, Thanks for your help earlier. My company, Pilotoutlook.com is close on the heels of launching our first APIs - AirportLookup (shameless plug - it is going to be the largest Airport DB) and I want to track the requests coming in through Google Analytics. My idea is that if somehow, I can call Urchin JS in the background (from controller), I should be able to register it as a visit. Note that we are rendering XML as the output of the controller and also, I don't want to add ~300ms to every response (so some as...

vb.Net 's inherited DataGrid dosen't Work in parent-Child mode
hi I have inherited from Datagrid Class and just add a new method there. while using this new inherited calss in a master-detail mode (master Grid and detail grid) I used a datatable as the master for binding first grid and a permanet ralation with child table for binding other grid. the problem is that after loading data ,no detail shows for first row in master grid. but if Current row change in master then details will be shown properly. this problem just exist in inherited classes from Datagrid. if you use ..Net's dataGrid you will not experiance this problem. Almost everybody in this ...

PDM Works
Hi, I'm planning to purchase 4 PDM works seats but before doing so I would appreciate your opinion and sharing any experiences with implementation, best strategy, etc. TIA Irek My opinion may be somewhat biased by the fact that I implement PDMWorks for paying customers. I think it is a fine departmental PDM app as long as you know what it is good for and what it is not good for. First, don't get PDMWorks thinking that you are going to customize it and tie it to your MRP system. PDMW is flexible, but not very customizable. If you are a big Oracle or SQL buff and want to write...

how does this work
This piece of code counts the number of one bits in integer x. unsigned int x; x = (x & 0x55555555) + ((x>>1)&0x55555555); x = (x & 0x33333333) + ((x>>2)&0x33333333); x = (x & 0x0F0F0F0F) + ((x>>4)&0x0F0F0F0F); x = (x & 0x00FF00FF) + ((x>>8)&0x00FF00FF); x = (x & 0x0000FFFF) + ((x>>16)&0x0000FFFF); I have not been able to figure out how. -- pacman <pacman2081@yahoo.com> wrote in message news:1122852052.396558.147740@g43g2000cwa.googlegroups.com... > This piece of code counts the number of one bits in integer ...

Best Home Base Work
"I can teach anyone how to get what they want out of life. The problem is I can't find anybody who can tell me what they want." -- Mark Twain "Today people in America can become whatever they want. Trouble is most don't know what they want." -- Earl Nightingale What do you want? Are you sick of the rat race? Are you tired of having someone else tell you what they think you're worth? Would you rather work from home, set you own hours, and pay yourself what you're really worth? We found the Perfect Home-based Business where you can work from home, set yo...

exec, shell_exec, system, and passthru not working at all
Can't get these commands to work! The following page simply doesn't finish loading ( Waiting... Opening... :-( ) <?php echo system("dir"); ?> The same for <?php echo exec("dir"); ?> or <?php echo shell_exec("dir"); ?>, etc... I'm running Apache 2.0.55 & PHP 5.0.5 with Zend Optimizer v2.5.10 on windows XP SP2. Any help is welcome, TIA, Bernhard. PS: I have also tried the windExec() user function sugested in php.net/manual. > Can't get these commands to work! The following page simply doesn't > finish loading ...

smaller Alph in subsection counters
So I want A, B, C as the subsection counters. So I used the following. \renewcommand{\thesubsection}{\thesection.\Alph{subsection}} which more or less works. But the A is a lot larger than the 2 in 2.A and it looks funny. Any ideas short of hacking the style like I sometime do for section headers as in \makeatletter \renewcommand\section{\@startsection {section}{1}{\z@}% { ---- -3.5ex \@plus ---- -1ex \@minus ---- -.2ex}% {2.3ex \@plus.2ex}% {\normalfont\large\bfseries}} \makeatothe...

DII fails to return value in TAO 1.4.6 version which was working in 1.4.0
TAO VERSION: 1.4.6 ACE VERSION: 5.4.6 HOST MACHINE and OPERATING SYSTEM: win2kProf TARGET MACHINE and OPERATING SYSTEM, if different from HOST: COMPILER NAME AND VERSION (AND PATCHLEVEL): VC++ 6.0 AREA/CLASS/EXAMPLE AFFECTED: DII/CORBA::Request DOES THE PROBLEM AFFECT: COMPILATION? no LINKING? no EXECUTION? yes SYNOPSIS: No value in result argument of _create_request and request->return_value() after calling invoke() DESCRIPTION: After calling invoke(), the result value should come to ...

Why does one work, but not the other?
I've done this before: data = [self.cong.tm[k] for k in self.cong.tm.li] #li is list, tm is dict instead of: for k in self.cong.tm.li: data.append(self.cong.tm[k]) but when I try: self.liststore = [[item] for item in data] instead of: for item in data: self.liststore.append([item]) I get an empty list! What gives?? jonathon j_mckitrick wrote: > but when I try: > > self.liststore = [[item] for item in data] > > instead of: > > for item in data: > self.liststore.append(...

Why doesn't the temporary work?
I need to make a copy of a vector of pointers (and the objects they point to). template< typename T > class ManagedPtr { public: ~ManagedPtr() { for( size_t i =0; i < data.size(); ++ i ) delete data[i]; } std::vector< T * > data; }; std::vector< MyClass * > MakeCopy( const std::vector< MyClass * > &src ) { ManagedPtr< MyClass > mgr; for( size_t i=0; i < src.size(); ++i ) mgr.data.push_back( src[i]->clone() ); // clone could throw // return std::vector< MyClass * >().swap( mgr.data ); std::vector...

Support for Galois/Counter Mode (GCM) ?
Hi ! Is there a crypto library for Python that has support for GCM ?? -- Roland ...

Using two different sample clock sources for one counter possible?
Hello All, &nbsp;&nbsp; I have 2 signals (both are pulse trains, one is 1 HZ and other other is about 100 HZ). My goal is to measure the time difference between the each pulse of 100HZ pulse train related to most recent 1HZ pulse. &nbsp; My idea is that, firstly, use the 1HZ pulse train as the external sample clock of counter0, then drive the counter0 source input with 100KHZ internal timebase, then use "Counter Input U32 1Sample" vi to continuously read counter value as the time instant of most recent 1HZ pulse.&nbsp; Then I&nbsp;need to use&nbsp;100HZ pulse ...

Anybody have a working HP Scanjet 4470C scanner?
I inherited one of these from a friend, but it has no power supply, no CD-ROM, just the scanner. I rigged up a 12V power supply for it, and a couple lights come on, but it's not clear the thing is still alive. Before installing the 60mb of software I found at HP, I'd like to make sure the scanner isn't obviously DOA. Without connecting it to the computer, when I just power up the scanner, I get two LEDs - the Power Save LED on the left, and the Color indicator on the right. There's nothing in the little LCD window. Pushing the Power Save toggle button has n...

IOGear USB Print Server + HP OfficeJet 6110 + 10.2.6 = working :)
I posted with a ? a few weeks ago, and now I'm following up with a :) and a ! A packaged installer for HPIJS 1.4.1 has been posted at: http://www.linuxprinting.org/macosx/hpijs/ and I now have full printing support for my OfficeJet 6110 via a generic USB print server. So far I've tried: Using HPIJS: ============ IOGear GPSU01 via IPP JetDirect 175x via AppSocket/Jetdirect Using HP's regular driver: ========================== JetDirect 175x via AppleTalk <-this is the only method that works with HP driver The IOGear GPSU01 looks like it's very simila...

A2300 Genlock and A2000 not working
I just got a new A2300 from eBay and tried to install it in my A2000. I get a black screen and no activity at all. My setup: A2000 Rev 4.3 WB 1.3 1MB Chip SupraRAM 2000 w/4MB A2091 2MB, Maxtor 120MB, Rev 6.6 ROMs The A2300 does not have a grounding wire, but I tried to ground it and it did not help. Any ideas? Tim > The A2300 does not have a grounding wire, but I tried to ground it and it > did not help. no clue. But i do have a workign 2300 ;-) -- ___ / __|__ Burt /Terminator / / / / ...

Re: counter for by groups
Hi, try this. data test; input order; cards; 989898 989898 979797 979797 979797 979797 979797 121212 121212 121212 121212 ;;;; proc sort data=test; by order;run; data test; set test; retain item 0; by order; item = item+1; if first.order then item=1; run; St�phane. ----Message d'origine---- >Date: Wed, 17 Nov 2004 21:05:50 -0800 >De: Mayank Gupta <mayank@ABSOLUTDATA.NET> >Sujet: counter for by groups >A: SAS-L@LISTSERV.UGA.EDU > >Hi > > > >I have a dataset which has a variable 'order number'. One order number can >have mult...

Counter
I am trying to keep track of pages visited on my pages on another server that doesn't offer CGI. I have a web server also on my computer with CGI. Is it possable to to direct the count to my server from the other server so I can keep track of the pages people are visiting. I don't need the count to show up on the other server it is just for my information. Thanks for any info. Larry --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.522 / Virus Database: 320 - Release Date: 9/29/2003 -- PLEASE NO...

Working with "property nodes" in pda module
Hi, i already know that it is not possible to work with property node in pda module. I have found something that allows to replace the visible property node (LabVIEW_PDA_Module_Property_Additions), but i need other property nodes. I need the following property nodes: disabled caption.text numrows (for a table control) numcols (for a table control) colhdrs[] (for a table control) Can anyone give me a help with this? Thanks, Pedro ...

newbie: working iwth list of tuples
Hi All, I am fairly new to Python (less than a week). My goal is to write a small prototype of a database. Rather than build it using the typical method where one provides selection, projection, aggregation, union, intersection, etc. functions, I would like to do it in a more 'functional' style (executing a database query by using map, reduce, filter, etc. I am curious what the best way is to work with a list of tuples. For example, if I have the following list: [('a',1),('a',1),('a',3),('b',1),('b',2),('c',2),('c',3),('c&...