FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-31-2007, 11:56 AM
Amir
Guest
 
Posts: n/a
Default ordering in Verilog

Hi,
I have a question, does this code means that when I 'm in the IDLE
state , first the arbiter checks if req0_ == ON and THEN req1_ ==
ON ?!
or they take place in the same time ?!

The Code :

always @(curr_state or req0_ or req1_ or req2_ or req3_ or req4_ or
req5_ or req6_ or req7_)
begin
next_state = 0;

case(curr_state)

IDLE:

begin
if(req0_ == ON)
begin
next_state = GNT0;
end
else
if(req1_ == ON)
begin
next_state = GNT1;
end
...
. ...

thanks in advance
-Amir

Reply With Quote
  #2 (permalink)  
Old 08-31-2007, 06:19 PM
gabor
Guest
 
Posts: n/a
Default Re: ordering in Verilog

On Aug 31, 5:56 am, Amir <sting...@gmail.com> wrote:
> Hi,
> I have a question, does this code means that when I 'm in the IDLE
> state , first the arbiter checks if req0_ == ON and THEN req1_ ==
> ON ?!
> or they take place in the same time ?!
>
> The Code :
>
> always @(curr_state or req0_ or req1_ or req2_ or req3_ or req4_ or
> req5_ or req6_ or req7_)
> begin
> next_state = 0;
>
> case(curr_state)
>
> IDLE:
>
> begin
> if(req0_ == ON)
> begin
> next_state = GNT0;
> end
> else
> if(req1_ == ON)
> begin
> next_state = GNT1;
> end
> ...
> . ...
>
> thanks in advance
> -Amir



It's not a matter of time, but of priority. The "else"
clause ensures that next_state only goes to GNT1 if
(req1_ == ON) _AND_ _NOT_ (req0_ == ON)

In other words req0_ has higher priority than req1_
in the case where they are both "ON".

By the way, if you leave out the "else" in the above code
exacly the opposite is true. In this case req1_ would
have higher priority as it is evaluated last. You
could think of this as a sequential (time) issue, and
in fact this is how simulators work, but the synthesized
logic is still just AND and OR gates that must evaluate
the inputs in parallel.

HTH,
Gabor

Reply With Quote
  #3 (permalink)  
Old 08-31-2007, 09:27 PM
[email protected]
Guest
 
Posts: n/a
Default Re: ordering in Verilog

So does the synthesized logic have chances of races if there are two
separate if as mentioned by Gabor in the end of the last mail

Reply With Quote
  #4 (permalink)  
Old 08-31-2007, 10:24 PM
Chris F Clark
Guest
 
Posts: n/a
Default Re: ordering in Verilog

It is extremely likely that they will be checked simultaneously in
synthesized hardware. However, it is possible that you can get
artifacts in your simulation, because they may be tested sequentially
in the simulator (and potentially the values could change in between
the tests). I'm not certain you could find text in the standard that
would require them to be tested sequentially and would allow one to
construct a test that would only work if they were tested
sequentially.
Reply With Quote
  #5 (permalink)  
Old 09-01-2007, 12:14 AM
Alex
Guest
 
Posts: n/a
Default Re: ordering in Verilog

On Aug 31, 3:27 pm, "parag_p...@hotmail.com" <parag_p...@hotmail.com>
wrote:
> So does the synthesized logic have chances of races if there are two
> separate if as mentioned by Gabor in the end of the last mail


In order to avoid simulation/synthesis mismatches, it is better to
code it in another way:

case (curr_sate)
IDLE:
case ({req0_,req1})
...

considering all possible req0, req1_ combinations.


-Alex

Reply With Quote
  #6 (permalink)  
Old 09-01-2007, 01:55 PM
Amir
Guest
 
Posts: n/a
Default Re: ordering in Verilog

thanks for the replies.
I wrote a round robin arbiter, using the method in the first message,
but it doesn't seem to work, I mean all the 'priority' that Gabor
talked about.
the arbiter should give grant to the requests, and the requests should
be "ON" as long as the client needs the bus.
I used also idle states between the grants, but nothing seems to
work ..
you have any advice ?

thanks
-Amir


Reply With Quote
  #7 (permalink)  
Old 09-04-2007, 05:29 AM
Mahurshi Akilla
Guest
 
Posts: n/a
Default Re: ordering in Verilog

Two questions here:

1. Is it okay to set the next_state to 0 before the
case(current_state)? I thought this would cause a glitch if the next
state changes in the case statement.

2. Shouldn't we use <= and not = since we're putting these statements
in an always @ block?




On Aug 31, 2:56 am, Amir <sting...@gmail.com> wrote:
> Hi,
> I have a question, does this code means that when I 'm in the IDLE
> state , first the arbiter checks if req0_ == ON and THEN req1_ ==
> ON ?!
> or they take place in the same time ?!
>
> The Code :
>
> always @(curr_state or req0_ or req1_ or req2_ or req3_ or req4_ or
> req5_ or req6_ or req7_)
> begin
> next_state = 0;
>
> case(curr_state)
>
> IDLE:
>
> begin
> if(req0_ == ON)
> begin
> next_state = GNT0;
> end
> else
> if(req1_ == ON)
> begin
> next_state = GNT1;
> end
> ...
> . ...
>
> thanks in advance
> -Amir



Reply With Quote
  #8 (permalink)  
Old 09-04-2007, 03:00 PM
gabor
Guest
 
Posts: n/a
Default Re: ordering in Verilog

On Sep 3, 11:29 pm, Mahurshi Akilla <mahur...@gmail.com> wrote:
> Two questions here:
>
> 1. Is it okay to set the next_state to 0 before the
> case(current_state)? I thought this would cause a glitch if the next
> state changes in the case statement.
>


This is fine. It would create a glitch in simulation with
zero width, but for synthesis just gives a default assignment
if there is no other assignment below. Assuming no logic
uses the output of the assignment (next_state) as a clock
source there should be no problems.

> 2. Shouldn't we use <= and not = since we're putting these statements
> in an always @ block?
>


This is a combinatorial always block, so the blocking assignment
is correct here. Use non-blocking <= assignments for registered
always @ (posedge clk) style blocks for synthesis.

Presumably there is another block like:

always @(posedge clock or posedge reset)
if (reset)
curr_state <= 0;
else
curr_state <= next_state;

so the sequential logic is not in the always block originally
posted.

> On Aug 31, 2:56 am, Amir <sting...@gmail.com> wrote:
>
> > Hi,
> > I have a question, does this code means that when I 'm in the IDLE
> > state , first the arbiter checks if req0_ == ON and THEN req1_ ==
> > ON ?!
> > or they take place in the same time ?!

>
> > The Code :

>
> > always @(curr_state or req0_ or req1_ or req2_ or req3_ or req4_ or
> > req5_ or req6_ or req7_)
> > begin
> > next_state = 0;

>
> > case(curr_state)

>
> > IDLE:

>
> > begin
> > if(req0_ == ON)
> > begin
> > next_state = GNT0;
> > end
> > else
> > if(req1_ == ON)
> > begin
> > next_state = GNT1;
> > end
> > ...
> > . ...

>
> > thanks in advance
> > -Amir



Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenation operator, value ordering, bug in ModelSim, or ??? Edmond Coté Verilog 1 02-13-2007 04:49 PM


All times are GMT +1. The time now is 01:34 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved