| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi, I'm new to verilog and i wanted to know, what would happen if i were to increment a 1-bit register over and over? would it just toggle between 0 and 1? or would i produce some kind of error during synthesis? Thanks |
|
#2
| |||
| |||
| On Sat, 30 Aug 2008 09:27:18 -0700 (PDT), laserbeak43 <laserbeak43@gmail.com> wrote: >Hi, >I'm new to verilog and i wanted to know, what would happen if i were >to increment a 1-bit register over and over? would it just toggle >between 0 and 1? Yes exactly. > or would i produce some kind of error during >synthesis? No, what you want is well-defined and would work the way you imagine. |
|
#3
| |||
| |||
| ahh Thank you very much ![]() On Aug 30, 12:52*pm, Muzaffer Kal <k...@dspia.com> wrote: > On Sat, 30 Aug 2008 09:27:18 -0700 (PDT), laserbeak43 > > <laserbea...@gmail.com> wrote: > >Hi, > >I'm new to verilog and i wanted to know, what would happen if i were > >to increment a 1-bit register over and over? would it just toggle > >between 0 and 1? > > Yes exactly. > > > or would i produce some kind of error during > >synthesis? > > No, what you want is well-defined and would work the way you imagine. |
|
#4
| |||
| |||
| It would also pay it one hell of a nice complement. |
|
#5
| |||
| |||
| visiblepulse wrote: > It would also pay it one hell of a nice complement. <groan> That was going a "bit" too far! ![]() Regards, -- Mark McDougall, Engineer Virtual Logic Pty Ltd, <http://www.vl.com.au> 21-25 King St, Rockdale, 2216 Ph: +612-9599-3255 Fax: +612-9599-3266 |
|
#6
| |||
| |||
| haha, Ok follow up question...would doing that be the best way of toggling a bit, or would using the ! operator or the ~ operator be better? Can never tell with these cells being the way they are...I implemented a half-adder using gates just to see if it was actually more efficient (i.e. used fewer "equivalent gates" or what have you) than just using the + operator. Of course, the + operator was more effective in that regard and far easier to read. Thoughts? |
|
#7
| |||
| |||
| On Mon, 1 Sep 2008 01:32:02 -0700 (PDT), andersod2 wrote: > + operator was more effective in that >regard and far easier to read. Thoughts? huh? If your design intent is to toggle a register, then surely R <= ~R; is much clearer and easier to read than R <= R + 1; The former looks like flipping a bit; the latter looks like arithmetic. Arithmetic on single-bit operands is somewhat un-intuitive for many folk, me included, and I usually try to avoid it. YMMV. -- 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. |
|
#8
| |||
| |||
| andersod2 wrote: > Ok follow up question...would doing that be the best way of toggling a > bit, or would using the ! operator or the ~ operator be better? Can > never tell with these cells being the way they are... You could always implement each and look at the resulting equations produced by the synthesizer. That way you wouldn't have to rely on our "opinions" and an added benefit is that you might accidently learn more than you originally intended! ![]() Regards, -- Mark McDougall, Engineer Virtual Logic Pty Ltd, <http://www.vl.com.au> 21-25 King St, Rockdale, 2216 Ph: +612-9599-3255 Fax: +612-9599-3266 |
|
#9
| |||
| |||
| andersod2 wrote: > haha, > > Ok follow up question...would doing that be the best way of toggling a > bit, or would using the ! operator or the ~ operator be better? Can > never tell with these cells being the way they are...I implemented a > half-adder using gates just to see if it was actually more efficient > (i.e. used fewer "equivalent gates" or what have you) than just using > the + operator. Of course, the + operator was more effective in that > regard and far easier to read. Thoughts? > For a single bit, the choice between ! and ~ is a matter of taste. If it is a bit that is treated like a Boolean, I like to use the logical operator !. Otherwise I'd use ~. -Kevin |
|
#10
| |||
| |||
| On Sep 2, 11:49*am, Kevin Neilson <kevin_neil...@removethiscomcast.net> wrote: > andersod2 wrote: > > haha, > > > Ok follow up question...would doing that be the best way of toggling a > > bit, or would using the ! operator or the ~ operator be better? * Can > > never tell with these cells being the way they are...I implemented a > > half-adder using gates just to see if it was actually more efficient > > (i.e. used fewer "equivalent gates" or what have you) than just using > > the + operator. *Of course, the + operator was more effective in that > > regard and far easier to read. *Thoughts? > > For a single bit, the choice between ! and ~ is a matter of taste. *If > it is a bit that is treated like a Boolean, I like to use the logical > operator !. *Otherwise I'd use ~. > -Kevin wow had no idea this thread was still going. thanks a lot for your help. these are all things i'll be sure to consider. a bit too far LOL!! i'm glad to see it's not illegal to have a sense of humor here ![]() |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.