I have very simple 'program' written in VHDL
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std;
entity Xand is
generic(width : integer:=8);
port( clk : in std_logic;
A,B : in std_logic_vector(width-1 downto 0);
C : out std_logic_vector(width-1 downto 0)
);
end Xand;
architecture Behavioral of Xand is
begin
C<= A and B;
end Behavioral;
My actual test-bench looks like this:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use ieee.numeric_std.all;
ENTITY Xand_tb IS
--generic(width : integer);
END Xand_tb;
ARCHITECTURE behavior OF Xand_tb IS
COMPONENT Xand IS
generic(width : integer);
port( clk : in std_logic;
A,B : in std_logic_vector(width-1 downto 0);
C : out std_logic_vector(width-1 downto 0)
);
end COMPONENT;
signal width : integer := 8;
-- inputs
signal clk : std_logic := '0';
signal A, B : std_logic_vector(width-1 downto 0) := (others => '0');
--Outputs
signal C : std_logic_vector(width-1 downto 0);
constant period : time := 10 ns;
BEGIN
-- instantiate the Unit Under Test (UUT)
uut: Xand generic map (width => 8)
PORT MAP (
clk => clk,
A => A,
B => B,
C => C
);
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for period*10;
for i in 0 to 2**width loop
A <= std_logic_vector( unsigned(A) + 1 );
for j in 0 to 2**width loop
B <= std_logic_vector( unsigned(B) + 1 );
wait for period;
end loop;
for j in 0 to width loop
B(j) <= '0';
end loop;
wait for period;
end loop;
wait;
end process;
END;
Sadly I get error (when I want to simulate it with --vcd=xand.vcd).
ghdl:error: overflow detected
from: process work.xand_tb(behavior).stim_proc at Xand_tb.vhd:57
ghdl:error: simulation failed
It's B(j) <= '0';
line that don't work. From what I understand A and B are vectors that have 8 bits. So I want to test my Xand program with diffrent A and B values that are from [0,256). Sadly I have no idea how to make vector B equal 0 diffrent way than with the loop, which doesn't work.
Can someone explain my what generic() does?