Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

VHDL Fixed point package with Quartus

Hello!

I am trying to use the VHDL Fixed-point package fixed_pkg with Quartus II (11.0 sp1).

http://www.vhdl.org/fphld/vhdl.html

The package works fine except when trying to define a two dimensional array. When the 2-D array is defined in a top-level entity everything goes well, but when I move the array to a package, Quartus crashes.

I created a package dedicated to the different types I need to work with, and there I defined


subtype GVal is sfixed (1 downto -7);    --sfixed is a fixed-point type defined in the VHDL fixed-point package.
type GMat is array (0 to 1, 0 to 1) of GMat;

In another package I declared the variables, signals, constants, functions etc...


constant GMTest: GMat:= ((to_sfixed(-1.5,2,-3),to_sfixed(-1.4,2,-3))  ,  (to_sfixed(-0.2,2,-3),to_sfixed(-0.5,2,-3)));

When I try to use the values of GMTest in a top-level entity I get the following error:

--- Quote Start ---

*** Fatal Error: Access Violation at 0X092E1C16

Module: quartus_map.exe

Lock in use: 9

Stack Trace:

0x91c15: Netlist::ProcessGlobals + 0x365 (synth_vrfx)

0x945e4: Netlist::Polish + 0xb4 (synth_vrfx)

0x15d99f: VhdlEntityDecl::CoreElaborate + 0x4af (synth_vrfx)

0x15dfee: VhdlEntityDecl::Elaborate + 0x37e (synth_vrfx)

0x5169e: VRFX_VERIFIC_VHDL_ELABORATOR::elaborate + 0x1be (synth_vrfx)

0x4c3c6: VRFX_ELABORATOR::elaborate + 0xc6 (synth_vrfx)

0x9cc41: SGN_FN_LIB::elaborate + 0x131 (synth_sgn)

0x9f3ca: SGN_FN_LIB::start_vrf_flow + 0xa (synth_sgn)

0xa06f7: SGN_FN_LIB::start + 0x597 (synth_sgn)

0x7dd99: SGN_EXTRACTOR::single_module_extraction + 0x149 (synth_sgn)

0x8266e: SGN_EXTRACTOR::recursive_extraction + 0x15e (synth_sgn)

0x85d6a: SGN_EXTRACTOR::extract + 0x16a (synth_sgn)

0xbc3e: sgn_elaboration + 0xee (synth_sgn)

0x3a7f: qsyn_execute_sgn + 0x19f (quartus_map)

0x19f2b: QSYN_FRAMEWORK::execute_core + 0x8b (quartus_map)

0x1c930: QSYN_FRAMEWORK::execute + 0xa0 (quartus_map)

0xf211: QEXE_ARGS::get_command_line + 0x1461 (comp_qexe)

0x116b7: qexe_process_cmdline_arguments + 0x387 (comp_qexe)

0x117a4: qexe_standard_main + 0x84 (comp_qexe)

0x17ede: qsyn_main + 0x5e (quartus_map)

0x1b81: msg_main_thread + 0x11 (CCL_MSG)

0x1be8: _thr_final_wrapper + 0x8 (ccl_thr)

0x1af5: msg_thread_wrapper + 0x85 (CCL_MSG)

0x458a: mem_thread_wrapper + 0x4a (ccl_mem)

0x28a03: msg_exe_main + 0x63 (CCL_MSG)

0x1938c: _main + 0x1c (quartus_map)

0x24ad4: __ftol2 + 0x1ce (quartus_map)

0x4ee1b: BaseThreadInitThunk + 0x11 (kernel32)

0x637ea: RtlInitializeExceptionChain + 0xee (ntdll)

0x637bd: RtlInitializeExceptionChain + 0xc1 (ntdll)

End-trace

Quartus II Version 11.0 Build 208 07/03/2011 SJ Full Version

Service Pack Installed: 1

--- Quote End ---

Any ideas would be appreciated.

Thanks in advance

6 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    First of all, I think you made an error:

    type GMat is array (0 to 1, 0 to 1) of GMat;

    shouldnt it be

    type GMat is array (0 to 1, 0 to 1) of GVal;

    I have done exactly what you did (2d array of sfixed in a package), without crashes, back in Q9.1 and 10.0 I think, maybe even 11.0. Have you tried a newer version?

    Can you post the code to see if we can see anything untoward?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hello Tricky and thank you very much for your reply.

    --- Quote Start ---

    First of all, I think you made an error:

    type GMat is array (0 to 1, 0 to 1) of GMat;

    shouldnt it be

    type GMat is array (0 to 1, 0 to 1) of GVal;

    --- Quote End ---

    It is a typewriting mistake, sorry about that. Thanks for the correction.

    --- Quote Start ---

    Have you tried a newer version?

    --- Quote End ---

    I only have this version right now.

    For the code, I made this separate example and got the same error:

    First, there is the types-package "IMG_Types.vhd".

    
    library RealNum; -- Defined as a global library in the project settings, it refers to the location of the fixed_pkg
    use RealNum.fixed_float_types.all;
    use RealNum.fixed_pkg.all;
    package IMG_Types is
    subtype GVal is sfixed (1 downto -4);    --sfixed is a fixed-point type defined in the VHDL fixed-point package.
    type GMat is array (0 to 1, 0 to 1) of GVal;
    end package;
    

    Second, there is the routines, constants, .. package "G_pkg.vhd"

    
    library ieee;
    use ieee.std_logic_1164.all;
    library RealNum; -- Defined as global library in the project settings, it refers to the location of the fixed_pkg
    use RealNum.fixed_float_types.all;
    use RealNum.fixed_pkg.all;
    library PKG; -- defined as a global library to refere to the location of the IMg_Types (the same of this package. work will suffice of course)
    use PKg.IMG_Types.all;
    package G_pkg is
    constant GMTest: GMat:= ((to_sfixed(-1.5,2,-3),to_sfixed(-1.4,2,-3))  ,  (to_sfixed(-0.2,2,-3),to_sfixed(-0.5,2,-3)));
    end package G_pkg; 
    

    Finally there is the top-level entity

    
    library ieee;
    use ieee.std_logic_1164.all;
    library PKG;
    use PKG.IMG_Types.all;
    use PKG.G_PKG.all;
    entity FixedMat is
    port(clk, reset : in std_logic;
    	  fGab : out GVal
    	  );
    end FixedMat;
    Architecture Exmp1Arc of FixedMat is
    begin 
    fGab <= GMTest(0,0);
    end;
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Its possibly falling over because you have GVal as a top level port. Its recommended to use only std_logic_vector, signed or unsigned for top level ports. I bet it doesnt like the -ve indices for the top level ports.

    Make fGab an std_logic_vector, and see what happens:

    
    fGab : out std_logic_vector(5 downto 0);
    ...
    fGab <= to_slv(GMTest(0,0));
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks Tricky!

    I tried what you suggested, but unfortunately it didn't work either.

    ...

    The problem perhaps has something to do with the 2D-Matrix, because I first tried this:

    
    fGab : out GVal; -- defined as port
    ...
    fGab <= to_sfixed(-1.5,2,-3);
    

    and it worked.

    Then I tried the same with one dimensional array and it also worked.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Then I can only suggest a new tool version to see if the problem is fixed.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks Tricky!

    I tried the same with a higher version of Quartus II and got the same error.

    A colleague of mine suggested defining the 2D-Matrix based on 1-D array, and it actually worked.

    
    type GVec is array (0 to 1) of GVal;
    type GMat is array (0 to 1) of GVec;
    

    In the top-level entity:

    
    fGab <= GMTest(0)(0);