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 6410 articles. 2 followers. Post Follow

5 Replies
377 Views

Similar Articles

[PageSpeed] 2

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:

iproute2 fwmark doesn't work (or iptables --set-mark doesn't)
Hi, I just subscribed this group. Hello everyone! I have a problem with setting up routing. In short, I want to mark certain packets with iptables and then catch these marks with iproute2. However Linux seems to ignore these marks. I have a 3.11.4 kernel with CONFIG_IP_ADVANCED_ROUTER and CONFIG_IP_MULTIPLE_TABLES set. Here's my setup: - eth0: LAN - IP 192.168.0.1, netmask /24 - It connects to the LAN - eth1: WAN - IP 192.168.1.180, netmask /24, gateway 192.168.1.1 - It connects to the Internet - tap0: VPN (created with OpenVPN) - Local IP 172.24.25.4...

Can't get sqlite3.Row working: keyword lookup doesn't work
Hello, using Python 2.7.6 I try to access a sqlite database using keyword lookup instead of position (much more easy to maintain code), but it always fail, with the error: Index must be int or string I have created the database, populated it, and here is the code that tries to retrieve the information: with sqlite3.connect(mydbPath) as db: # open the database db.row_factory = sqlite3.Row cursor = db.cursor() cursor.execute("SELECT * FROM files") for row in cursor.fetchall(): print(row.keys()) print(row["filename&qu...

Jeff Doesn't Like Pizza; Jeff Doesn't Like In-House Working Peripherals
Jeff sits in a tangle of trackball wires. Jeff can't order a delicious pizza from the Web. He won't call the Geek Squad to fix his broken trackball. Meanwhile, Linux service explodes with In-Home Fixit People. Get these People to Fix the Track Ball ! Jeff (!) begin Steve Zissou (JBailo) nymshifted: > > Jeff sits in a tangle of trackball wires. > < snip > Fine, JBailo. So this idiot has felt the need to be mentioned again. You, in your infinite idiocy, naturally did his wishes. Idiot -- Warning: 10 days have passed since your last Windows reinstall. Hi ...

why 'for' doesn't works as it should?
hi, i've got a little code: for ii=4:5 % splines in p-form splineP = GlobalData.SplineFit{ii}; % splines in B-form splineB = fn2fm(splineP, 'B-'); z(ii) = {splineB} z(1) end and what is strange in this is that this 'for' counts from 1:5! z shows me: z = [] [] [] [1x1 struct] [1x1 struct] and z(1) shows {[]} but splineB and splineP shows me only things for ii=4 and ii=5 then i need to put them in one 'thing' so i made: z(ii)= ...

'do over' doesn't work
hi, why my code doesn't work with 'do over'. thanks. ash007. DATA TABLE_BIDON; INPUT X1 X2 X3 X4 X5 $; CARDS; 2 . 5 1161 AB=C9LIEN 35 6 3 1336 ALM=C9RIC 82 1 5 1499 ;RUN; DATA TABLE_BIDON (DROP =3D _I); SET TABLE_BIDON; ARRAY A_VARNUM[*] _NUMERIC_; ARRAY A_VARCAR[*] _CHARACTER_; DO OVER A_VARNUM[*]; IF A_VARNUM[*] =3D . THEN A_VARNUM[*] =3D 0; END; DO OVER A_VARCAR[*]; IF COMPRESS(A_VARCAR[*]) IN (".","") THEN A_VARCAR[*] =3D "Z"; END; RUN; ...

why my work doesn't work? i cant' understnd....
hi guys i've made a software that is a protocol to comunicate between pc and a bord with automotive cpu by datasocket it constains 2 modules called "shm" (sharm) &amp; "cmt" (comunicator). Shm is the user side while cmt is serial port side and this talks with the board I can't understand why if i do run on 2 files (shm_test &amp; cmt_test) the counting of sending and receiving packets sometimes stops and the count accumulate fails... with a wait of 20 ms the problems is solved. where i'm in fall? thank you very much!!! Dario SHM_CMT_TEST.zip: http://fo...

__getattribute__ doesn't work on 'type' type for '__class__'
I'm running this version of Python: Python 2.4.3 (#1, May 18 2006, 07:40:45) [GCC 3.3.3 (cygwin special)] on cygwin I read in the documentation that these two expressions are interchangeable: x.__getattribute__('name') <==> x.name From "pydoc __getattribute__": ---8<--- Help on method-wrapper object: __getattribute__ = class method-wrapper(object) | Methods defined here: | | __call__(...) | x.__call__(...) <==> x(...) | | __getattribute__(...) | x.__getattribute__('name') <==> x.name --->8--- Yet when I...

Linux
http://www.murrayc.com/blog/permalink/2008/03/28/webcams-that-just-work-with-ubuntu/ <quote> As I've said before, I think the hardware lists on the Ubuntu wiki are mostly useless for real users because nobody is insisting that "just works" really means "just works", and nobody is flagging the ones that really do just work. </quote> And if you finally can get it to work with linux.... <quote> got a Pro 9000 around Christmas because I read that it "Just Works". It did not work in Ubuntu 7.04. I chased and chased and could not solve i...

