Hi
I tried matrix inverse code...First i wrote package for finding determinant...then i wrote package for adjoint matrix. In vhdl module i have use both packages....Whether this approach is correct or not..? please help me..
libraryIEEE;useIEEE.STD_LOGIC_1164.all;useieee.numeric_std.all;package mat istype t11 isarray(0to2)ofunsigned(3downto0);type t1 isarray(0to2)of t11;--3*3 matrixtypeintegerisrange0to256;function dd (a:t1)returninteger;end mat ;packagebody mat isfunction dd (a:t1)returnintegerisvariable i:integer:=0;variable det :integerrange0to256:=0;beginfor i in0to2loop
det := det +( a(0)(i)*((a (1)((i+1)%3)*(a (2)((i+2)%3)))-(a (1)((i+2)%3)*(a (2)((i+1)%3))));endloop;return det;end dd;end mat;
libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;use.work.mat.alluse.work.inve.alluseIEEE.NUMERIC_STD.ALL;type t44 isarray(0to2)ofunsigned(3downto0);type t4 isarray(0to2)of t44 ;entity ddd isport(clk:instd_logic;
a:in t1;
a1:in t2;
det:outstd_logic;
ainverse:out t3;
final:out t4);end ddd;architecture Behavioral of ddd isbeginprocess(clk)beginif(clk'eventand clk='1')then
det<=dd(a);--function is called here.
ainverse<=adjoint(a1);endif;endprocess;end Behavioral;
error in package determinant
ERROR:HDLCompiler:806 - "C:\.Xilinx\god\matt.vhd" Line 37: Syntax error near ""3) * (a (2)((i+2)"".
ERROR:HDLCompiler:854 - "C:\.Xilinx\god\matt.vhd" Line 31: Unit <mat> ignored due to previous errors.
Besides that the error you are showing doesn't match any line numbers in your code. Next time post the exact error like you did, but also make sure they match the line numbers of the posted code or make sure you point out which error is on what line in the posted code.
Also Tricky is right this is the wrong way to do this. Think about the amount of logic that is generated in the functions, with for loops that are unrolled into parallel circuits. Don't expect VHDL to be software just because you use a text editor to enter the code. VHDL is a hardware description language, it describes a hardware circuit not a software program.
Thank you for ur response...I'll go through that operators....how to approch a matrix inversion in vhdl...? Is there any other method to do matrix inverse
You need to find a good textbook about digital logic. You code as a software programmer. You need to learn how digital logic works.. The best way would be to draw the circuit before you try and write any more vhdl code
You design this as a FSM that addresses a memory (the matrix) and uses pipelined math operations. Writing the results into another memory (inverted matrix). This is all hardware circuits that aren't abstracted like a software matrix inversion program would be.