incrementing a 1-bit register?

This is a discussion on incrementing a 1-bit register? within the verilog forums in Programming Languages category; 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...

Go Back   Application Development Forum > Programming Languages > verilog

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-30-2008, 12:27 PM
laserbeak43
Guest
 
Default incrementing a 1-bit register?

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
Reply With Quote
  #2  
Old 08-30-2008, 12:52 PM
Muzaffer Kal
Guest
 
Default Re: incrementing a 1-bit register?

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.
Reply With Quote
  #3  
Old 08-30-2008, 01:20 PM
laserbeak43
Guest
 
Default Re: incrementing a 1-bit register?

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.


Reply With Quote
  #4  
Old 08-31-2008, 04:24 AM
visiblepulse
Guest
 
Default Re: incrementing a 1-bit register?

It would also pay it one hell of a nice complement.
Reply With Quote
  #5  
Old 09-01-2008, 12:56 AM
Mark McDougall
Guest
 
Default Re: incrementing a 1-bit register?

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
Reply With Quote
  #6  
Old 09-01-2008, 04:32 AM
andersod2
Guest
 
Default Re: incrementing a 1-bit register?


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?

Reply With Quote
  #7  
Old 09-01-2008, 07:03 AM
Jonathan Bromley
Guest
 
Default Re: incrementing a 1-bit register?

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.
Reply With Quote
  #8  
Old 09-01-2008, 08:55 PM
Mark McDougall
Guest
 
Default Re: incrementing a 1-bit register?

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
Reply With Quote
  #9  
Old 09-02-2008, 11:49 AM
Kevin Neilson
Guest
 
Default Re: incrementing a 1-bit register?

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
Reply With Quote
  #10  
Old 09-03-2008, 09:00 AM
laserbeak43
Guest
 
Default Re: incrementing a 1-bit register?

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
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:04 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.