/bin/bash -c 'vim !(CVS)' doesn't work while vim !(CVS) does work
Hello together, I want to add a 'vim !(CVS)' to a makefile in order to open vim with all files by typing 'make edit'. My problem now is that it doesn't work like expected. Some experiments showed me that /bin/bash -c 'vim !(CVS)' doesn't work either. But /bin/bash -c 'vim *' does work. Any ideas?! '!(CVS)' Means open all file that doesn't match CVS (from bash manual). (faui00j) [~] /bin/bash -c 'vim !(CVS)' /bin/bash: -c: line 1: syntax error near unexpected token `!(C' /bin/bash: -c: line 1: `vim !(CVS)' I also tried to a...

Re: 'do over' doesn't work
Ash As I recall, the first SAS arrays were not subscripted and did not use direct array references. The do over statement simply said, go through the variables listed in the array starting with the first and going to the last. The erro messages that you received were telling you that you should not use the brackets on the array names. From my standpoint, the beauty of the do over is that it makes coding simpler and, given my clumsy fingers, anything that reduces my chances of screwing up are a help. However, these days, I would not choose to use a do over expression in code that was going t...

Why doesn't this 'next if' work?
Hi All, I'm fairly new to perl, and have already fixed this problem, but I want to understand why it didn't work before. This is the original, non-working code: @o_list = (); foreach my $o ( @{$stuff->{thingys}} ) { # Exclude if no match $match = 'n'; foreach $thingy (@test_thingys) { if ($o->{thingy} == $thingy) { $match = 'y'; last; } } next if ($match != 'y'); push @o_list, $o; } Basically, its running through a list of "thingys", checking to see if the item matches any of a list of test "thingy...

'=' command doesn't work?
Hi, i have a strange problem. It seems so simple, but : disp(['temp2=',num2str(temp2(end))]); Ergebnis(j) = temp2(end); disp(['Ergebnis=',num2str(Ergebnis(j))]); the result is : temp2=184.37 Ergebnis=1 why is Ergebnis(j) still 1? It should be 184.37. Where is the problem, i am quite confused right now. ...

Why doesn't 'uiwait' work?
UI with button. When I execute this: .... set (hButton, 'Callback', 'uiresume(hFigure)'); .... disp('A') uiwait(hFigure) disp('B') .... I get 'A'. But when I press the button I get: ??? Error using ==> waitfor Undefined function or variable 'hFigure'. Why don't I get 'B' ? NOTE: hFigure is the handles of the figure where Button is placed. hButton is the handles of Button. Thanks. ...

Ubuntu Lurid crapware: "sound stopped working..video unstable...can't read USB sticks...battery meter inaccurate...shutdown doesn't work"
"Sound - worked then stopped working (just one boot up the controls were gone and no sound came from anywhere), now fixed with the removal of pulse (this is a standard issue with ubuntu since 8.04). still have an issue with going to system->prefs->sound, its just hangs waiting for sound system. Video - Nvidia card but unstable video and no openGL until attention given to correct driver - the standard install looked pretty grim. USB sticks cannot read, get permission denied errors. Battery meter seems wildly inaccurate, claims 7 hours then dies in 2. Shutdown see...

OCI-8, Oracle : 'ORDER BY' doesn't work with 'bind_param'
Hello, I'm testing the gem 'ruby-oci8'/oci8 (1.0.4) under Windows with Ruby 1.8.6 patchlevel 287. I play with the user SCOTT and the table EMP of ORACLE. First, the table : --------------- Schema = SCOTT, Name =EMP Columns8 EMPNO | NUMBER(4) NOT NULL ENAME | VARCHAR2(10) JOB | VARCHAR2(9) MGR | NUMBER(4) HIREDATE | DATE SAL | NUMBER(7,2) COMM | NUMBER(7,2) DEPTNO | NUMBER(2) NOT NULL --------------- The rows : --------------- 7876,ADAMS,CLERK,7788,1983/01/12 00:00:00,1100.0,,20 7499,ALLEN,SALESMAN,7698,1981/02/20 00:00:00,1600.0,300.0,30 7698,BLAKE,MANAGER,7839,1981/05/01 00:00:0...

Can't figure it out why my code doesn't work
My program needs to select the microphone as the default input, but I can't figure it out why my code doesn't work. (I've been able to set the mic's recording volume) I have been thinking about that for a whole day I post some of the code here, and hope somebody could help me, pls...I'm so tired { MIXERLINE mxl; MIXERCONTROL mxc; MIXERLINECONTROLS mxlc; mxl.cbStruct = sizeof(MIXERLINE); mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN; if (::mixerGetLineInfo(reinterpret_cast<HMIXEROBJ>(mixer), &mxl, MIXE...

Yosemite: Can't add a space (+ doesn't work)
Can't add a new space with Mission Control. CTRL-up-arrow works, thence "+" should allow adding a space - but doesn't= =2E Full screen Fusion 7 does go into a new space (or one per VM) and=20 CTRL-left/right arrows works for that. But not "+" a space. I restored the default shortcuts to be sure. No change. --=20 << Among Broad Outlines, conception is far more pleasurable than =93carrying [the children] to fruition.=94 Sadly, =93there=92s a high infant mortality rate among Broad Outlines=97they often fall prey to Nonstarters.=94 ...

IE doesn't work if ZoneAlarm isn't running
I have Release 2.6 of Zonealarm on my laptops. I've found that i have to have ZoneAlarm running to surf the net. If ZoneAlarm is not running I get the page not found message in IE. I can't even receive/send emails via Outlook Express. Is there a setting in ZoneAlarm that does this? > I have Release 2.6 of Zonealarm on my laptops. I've found that i have > to have ZoneAlarm running to surf the net. If ZoneAlarm is not > running I get the page not found message in IE. I can't even > receive/send emails via Outlook Express. Is there a setting in > ZoneAlarm th...

Yosemite: Can't add a space (+ doesn't work)
Can't add a new space with Mission Control. CTRL-up-arrow works, thence "+" should allow adding a space - but doesn't= =2E Full screen Fusion 7 does go into a new space (or one per VM) and=20 CTRL-left/right arrows works for that. But not "+" a space. I restored the default shortcuts to be sure. No change. --=20 << Among Broad Outlines, conception is far more pleasurable than =93carrying [the children] to fruition.=94 Sadly, =93there=92s a high infant mortality rate among Broad Outlines=97they often fall prey to Nonstarters.=94 ...

What to do if in 'putty' emulator mouse doesn't work in 'mc' if env TERM=putty
Patch the source of mc, obviously. The patch for mc-4.8.11: cd lib/tty cat >tty.patch <<DONE 111a112 > || strncmp (termvalue, "putty", 5) == 0 DONE patch -i tty.patch tty.c ...

'=' command doesn't work? #2
Hi, i have a strange problem. It seems so simple, but : disp(['temp2=',num2str(temp2(end))]); Ergebnis(j) = temp2(end); disp(['Ergebnis=',num2str(Ergebnis(j))]); the result is : temp2=184.37 Ergebnis=1 why is Ergebnis(j) still 1? It should be 184.37. Where is the problem, i am quite confused right now. "martin Müllinger" <zettinger@gmx.de> wrote in message <i9m736$gu7$1@fred.mathworks.com>... > Hi, > > i have a strange problem. It seems so simple, but : > > disp(['temp2=',num2str(temp2(end))]); &g...

Re: 'do over' doesn't work #2
Ramsamy, The code that follows will get you into DO OVER. Do not use '*' in the dimension statements. Use the implicit index of _I_ t= o refer to individual elements of the array. DATA TABLE_BIDON; INPUT X1 X2 X3 X4 X5 $; CARDS; 2 . 5 1161 ABELIEN 35 6 3 1336 ALMERIC 82 1 5 1499 . ; RUN; DATA TABLE_BIDON ; SET TABLE_BIDON; ARRAY A_VARNUM _NUMERIC_; ARRAY A_VARCAR _CHARACTER_; DO OVER A_VARNUM; IF A_VARNUM[_i_] =3D . THEN A_VARNUM[_i_] =3D 0; END; DO OVER A_VARCAR; IF COMPRESS(A_VARCAR[_i_]) IN (".","") THEN A_VARCAR[_...

'dd' doesn't work on NFS?
Hi, all; Both machines use Red HAt advanced server 2.1 [root@p4asus root]# dd if=/dev/zero of=/nfs-share/test bs=1M count=20 dd: writing `/oradata/test': Input/output error 2+0 records in 1+0 records out /nfs-shared is mounted on another RHAS2.1 machine. Use 'rw,no_root_squash' in '/etc/exports' file. Other operations on NFS (like, cp, mv, touch) are fine so far. Any ideas? THanks a lot! On 29 Sep 2003 14:01:14 -0700, JZ <ibm_97@yahoo.com> wrote: >Hi, all; > >Both machines use Red HAt advanced server 2.1 > >[root@p4asus root]# dd if=/dev/zero of=/nfs-share/test bs=1M count=20 >dd: writing `/oradata/test': Input/output error >2+0 records in >1+0 records out > >/nfs-shared is mounted on another RHAS2.1 machine. Use >'rw,no_root_squash' in '/etc/exports' file. Other operations on NFS >(like, cp, mv, touch) are fine so far. > >Any ideas? > Use a much smaller block size, say 8k or so, and increase the count accordingly. Villy ...

Re: 'do over' doesn't work #3
On Sat, 24 Jan 2009 14:25:41 +0000, karma <dorjetarap@GOOGLEMAIL.COM> wrote: >Hi Ash, > >What is the purpose of your code? Looking at the test data it appears >you want to replace missing numeric values with the number zero and >missing character data with a "Z". Replacing missing numerics with >zero seems like a pretty standard thing, and therefore there are a few >ways to handle this in SAS. Yes. See http://www.sascommunity.org/wiki/Generating_Zeroes_in_PROC_TRANSPOSE_Output or http://tinyurl.com/abozdc >Replacing missing character variables with &g...

Web resources about - Counter in FSM doesn't work - comp.lang.vhdl

Resources last updated: 2/23/2016 7:27:18 AM