Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Definition Multiply and Division in VHDL

Status
Not open for further replies.

Adnan86

Full Member level 2
Joined
Apr 4, 2013
Messages
121
Helped
26
Reputation
52
Reaction score
26
Trophy points
1,308
Activity points
2,153
Hi ,
I want execute this line in vhdl and i have no error but after compile it with Orcad and define the signal .. after RUN i have this error : Run time error accure at time 0 ns :
a , b, is real array matrix ,
c,d just real

a(0,0) <= b(0,0) * (c/d)
and if you have any idea for improve it , plz tell tanks

plz help :?:
 

Yes.
1. Dont use real type - its not supported for synthesis
2. Dont use OrCad for VHDL.
 

Yes.
1. Dont use real type - its not supported for synthesis
2. Dont use OrCad for VHDL.

IF i don't use real type so use what ?
I used integer but answer not float so i can't use it and if i use std_logic i have error for doing "/" and " * " .
instead ORCAD i use Modelsim but i have problem too ..

- - - Updated - - -

Yes.
1. Dont use real type - its not supported for synthesis
2. Dont use OrCad for VHDL.

IF i don't use real type so use what ?
I used integer but answer not float so i can't use it and if i use std_logic i have error for doing "/" and " * " .
instead ORCAD i use Modelsim too but i have problem ..
 
for floating point you need to use the floating point cores provided by whatever vendor you're using. but the main question there is - do you really need float? fixed point is probably waht you need (because thats basically an integer). FPGAs are not very good for floating point but perfect for fixed point.
 
THANKS for answer
I know , but I want to do this just as a project not for FPGA .
What do you recommend for this ... this line : a(0,0) <= b(0,0) * (c/d) that i said befor ,it's part of program : Matrix inversion . and now my question is : What's your recommend to do this . inevers (A) = 1 / determinant * (Adjoint (A)) ;
Any way I appreciate for your help .
 
Last edited:
well, if you dont care about synthesising it, then your code should work fine in modelsim.
 
I'll try it again in modelsim and we'll see...
any way Thanks again ...
 

still have problem in output answer ;
Any one here to recommend for VHDL code for matrix inversion use REAL type .
or give help for algorithm of multiplier and diversion for REAL type .
 
real can be multiplied and divided with the * and / operators.
what problems are you having?
 
for 1/x x it's real or integer answer always is zero .. and for (-y)/x answer always it's zero .. i'm confused ... for real type don't work
here my CODE
LIBRARY IEEE ;
USE IEEE.std_logic_1164.all ;
USE IEEE.numeric_std.all ;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
--use IEEE.MATH_REAL.ALL;
USE work.matrix_2by2.all ;


ENTITY matrix_inversion IS
PORT ( mat_in : IN matrix_2x2 ;
mat_invers : OUT matrix_2x2 );
END ;

ARCHITECTURE behav OF matrix_inversion IS



SIGNAL mat_det : integer ;
SIGNAL mat_adj : matrix_2x2 ;

BEGIN

-- PROCESS (mat_det)
-- BEGIN
-- IF mat_det /= 0.0 THEN
( mat_invers (0,0)) <= (mat_adj(0,0))/(mat_det) ;
( mat_invers (0,1)) <= ((mat_adj(0,1))/(mat_det)) ;
( mat_invers (1,0)) <= ((mat_adj(1,0))/(mat_det)) ;
( mat_invers (1,1)) <= (mat_adj(1,1))/(mat_det) ;
-- ELSE
-- mat_invers <= mat_in ;
-- END IF ;
-- END PROCESS ;
END ;

- - - Updated - - -

here determinant code

LIBRARY IEEE ;
USE IEEE.std_logic_1164.all ;
USE IEEE.numeric_std.all ;
-- use IEEE.MATH_REAL.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;



USE work.matrix_2by2.all ;


ENTITY determinant IS
PORT ( mat_in : IN matrix_2x2 ;
mat_det : OUT integer );

END determinant;

ARCHITECTURE behav OF determinant IS
BEGIN
mat_det <= ( mat_in(0,0) * mat_in(1,1) ) - ( mat_in(0,1) * mat_in(1,0) ) ;
END behav;
 
Last edited:
1 is an integer. 1/real will give an integer result, which means answer will always be zero. You need to do 1.0/x for a real result (x must be an integer)

I see all of your matrix are integers. YOu need to cast these to real before you can get a real result. But in your code your output is an integer, so you will always get an integer value. Integer values always floor the result.
 
I tried it with real 1.0 / x x: integer
mat_invers (0,0) <= (mat_adj(0,0))* (1.0 /mat_det) ; mat_det : integer
but give me this error : No feasible entres for infix operator "/" if use real ( x ) ihaven't erro but
my output answer it's wrong ang give me this 4.656661e+298
 
Last edited:
you need to cast the integer to a real. / is not defined for real/integer:

1.0 / real(x)
 
I tried it with real 1.0 / x x: integer
mat_invers (0,0) <= (mat_adj(0,0))* (1.0 /mat_det) ; mat_det : integer
but give me this error : No feasible entres for infix operator "/" if use real ( x ) ihaven't erro but
my output answer it's wrong ang give me this 4.656661e+298

- - - Updated - - -

if use real ( x ) ihaven't erro but
my output answer for all matrix it's wrong and give me this 4.656661e+298
 
but give me this error : No feasible entres for infix operator "/" if use real ( x ) ihaven't erro but
my output answer it's wrong ang give me this 4.656661e+298
1. Other than e.g. C language, VHDL doesn't provide automatic type conversion, arithmetic operator can be only applied to the data types they are defined for.
2. The most plausible reason for getting 4.656661e+298 result is zero value of x. In the post #10 code, mat_det is never assigned a value.
 
thanks you Fvm and TrickyDicky , my problem almost solved .... I really appreciate for your attention .
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top