Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable not saturating

Status
Not open for further replies.

neilmallia

Technical User
Mar 30, 2010
3
MT
Hi,

I am trying to implement an integrator but when it is reaching the maximum it is not saturating but resetting and starting again from 0.

Here is the part of the code which is relevant:

INTEGRATION := INTEGRATOR + T_DIFF + (T_DIFF & "000000000") - (T_DIFFPRE & "000000000");

IF INTEGRATION >= "0000000011111111111111111111111111" then

INTEGRATOR := "11111111111111111111111";

ELSE

INTEGRATOR := INTEGRATION(22 DOWNTO 0);

END IF;



T_DIFF is an 8bit constant
T_DIFF_PRE is an 8bit constant
INTEGRATION is a 31 bit variable
INTEGRATOR is a 23 bit variable

I don't know what I'm doing wrong but I think when INTEGRATION reaches "0000000011111111111111111111111111" INTEGRATOR should be kept at "11111111111111111111111" and it will stay like this.

Any ideas on whats happening?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top