Arithmetic operations in vhdl

Status
Not open for further replies.

mohit1108

Newbie level 2
Joined
Mar 31, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
I have made a program for PI controller and the excerpts are as follows-
v1<= v_prev + (k1*iq_error)+(k2*f_prev1)+(k3*f_prev2);
All the variables are std logic vector ( 7 downto 0)
but there is an error in execution of this code-

* can not have such operands in this context.

I have also included IEEE.NUMERIC_STD.ALL; but still error persists.

please help me out
 

try casting the std_logic_vectors to unsigned/signed, or better yet, just use unsigned/signed in the first place.

v1<= v_prev + (unsigned(k1)*unsigned(iq_error))+(unsigned(k2)*unsigned(f_prev1))+(unsigned(k3)*unsigned(f_prev2));

what would you do for a slv if you had a 'X' * 'H'?

https://www.synthworks.com/papers/vhdl_math_tricks_mapld_2003.pdf
 
Last edited:

what would you do for a slv if you had a 'X' * 'H'?

remember that signed/unsigned are arrays of std_logic too, so you could have 'x' * 'h'. you should just get 'x' as the result.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…