PoC.arith.counter_ringΒΆ

This module implements an up/down ring-counter with loadable initial value (seed) on reset. The counter can be configured to a Johnson counter by enabling INVERT_FEEDBACK. The number of counter bits is configurable with BITS.

Entity Declaration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
entity arith_counter_ring is
  generic (
    BITS            : positive;
    INVERT_FEEDBACK : boolean   := FALSE                                  -- FALSE -> ring counter;   TRUE -> johnson counter
  );
  port (
    Clock   : in  std_logic;                                              -- Clock
    Reset   : in  std_logic;                                              -- Reset
    seed    : in  std_logic_vector(BITS - 1 downto 0) := (others => '0'); -- initial counter vector / load value
    inc     : in  std_logic                           := '0';             -- increment counter
    dec     : in  std_logic                           := '0';             -- decrement counter
    value   : out std_logic_vector(BITS - 1 downto 0)                     -- counter value
  );
end entity;