Home    Bloggers    Messages    Webinars    Resources   
Tw  |  Fb  |  In  |  Rss
Ken Boyette

Jurassic HDL: A Gray Code Counter

Ken Boyette
Page 1 / 2   >   >>
geekyasa
geekyasa
8/30/2012 11:47:02 AM
User Rank
Beginner
Re: altera's gray counter
I also tried both plus some other stuff by googling as well. Couldnt find a solution. I will send the error message to you so if you can have alook and help me on it.

50%
50%
geekyasa
geekyasa
8/30/2012 11:45:55 AM
User Rank
Beginner
Re: altera's gray counter
I tried many forms by googling but nothing seemed to solve the issue I have.

50%
50%
thrakkor
thrakkor
8/27/2012 10:34:12 AM
User Rank
Blogger
what about
what about a Johnson Counter/Twisted Ring counter if an "up" counter is not absolutely a requirement?  it still exhibits grey code single bit changes, just not in ascending order.

http://en.wikipedia.org/wiki/Ring_counter

like thus:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity j_counter is
  generic (g_width : integer := 4);
  port (i_clk : in std_logic;
          i_rst : in std_logic;
          o_count : out std_logic_vector(g_width - 1 downto 0));
end entity j_counter;

architecture rtl of j_counter is

  signal f_count : unsigned(g_width - 1 downto 0);

begin -- architecture rtl

------------------------------------------------------------------------------
--! Johnson counter. feed inverted MSB back into LSB and shift LSB -> MSB
------------------------------------------------------------------------------
j_cnt_proc : process (i_clk) is
begin -- process j_cnt_proc
  if (rising_edge(i_clk)) then -- rising clock edge
    if (i_rst = '1') then -- synchronous reset (active high)
      f_count <= (others => '0');
    else
      --! invert MSB and feed into LSB
      f_count(0) <= not(f_count(g_width - 1));
      --! shift up
      for c in g_width - 1 downto 1 loop
        f_count(c) <= f_count(c - 1);
      end loop; -- c
    end if;
  end if;
end process j_cnt_proc;

o_count <= std_logic_vector(f_count);

end architecture rtl;


i just whipped this up from the wikipedia description and haven't compiled it yet.

in the examples, I would have declared bin_count as unsigned vector so as to eliminate all conversions until possibly outputing it as SLV if needed.

another important place I've seen grey encoding is for FIFO address pointers.

50%
50%
William Murray
William Murray
8/26/2012 3:09:35 PM
User Rank
Blogger
Believe NASA uses Gray Code Counters / Logic for timing on many of it's launch vehicles
Can generate a more consistent time delay than SW based event counters with multiple interrupts/timers firing and making the multi-tasking not quite perfect in it's intervals, where logic can time out 30 different events exactly to the nano-second --

50%
50%
jacklsw86
jacklsw86
8/26/2012 4:34:06 AM
User Rank
Blogger
Re: altera's gray counter
@geekyasa

I looked through the Ken's codes and altera's codes briefly. They should be applying the same concept, just the implementation is different (those "programmers" all-time-favourite, loops).

which part do you encounter error? lemme see if i can give you some help ;)

50%
50%
Bill White
Bill White
8/26/2012 2:44:05 AM
User Rank
Expert
Re: Gray Code.
@hamster--good find; I am interested to see if it was a navigational computation or something else--will investigate!

50%
50%
geekyasa
geekyasa
8/26/2012 2:25:59 AM
User Rank
Beginner
Re: altera's gray counter
No Ken Im reffering to Altera's Counter.. Too bad looks like you do not know about it . Any idea where I can find some data regarding this ? I tried Googling but nothing worthwhile was found :(

50%
50%
KenwickVS
KenwickVS
8/25/2012 9:47:22 PM
User Rank
Blogger
Re: Gray Code.
@Hamster - Thanks for pointing this old beast out. I'll bet that encoder was "high dollar" back in the day. I'd guess military or scientific, because of the precision.

50%
50%
KenwickVS
KenwickVS
8/25/2012 4:50:22 PM
User Rank
Blogger
Re: Some comments
@Devel: "it's 2012!" - It wasn't nearly 2012 when I wrote the counter. I appreciate the input, but it doesn't seem you looked at the actual code that was attached. It doesn't use a binary counter at all - that was for example. And I did use "numeric_std" - check out the attachment. I confess to my old school clock terminology. Some habits are hard to break.

50%
50%
KenwickVS
KenwickVS
8/25/2012 10:50:17 AM
User Rank
Blogger
Re: altera's gray counter
@geekyasa - Are you referring to Altera's counter (which I know nothing about) or did you download my files for this project?

50%
50%
Page 1 / 2   >   >>
More Blogs from Ken Boyette
Ken Boyette has worked around machines all his life, but he's having trouble with the idea of interacting with them the way one would interact with another person.
If you use Google a bit, you can find all sorts of information about both ABEL and CUPL. You might even get off your high horse as a result.
In this column, KenwickVS (a.k.a. Ken Boyette) walks us through the VHDL code for his interpretation of the famous Motorola MC14500B single-bit processor.
We examine the block diagram and instruction set for our recreation of the MC14500B single-bit processor and also create the VHDL entity for our processor core.
flash poll
follow us on twitter
follow Xilinx on twitter
like us on facebook
like Xilinx on facebook
All Programmable Planet     About Us     Contact Us     Help     Register     Twitter     Facebook     RSS