Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

i want grey code counder eq ??

Status
Not open for further replies.

niks

Full Member level 3
Joined
Mar 18, 2002
Messages
189
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,296
Activity points
1,386
hi
can anyone give me optimized 4 bit grey code counter. i want equation for bit 0-3 .....
~niks~
 

niks said:
hi
can anyone give me optimized 4 bit grey code counter. i want equation for bit 0-3 .....
~niks~

In what way do you whant the answer? C code, VHDL, gates, ....?

0000 0
0001 1
0011 2
0111 3
1111 4
1110 5
1100 6
1000 7

Regards
 

i want to write it in verilog. can u help me.
 

There are ways of doing it at RTL level but it's quite cumbersome, here you have an extract of the COMP.ARCH.FPGA newsgroup:

--------------------------------------------------------
Article: 28365
Subject: Re: grey code counters
Date: Wed, 10 Jan 2001 09:20:04 -0800
Here are my notes:
Grey-Coded Addresses
Only one bit/address changes at any time
Therefore no glitches from the identity comparator

Implementation:
Build binary counter
Generate XOR of two adjacent D-inputs
(that is the trick ! Don't use the binary Q, use the binary D)
Feed these XORs to a register = Grey !
MSB binary = MSB Grey
Advantage: very fast and easily epandable.

Yes, it wastes flip-flops. But I think it is still the most compact
(cheapest) solution in Virtex, where one CLB implements two bits, since it
has 4 flip-flops.
I tried various other ways, and -while they did not waste flip-flops- they
were no cheaper.
BTW: You can of course use the simultaneous binary output "for free".
You can also run the counter in both directions "for free".
I will gladly accept a more compact solution.

--------------------------------------------------------

There is more info in the newsgroup about it so have a look.

Why do you need a grey counter? Low noise, low power consumption?I don't like them what can I say.

Regards,
Maestor
 

i want to build grey counter for low power consumption.so i cant use binary counter.converting binary counter to grey ll still increase power.
actually im using xcr3064.
 

edit:
Sorry I didnt check the previous mail

Try the following for a 4-bit gray counter


////////////////////////////////////////////////////////////////////////////////
module GrayCounter(
clk_i ,
rst_i ,
GrayCount_o
) ;
parameter aw = 3 ;

input clk_i ;
input rst_i ;
output [aw:0] GrayCount_o ;
reg [aw:0] BinCount ;
reg [aw:0] GrayCount_o ;
wire [aw:0] NextBinCount ;
integer i ;

assign NextBinCount = BinCount + 1'b1 ;

always @ (posedge clk_i or posedge rst_i)
begin
if(rst_i == 1'b1)
begin
BinCount <= 0 ;
GrayCount_o<= 0 ;
end
else
begin
BinCount <= NextBinCount ;
GrayCount_o[aw] <= NextBinCount[aw] ;
for(i=0; i<aw; i=i+1)
GrayCount_o <= NextBinCount[i+1]^NextBinCount ;
end
end

endmodule
////////////////////////////////////////////////////////////////////////////////
 

i dun want to use more than 4 flops. how can i built it ?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top