Hello again Andreas, It seems I have been a bit too pessimistic on first time, there *is* a "mod" operator defined in IEEE1076.2-1996 (VHDL Mathematical Packages).
However, the package provided with GHDL lacks it, so a good start would be to enter a request/bug fix there: https://gna.org/support/?func=additem&group=ghdl The official declaration is (taken from IEEE Std): function "MOD"(X, Y: in REAL ) return REAL; -- Purpose: -- Returns floating point modulus of X/Y, with the same sign as -- Y, and absolute value less than the absolute value of Y, and -- for some INTEGER value N the result satisfies the relation -- X = Y*N + MOD(X,Y) -- Special values: -- None -- Domain: -- X in REAL; Y in REAL and Y /= 0.0 -- Error conditions: -- Error if Y = 0.0 -- Range: -- ABS(MOD(X,Y)) < ABS(Y) -- Notes: -- None As a workaround, I propose you to compile the attached file inside the ieee_proposed library which will provide the stuff, and add the line: use IEEE_PROPOSED.math_real_fmod.all; in the 'fixed_pkg_c.vhdl'. Hope this will help you, Regards, Chris. On Monday 27 August 2007 17:19, Chris wrote: > Hello Andreas, > > I had a quick look on my side, and the lines are doing this: > > [real] <= [real] mod [real] > > but the "mod" operator does not exist for reals. I will try to check > tomorrow in the IEEE reference, but I don't think there is such operator to > be defined in "math_real" package. > > If this code has ever been compiled somewhere, I suppose that the tool used > made an implicit conversion (to integer, which I doubt, or...?) > > Regards, > Chris. > > On Sunday 26 August 2007 17:37, Andreas Schwarz wrote: > > Hi, > > > > I can't compile fixed_pkg (VHDL-93 compatible version from > > http://www.vhdl.org/vhdl-200x/vhdl-200x-ft/packages/fixed_pkg_c.vhdl) > > with GHDL: > > > > $ ghdl -a --work=ieee_proposed math_utility_pkg.vhdl > > $ ghdl -a --work=ieee_proposed fixed_pkg_c.vhdl > > fixed_pkg_c.vhdl:4493:28: no function declarations for operator "mod" > > fixed_pkg_c.vhdl:4548:29: no function declarations for operator "mod" > > /usr/lib/ghdl/bin/ghdl: compilation error > > $ ghdl -v > > GHDL 0.25 (20060811) [Sokcho edition] > > > > > > Any ideas how to fix this? > > > > Thanks > > Andreas > > > > > > _______________________________________________ > > Ghdl-discuss mailing list > > Ghdl-discuss@gna.org > > https://mail.gna.org/listinfo/ghdl-discuss > > _______________________________________________ > Ghdl-discuss mailing list > Ghdl-discuss@gna.org > https://mail.gna.org/listinfo/ghdl-discuss --- ------------------------------------------------------------------------------- -- MATH_REAL / MOD function - (c)2007 Christophe CURIS -- Provided as-is as a workaround for GHDL's missing MOD operator on reals -- Code is GPL. ------------------------------------------------------------------------------- package math_real_fmod is function "MOD"(X, Y: in REAL ) return REAL; end math_real_fmod; package body math_real_fmod is function SYS_fmod(X: REAL; Y: REAL) return REAL; attribute foreign of SYS_fmod : function is "VHPIDIRECT fmod"; function "MOD"(X, Y: in REAL ) return real is begin if (Y = 0.0) then report Y'instance_name & " Y=0.0 not allowed for MOD operator" severity ERROR; return 0.0; else return SYS_fmod(X, Y); end if; end; function SYS_fmod (X: REAL; Y: REAL) return REAL is begin report "ERROR: Call to 'fmod' instead of FOREIGN body" severity FAILURE; end SYS_fmod; end math_real_fmod; _______________________________________________ Ghdl-discuss mailing list Ghdl-discuss@gna.org https://mail.gna.org/listinfo/ghdl-discuss