Add Gray counter implementation and testbench
Introduces a synchronous Gray counter with configurable width, reset, enable, and look-ahead functionality. Implements binary-to-Gray and Gray-to-binary conversion functions. Includes a testbench for simulation and validation of the counter's behavior.
This commit is contained in:
46
tests/GrayCounter_tb.vhd
Normal file
46
tests/GrayCounter_tb.vhd
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity GrayCounter_tb is
|
||||
end;
|
||||
|
||||
architecture bench of GrayCounter_tb is
|
||||
-- Clock period
|
||||
constant clk_period : time := 10 ns;
|
||||
-- Generics
|
||||
constant G_Width : integer := 6;
|
||||
constant G_InitialValue : integer := 0;
|
||||
constant G_ResetValue : integer := 0;
|
||||
constant G_CountingDirection : string := "UP";
|
||||
constant G_LookAhead : integer := 1;
|
||||
-- Ports
|
||||
signal I_CLK : std_logic := '0';
|
||||
signal I_CE : std_logic := '1';
|
||||
signal I_RST : std_logic := '0';
|
||||
signal I_CountEnable : std_logic := '1';
|
||||
signal O_Value : std_logic_vector(G_Width - 1 downto 0);
|
||||
signal O_LookAheadValue : std_logic_vector(G_Width - 1 downto 0);
|
||||
begin
|
||||
|
||||
GrayCounter_inst : entity work.GrayCounter
|
||||
generic map (
|
||||
G_Width => G_Width,
|
||||
G_InitialValue => G_InitialValue,
|
||||
G_ResetValue => G_ResetValue,
|
||||
G_CountingDirection => G_CountingDirection,
|
||||
G_LookAhead => G_LookAhead
|
||||
)
|
||||
port map (
|
||||
I_CLK => I_CLK,
|
||||
I_CE => I_CE,
|
||||
I_RST => I_RST,
|
||||
I_CountEnable => I_CountEnable,
|
||||
O_Value => O_Value,
|
||||
O_LAValue => O_LookAheadValue
|
||||
);
|
||||
|
||||
I_CLK <= not I_CLK after clk_period/2;
|
||||
|
||||
end;
|
Reference in New Issue
Block a user