Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20688 Discussions

floating point operating in vhdl (fixed_pkg)

Altera_Forum
Honored Contributor II
3,280 Views

Hi all; 

 

I have write a code using fixed_pkg. It compile successfully in quartus, but when I try to simulate in ModelSim an error occur. 

--------------------------------------------------------------------------------------------------------------- 

library ieee; 

library ieee_proposed; 

use work.fixed_pkg.all; 

use ieee.numeric_std.all; 

 

entity fix is 

port (clk: in bit; 

nprev: in integer range -127 to 127; 

ip1: out ufixed (8 downto -9)); 

end fix; 

 

architecture fix of fix is 

signal n1: ufixed (4 downto -4); 

begin 

process(clk) 

begin 

if (clk'event and clk='1') then 

ip1 <= (to_ufixed(0.483,n1)) * (to_ufixed(11,n1)); 

end if; 

end process; 

end fix; 

---------------------------------------------------------------------------------------------- 

This is the error in ModelSim:# Compile of fix.vhd failed with 2 errors.# Compile of fix_tb.vhd failed with 2 errors.# Compile of fixed_float_types_c.vhdl was successful.# Compile of fixed_pkg_c.vhdl failed with 1 errors.# Compile of fixed_synth.vhdl failed with 2 errors. 

This the error when I expand it: 

** Error: H:/altera/mul_try_tb/fix_tb.vhd(2): Library ieee_proposed not found. 

 

I have add all the fixed_pkg in the project (in quartus). Need your helps.. 

0 Kudos
17 Replies
Altera_Forum
Honored Contributor II
1,475 Views

what version of modelsim? 

 

newer versions of modelsim have the fixed_pkg in the floatfixlib library, so I would delete all references to ieee_proposed and the fixed_pkg in the work library.
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

I use ModelSim Altera Starter Edition 6.6d..After I remove the ieee_proposed library, this error occur in ModelSim: 

 

** Error: H:/altera/mul_try_tb/fix.vhd(3): Library floatfixlib not found. 

** Error: H:/altera/mul_try_tb/fix.vhd(4): (vcom-1136) Unknown identifier "floatfixlib". 

 

Thanks for reply
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

you will need to create the floatfixlib, as I dont think the starter edition ships with it.

0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

How to create the floatfixlib? Do you have any other idea for avoid the error.. 

thanks for reply
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

on the modelsim command window (or in a tcl or do file): 

 

vlib floatfixlib 

vcom fixed_float_types_c.vhdl -work floatfixlib 

vcom fixed_pkg_c.vhdl -work floatfixlib 

 

etc.
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

I write in the modelsim command window for create the ieee_proposed; 

 

vlib ieee_propose 

vcom vcom fixed_float_types_c.vhdl 

vcom fixed_pkg_c.vhdl 

 

There are no error for line 1 and 2. But, in line 3 this error occur:# ** Error: (vcom-11) Could not find ieee_proposed.fixed_float_types.# ** Error: fixed_pkg_c.vhdl(23): (vcom-1195) Cannot find expanded name "ieee_proposed.fixed_float_types".# ** Error: fixed_pkg_c.vhdl(23): Unknown expanded name.# ** Error: fixed_pkg_c.vhdl(25): VHDL Compiler exiting# C:/altera/10.1/modelsim_ase/win32aloem/vcom failed. 

 

What my false?..thanks for reply
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

if you just run vcom it will add it to the work libarary. To add a file to the specific library, you need the -work option 

 

vcom fixed_float_types_c.vhdl -work ieee_proposed 

vcom fixed_pkg_c.vhdl -work ieee_proposed
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

Okay, I understand now..Many thanks Tricky

0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

This thread is the closest I've found to addressing my issue, so I hope you don't mind me reviving it. I am using fixed_pkg in my VHDL design to do fixed point arithmetic. I compiled it into my Quartus work library so didn't create the ieee_proposed library: 

 

library IEEE; 

use IEEE.std_logic_1164.all; 

use IEEE.numeric_std.all; 

use work.fixed_pkg.all; 

 

My design compiles and synthesizes successfully in Quartus 16.1.1 Standard, but not in ModelSim 10.5a: 

 

Error: (vcom-11) Could not find work.fixed_pkg. 

 

Now I've read that I can change the location of fixed_pkg from "work" to "ieee" since ModelSim supports it. However, the compilation of my project is heavily scripted, so I need to use the same source files for both the Quartus and ModelSim synthesis. How can I do this?
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

if you put it in work - then you will have to compile it into work youself and you wont get the nice accelerated version modelsim uses, and it wont be the 2008 version (which is where fixed_point was introduced). The version you have for quartus is a 1993 compatible version written by David Bishop (the author of the 2008 version) - but it is not an official VHDL standard. 

 

Why not just do it properly and compile it into ieee in quartus (you can assign a library to it) and then in quartus you can just use the version that is already included in Modelsim, as it has supported the fixed_point package for a long time (from 6.6 onwards, and probably a bit before). And since about version 10.0 it has supported 2008.
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

Tricky, thank you for your reply. I've appreciated your answers over the years, but rarely post myself. 

 

The reason I'm using David Bishop's 1993 version of fixed_pkg is because Quartus 16.1 Standard doesn't support the 2008 version. Altera Support told me that Quartus 16.1 Prime doesn't either. 

 

Are you suggesting that I copy the library files from my ModelSim installation (ie. the 2008 version) into my Quartus project and compile it into the IEEE library in Quartus? So I would have these lines? 

 

library ieee; 

use ieee.fixed_float_types.all; 

use ieee.fixed_pkg.all; 

 

Does Quartus Synthesis support the 2008 version? Was/is it just missing the 2008 library files? I tried compiling the 1993 version into the ieee_proposed library in my Quartus project, and it works, but my ModelSim project reports errors with fixed_pkg_c.vhdl.
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

You can: 

A) Try to rename ieee_proposed to ieee in files like fixed_pkg_c.vhd 

