Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Another syntax question
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Daku  
View profile  
 More options Jan 23, 2:43 am
Newsgroups: comp.lang.verilog
From: Daku <dakup...@gmail.com>
Date: Sun, 22 Jan 2012 23:43:17 -0800 (PST)
Local: Mon, Jan 23 2012 2:43 am
Subject: Another syntax question
Please pardon me if this is a very stupid question. My Verilog
is rusty. Could some Verilog guru please explain what the
following means ? I have seen it before, and it seems very
complicated. Does it mean that if sum[25] == true, normalshift is
assigned 0, and so on down the chain.
Thanks for your help.

assign normalshift =

                sum[25] ? 0 :

                sum[24] ? 1 :

                sum[23] ? 2 :

                sum[22] ? 3 :

                sum[21] ? 4 :

                sum[20] ? 5 :

                sum[19] ? 6 :

                sum[18] ? 7 :

                sum[17] ? 8 :

                sum[16] ? 9 :

                sum[15] ? 10 :

                sum[14] ? 11 :

                sum[13] ? 12 :

                sum[12] ? 13 :

                sum[11] ? 14 :

                sum[10] ? 15 :

                sum[9] ? 16 :

                sum[8] ? 17 :

                sum[7] ? 18 :

                sum[6] ? 19 :

                sum[5] ? 20 :

                sum[4] ? 21 :

                sum[3] ? 22 :

                sum[2] ? 23 :

                sum[1] ? 24 : 25;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
glen herrmannsfeldt  
View profile  
 More options Jan 23, 6:36 am
Newsgroups: comp.lang.verilog
From: glen herrmannsfeldt <g...@ugcs.caltech.edu>
Date: Mon, 23 Jan 2012 11:36:39 +0000 (UTC)
Local: Mon, Jan 23 2012 6:36 am
Subject: Re: Another syntax question

Daku <dakup...@gmail.com> wrote:
> Please pardon me if this is a very stupid question. My Verilog
> is rusty. Could some Verilog guru please explain what the
> following means ? I have seen it before, and it seems very
> complicated. Does it mean that if sum[25] == true, normalshift is
> assigned 0, and so on down the chain.
> Thanks for your help.
> assign normalshift =
>                sum[25] ? 0 :
>                sum[24] ? 1 :
>                sum[23] ? 2 :

(snip)

This is the conditional operator that came from C. (At least that
is where I first knew it in this form.)

So, yes, if sum[25] is true the value is zero (the left side of the : ),
otherwise it has the value of the expression on the right side of the :.

Whether that is a good way to implement a priority encoder, I don't
know.

The logic, as written, would be very slow, propagating all the way
through in the low sum[], high return value cases. The tools are very
good at optimizing much logic, and reasonably likely this one, too.

Even so, I probably wouldn't write it this way.

-- glen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gabor  
View profile  
 More options Jan 23, 3:29 pm
Newsgroups: comp.lang.verilog
From: Gabor <ga...@szakacs.invalid>
Date: Mon, 23 Jan 2012 15:29:15 -0500
Local: Mon, Jan 23 2012 3:29 pm
Subject: Re: Another syntax question

Because the ? operator can be used in a continuous assignment it is
often used to generate multiplexers and encoders.  The alternative
is to use a reg instead of a wire, and then in an always @* block
use a case statement.  Normally I would not use the ? operator
for building very large encoders or multiplexers, however it is likely
that the synthesis tool will build the same hardware as if you
used a reg and a case statement.

I think this is more a matter of style than substance.  Some people
like to keep combinatorial equations in continuous assigns rather
than using always @*, and may go to extreme lengths to make it happen
as you can see here.  Still, once you know how it works, the code
is readable enough, I guess...

-- Gabor


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »