fanwel
Full Member level 3

Dear all,
I try to write a testbench code for my transpose.vhd file, where i want to have a matrix transpose. Below is my main code and testbench code:
1) Main code:
---------package---------
package my_data_types is
--type column is array (-127 downto 127) of integer;
--type row is array (-127 downto 127) of integer;
type matrix is array (natural range<>, natural range<>) of integer;
end package my_data_types;
----------main code-------
use work.my_data_types.all;
entity transpose is
generic (m: integer :=3;
n: integer :=3);
port (x: in matrix (0 to M-1, N-1 downto 0);
y: out matrix (0 to M-1, N-1 downto 0);
clk: in bit);
end transpose;
architecture transpose of transpose is
begin
process(clk)
begin
if (clk'event and clk='1') then
for i in 0 to m-1 loop
for j in 0 to m-1 loop
y(i,j) <= x(j,i);
end loop;
end loop;
end if;
end process;
end transpose;
2)Testbench code:
library IEEE;
use IEEE.Std_logic_1164.all;
use IEEE.Numeric_Std.all;
entity transpose_tb is
end;
architecture bench of transpose_tb is
component transpose
generic (m: integer :=3;
n: integer :=3);
port (x: in matrix (0 to M-1, N-1 downto 0);
y: out matrix (0 to M-1, N-1 downto 0);
clk: in bit);
end component;
signal x: matrix (0 to M-1, N-1 downto 0);
signal y: matrix (0 to M-1, N-1 downto 0);
signal clk: bit;
constant clock_period: time := 10 ns;
signal stop_the_clock: boolean;
begin
uut: transpose generic map ( m => 3,
n => 3 )
port map ( x => x,
y => y,
clk => clk );
stimulus: process
begin
x <= (12,23,30,18),(2,3,1,5);
wait for 150ns;
stop_the_clock <= true;
wait;
end process;
clocking: process
begin
while not stop_the_clock loop
clk <= '1', '0' after clock_period / 2;
wait for clock_period;
end loop;
wait;
end process;
end;
There is no error when I compile the main code, but an error occured when I compile the testbench code;
Error (10486): VHDL error at transpose_tb.vhd(13): slice of object cannot be specified for object that has an array type of more than one dimension.
I try to debug this error many times but this error still occured. I need helps from you all to tell me where Iam wrong..Many thanks.
I try to write a testbench code for my transpose.vhd file, where i want to have a matrix transpose. Below is my main code and testbench code:
1) Main code:
---------package---------
package my_data_types is
--type column is array (-127 downto 127) of integer;
--type row is array (-127 downto 127) of integer;
type matrix is array (natural range<>, natural range<>) of integer;
end package my_data_types;
----------main code-------
use work.my_data_types.all;
entity transpose is
generic (m: integer :=3;
n: integer :=3);
port (x: in matrix (0 to M-1, N-1 downto 0);
y: out matrix (0 to M-1, N-1 downto 0);
clk: in bit);
end transpose;
architecture transpose of transpose is
begin
process(clk)
begin
if (clk'event and clk='1') then
for i in 0 to m-1 loop
for j in 0 to m-1 loop
y(i,j) <= x(j,i);
end loop;
end loop;
end if;
end process;
end transpose;
2)Testbench code:
library IEEE;
use IEEE.Std_logic_1164.all;
use IEEE.Numeric_Std.all;
entity transpose_tb is
end;
architecture bench of transpose_tb is
component transpose
generic (m: integer :=3;
n: integer :=3);
port (x: in matrix (0 to M-1, N-1 downto 0);
y: out matrix (0 to M-1, N-1 downto 0);
clk: in bit);
end component;
signal x: matrix (0 to M-1, N-1 downto 0);
signal y: matrix (0 to M-1, N-1 downto 0);
signal clk: bit;
constant clock_period: time := 10 ns;
signal stop_the_clock: boolean;
begin
uut: transpose generic map ( m => 3,
n => 3 )
port map ( x => x,
y => y,
clk => clk );
stimulus: process
begin
x <= (12,23,30,18),(2,3,1,5);
wait for 150ns;
stop_the_clock <= true;
wait;
end process;
clocking: process
begin
while not stop_the_clock loop
clk <= '1', '0' after clock_period / 2;
wait for clock_period;
end loop;
wait;
end process;
end;
There is no error when I compile the main code, but an error occured when I compile the testbench code;
Error (10486): VHDL error at transpose_tb.vhd(13): slice of object cannot be specified for object that has an array type of more than one dimension.
I try to debug this error many times but this error still occured. I need helps from you all to tell me where Iam wrong..Many thanks.