OR 

B) Custom script to compile testbench that exclude fixed_pkg_c, fixed_float_types_c, etc.. files.
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

 

--- Quote Start ---  

Tricky, thank you for your reply. I've appreciated your answers over the years, but rarely post myself. 

 

The reason I'm using David Bishop's 1993 version of fixed_pkg is because Quartus 16.1 Standard doesn't support the 2008 version. Altera Support told me that Quartus 16.1 Prime doesn't either. 

 

Are you suggesting that I copy the library files from my ModelSim installation (ie. the 2008 version) into my Quartus project and compile it into the IEEE library in Quartus? So I would have these lines? 

 

library ieee; 

use ieee.fixed_float_types.all; 

use ieee.fixed_pkg.all; 

 

Does Quartus Synthesis support the 2008 version? Was/is it just missing the 2008 library files? I tried compiling the 1993 version into the ieee_proposed library in my Quartus project, and it works, but my ModelSim project reports errors with fixed_pkg_c.vhdl. 

--- Quote End ---  

 

 

In quartus, just compile the fixed_package version you have into the ieee library, in the source tab you can select what library to compile any source into. 

You cannot use the version from modelsim, as it will not compile in quartus.
0 Kudos
Altera_Forum
Honored Contributor II
1,474 Views

I did as Tricky suggested and both my Quartus and ModelSim projects compile! I had to rename "ieee_proposed" to "ieee" as suggested by flz47655. 

 

Just so I understand why this works, correct me if I'm wrong: 

- Quartus compiles the 1993 (compatible) fixed_pkg into its ieee library 

- ModelSim also compiles the 1993 (compatible) fixed_pkg into its ieee library, ignoring its 2008 version since I used the _c.vhdl files for the fixed_pkg 

- this would not have worked if the source files "fixed_float_types" and "fixed_pkg" were named the same in both projects since ModelSim has its own version of the files
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

There is no reason you cannot use the 2008 version in modelsim, and 2008 version in Quartus. It doesnt matter that the file names are different, the package names are the same.

0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

I thought Quartus doesn't support the 2008 version. Here's what Altera Support said: 

--- 

i checked in the database, the fixed_pkg is yet to be supported in qpro version or in qstandard version. and i had try one of the design using 

 

use ieee.fixed_pkg.all;  

 

but it does not work in qpro or qstandard. i do not have the detail when it will get support. however, i will go ahead and request the enhancement for this support. 

--- 

I had to use the 1993-compatible version in my Quartus project by compiling it into the ieee library. But I'm not sure what version of fixed_pkg my ModelSim project is using.
0 Kudos
Altera_Forum
Honored Contributor II
1,475 Views

Yes, use the 1993 version in Quartus, and the one that comes with modelsim by default (the 2008 version) 

They should both work fine,.
0 Kudos
Reply