Counting in Gray – Part III – Putting Everything Together

May 14, 2007

In the last post we built the basis for our Gray counter implementation. In this post we will combine all observations and create a “Gray bit cell” which could be instantiated as many times as one wishes to create Gray counters which count up or down and are of any desired length.

As mentioned before, the basic idea is to build a “Gray bit cell”. Naturally it has a single bit output, but the cell also has to get the information from all previous cells whether or not a pattern was identified and whether it has to toggle or not.

tflop.png The latter point reminds us that we will have to use T-Flops for the implementation, since the patterns we observed in the previous post only concern when a certain Gray bit toggles and not its absolute value. The most basic implementation of a T-Flop is presented on the figure on the right.

The abstract view of the Gray cell is presented to the left. Both the clock and reset inputs have been omitted. The cell inputs and outputs are:

  • Q_o – Gray value of the specific bit (n)
  • Q_i – The previous – n-1 – Gray bit value
  • Z_i – All Gray bits n-2 down to 0 are “0”
  • Z_o – All Gray bits n-1 down to 0 are “0”
  • parity – Parity bit – or more correctly inverted parity
  • up_n_dn – If “1” count up, if “0” count down
  • enable – enable counting
  • Two implementations of the Gray cell are depicted below, the left one being more intuitive than the right, but the right one is more compact. Both implementations are logically identical.

    All that is left now is to see how to connect the Gray cells in series to produce a Gray up/down counter.
    In the final picture the Gray cells were connected to form a Gray counter. Notice that some cells are connected in a special way:

  • Cell 0 – Q_i and Z_i are both connected to “1”, The parity input is inverted and Z_o left unconnected
  • Cell 1 – Z_i connected to “1”
  • Cell n (MSB) – Q_i is connected to “1”, Z_o left unconnected
  • A few more words on the parity bit. In the given implementation it is generated by a normal D-Flop with its Qbar output connected to its D input. The same functionality can be achieved without this extra D-Flop, by using an Xor tree on the outputs of the Gray counter – remember our first observation from the previous post? the parity changes with each count.

    That concludes this series of posts on Gray counters, but don’t worry I promise there will be more interesting stuff coming on Gray codes.


    One comment

    1. In the last circuit shown above, the parity toggle flop is not enabled, but the counter is. It will get out of sync with the true parity when enable is not active.

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )


    Connecting to %s

    %d bloggers like this: