matrix - Warnings inmatrix multiplication in vhdl -


so, started writing code simple 4x4 matrix multiplication. code crude @ point, try change end, wanted see if works. uses direct assignment 2-bit elements of matrices 8-bit inputs. similarly, 4 outputs created concatenating 4 elements of each row of resulting matrix. below can see code.

the problem have after run code, 100 warnings of type "there 'u'|'x'|'w'|'z'|'-' in arithmetic operand, result 'x'(es)." doing wrong? there problem initialization of variables a, b, temp, or else?

library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;  entity matrix_mul     port(      a1: in std_logic_vector(7 downto 0);     a2: in std_logic_vector(7 downto 0);     a3: in std_logic_vector(7 downto 0);     a4: in std_logic_vector(7 downto 0);     b1: in std_logic_vector(7 downto 0);     b2: in std_logic_vector(7 downto 0);     b3: in std_logic_vector(7 downto 0);     b4: in std_logic_vector(7 downto 0);     x1: out std_logic_vector(15 downto 0);     x2: out std_logic_vector(15 downto 0);     x3: out std_logic_vector(15 downto 0);     x4: out std_logic_vector(15 downto 0)     ); end matrix_mul;  architecture arch of matrix_mul  type array_2b_1x4 array (3 downto 0) of std_logic_vector(1 downto 0); type matrix_2b_4x4 array (3 downto 0) of array_2b_1x4; type array_4b_1x4 array (3 downto 0) of std_logic_vector(3 downto 0); type matrix_4b_4x4 array (3 downto 0) of array_4b_1x4;   begin     process (a1,a2,a3,a4,b1,b2,b3,b4)     variable : matrix_2b_4x4 := (others => (others => (others => '0')));     variable b : matrix_2b_4x4 := (others => (others => (others => '0')));     variable temp : matrix_4b_4x4 := (others => (others => (others => '0')));      begin         a(0)(0) := a1(7 downto 6);         a(0)(1) := a1(5 downto 4);         a(0)(2) := a1(3 downto 2);         a(0)(3) := a1(1 downto 0);         a(1)(0) := a2(7 downto 6);         a(1)(1) := a2(5 downto 4);         a(1)(2) := a2(3 downto 2);         a(1)(3) := a2(1 downto 0);         a(2)(0) := a3(7 downto 6);         a(2)(1) := a3(5 downto 4);         a(2)(2) := a3(3 downto 2);         a(2)(3) := a3(1 downto 0);         a(3)(0) := a4(7 downto 6);         a(3)(1) := a4(5 downto 4);         a(3)(2) := a4(3 downto 2);         a(3)(3) := a4(1 downto 0);         b(0)(0) := b1(7 downto 6);         b(0)(1) := b1(5 downto 4);         b(0)(2) := b1(3 downto 2);         b(0)(3) := b1(1 downto 0);         b(1)(0) := b2(7 downto 6);         b(1)(1) := b2(5 downto 4);         b(1)(2) := b2(3 downto 2);         b(1)(3) := b2(1 downto 0);         b(2)(0) := b3(7 downto 6);         b(2)(1) := b3(5 downto 4);         b(2)(2) := b3(3 downto 2);         b(2)(3) := b3(1 downto 0);         b(3)(0) := b4(7 downto 6);         b(3)(1) := b4(5 downto 4);         b(3)(2) := b4(3 downto 2);         b(3)(3) := b4(1 downto 0);           in 0 3 loop             j in 0 3 loop                 k in 0 3 loop                     temp(i)(j) := temp(i)(j) + ( a(i)(k) * b(k)(j) );                 end loop;             end loop;         end loop;          x1 <= temp(0)(0) & temp(0)(1) & temp(0)(2) & temp(0)(3);         x2 <= temp(1)(0) & temp(1)(1) & temp(1)(2) & temp(1)(3);         x3 <= temp(2)(0) & temp(2)(1) & temp(2)(2) & temp(2)(3);         x4 <= temp(3)(0) & temp(3)(1) & temp(3)(2) & temp(3)(3);      end process; end arch; 

the problem these initialization @ variable declarations within process

variable : matrix_2b_4x4 := (others => (others => (others => '0'))); variable b : matrix_2b_4x4 := (others => (others => (others => '0'))); variable temp : matrix_4b_4x4 := (others => (others => (others => '0'))); 

take place only once when process ia executed first time.

you haven't posted testbench, suspect a , b not initialized @ declarations there. thus, 'u' when process executed first time. thus, temp assigned / 'x'es. after assigned valid values a , b within testbench, process executed again, temp still assigned value last run @ beginning , contains 'x'es , keep them in addition.

this, not want in matrix multiplication. have described combinational process, that, have initialize variables in process every run. way, not depend on previous run, that, accumulation starts every temp = zero. have proper assignment of a , b in process, temp missing. init before for loops:

... temp := (others => (others => (others => '0'))); in 0 3 loop ... 

after making change, can remove variable initialization @ variable declaration.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -