Forum Discussion

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

Wrong logic synthesis when call function named <package_name>.<function_name>

I am in trouble in VHDL analyze & synthesis.

I use "Quartus Prime Verion 15.1.0 Build 185 10/21/2015 SJ Lite Edition".

It defines the no argument function in the package.

sample.vhd


library ieee;
use     ieee.std_logic_1164.all;
package Sample is
    subtype   Code_Type  is std_logic_vector(3 downto 0);
    function  New_Code_0 return Code_Type;
    function  New_Code_1 return Code_Type;
    function  New_Code_2 return Code_Type;
    function  New_Code_3 return Code_Type;
end Sample;
package body Sample is
    function  New_Code_0 return Code_Type is begin
        return std_logic_vector'("0001");
    end function;
    function  New_Code_1 return Code_Type is begin
        return std_logic_vector'("0010");
    end function;
    function  New_Code_2 return Code_Type is begin
        return std_logic_vector'("0100");
    end function;
    function  New_Code_3 return Code_Type is begin
        return std_logic_vector'("1000");
    end function;
end Sample;

I call no-argment function by <package_name>.<function_name>

sample_ng.vhd


library ieee;
use     ieee.std_logic_1164.all;
use     ieee.numeric_std.all;
use     work.Sample;
entity  Sample_NG is
    port (CLK: in  std_logic;
          CLR: in  std_logic;
          O  : out Sample.Code_Type
    );
end     Sample_NG;
architecture RTL of Sample_NG is
    signal count : integer range 0 to 3 := 0;
begin
    process(CLK) begin
        if (CLK'event and CLK = '1') then
            if (CLR = '1' or count >= 3) then
                count <= 0;
            else
                count <= count + 1;
            end if;
        end if;
    end process;
    O <= Sample.New_Code_3 when (count = 3) else
         Sample.New_Code_2 when (count = 2) else
         Sample.New_Code_1 when (count = 1) else
         Sample.New_Code_0;
end RTL;

Analyze & Synthesis


Info: *******************************************************************
Info: Running Quartus Prime Analysis & Synthesis
    Info: Version 15.1.0 Build 185 10/21/2015 SJ Lite Edition
    Info: Processing started: Tue Mar 15 00:50:13 2016
Info: Command: quartus_map --read_settings_files=on --write_settings_files=off 0020 -c sample_ng
Info (20030): Parallel compilation is enabled and will use 4 of the 4 processors detected
Info (12021): Found 2 design units, including 1 entities, in source file sample_ng.vhd
    Info (12022): Found design unit 1: Sample_NG-RTL
    Info (12023): Found entity 1: Sample_NG
Info (12021): Found 2 design units, including 0 entities, in source file sample.vhd
    Info (12022): Found design unit 1: Sample
    Info (12022): Found design unit 2: Sample-body
Info (12127): Elaborating entity "sample_ng" for the top level hierarchy
Warning (10873): Using initial value X (don't care) for net "O" at sample_ng.vhd(8)
Warning (13024): Output pins are stuck at VCC or GND
    Warning (13410): Pin "O" is stuck at GND
    Warning (13410): Pin "O" is stuck at GND
    Warning (13410): Pin "O" is stuck at GND
    Warning (13410): Pin "O" is stuck at GND
Info (16010): Generating hard_block partition "hard_block:auto_generated_inst"
    Info (16011): Adding 0 node(s), including 0 DDIO, 0 PLL, 0 transceiver and 0 LCELL
Warning (21074): Design contains 2 input pin(s) that do not drive logic
    Warning (15610): No output dependent on input pin "CLK"
    Warning (15610): No output dependent on input pin "CLR"
Info (21057): Implemented 6 device resources after synthesis - the final resource count might be different
    Info (21058): Implemented 2 input pins
    Info (21059): Implemented 4 output pins
Info: Quartus Prime Analysis & Synthesis was successful. 0 errors, 9 warnings
    Info: Peak virtual memory: 870 megabytes
    Info: Processing ended: Tue Mar 15 00:50:38 2016
    Info: Elapsed time: 00:00:25
    Info: Total CPU time (on all processors): 00:00:56

Why "warning(10873): Using initial value X (don't care) for net "O" at sample_ng.vhd(8)" ???

As a result , the output signals(O) are all connected to GND.

I think this is a bug in the logic synthesis , how about you do you think ?

8 Replies

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

    --- Quote Start ---

    ???? http://www.alteraforum.com/forum/showthread.php?t=51340

    ok. Did you pay attention on the word "all" in "use" clause?

    by the way, why multiple call to "use" and "library" if VHDL able only one "use" clause per entity.

    library ieee;

    use ieee.std_logic_1164.all, ieee.numeric_std.all, work.sample.all;

    --- Quote End ---

    This doesnt matter. VHDL allows you to invidually call functions from a package. So this is not the problem. you never have to use .all to access things in a package, and you can also include only specific parts of packages if you want:

    use ieee.std_logic_1164.std_logic; --cannot create std_logic_vectors

    To the OP : this is very similar to your problem you posted here: http://www.alteraforum.com/forum/showthread.php?t=51340&p=211717#post211717

    Have Altera confirmed the bug?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    At the end of the day, this appears to be a very convoluted solution to a very simple problem - is there any reason you are doing all of this with functions? if you step away from normal working practice, you are likely to hit tool bugs.

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

    --- Quote Start ---

    ???? http://www.alteraforum.com/forum/showthread.php?t=51340

    ok. Did you pay attention on the word "all" in "use" clause?

    by the way, why multiple call to "use" and "library" if VHDL able only one "use" clause per entity.

    library ieee;

    use ieee.std_logic_1164.all, ieee.numeric_std.all, work.sample.all;

    --- Quote End ---

    I think that I am easy to understand that do not use "all" in "use" clause.

    for example.

    
    package A is 
      subtype Code_Type is std_loigc_vector(3 downto 0);
      function New_Code return Code_Type;
    end A;
    package B is
      subtype Code_Type is unsinged(3 downto 0);
      function New_Code return Code_Type;
    end B;
    use work.A;
    use work.B;
       :
       :
      signal  code_a : A.Code_Type := A.New_Code;
      signal  code_b : B.Code_Type := B.New_Code;
       :
       :
    

    The purpose of this thread is because I wanted to share information, not knowing the solution.

    Though VHDL has such a description method, it presents a question in what only a tool of Altera does not accept.

    Thank you for a reply.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi, KAWAZOME san,

    --- Quote Start ---

    At the end of the day, this appears to be a very convoluted solution to a very simple problem - is there any reason you are doing all of this with functions? if you step away from normal working practice, you are likely to hit tool bugs.

    --- Quote End ---

    --- Quote Start ---

    :) oh. very nice answer

    --- Quote End ---

    Maybe, their replay had offended you, but they aren't kidding you. They only insist that 'If you have a workaround, don't enter the minefield'.

    This forum is maintained by many volunteers. Of course, we have the person of Altera company, too. And all people are struggling to solve their problems with mutual cooperation.

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

    --- Quote Start ---

    Hi, KAWAZOME san,

    Maybe, their replay had offended you, but they aren't kidding you. They only insist that 'If you have a workaround, don't enter the minefield'.

    This forum is maintained by many volunteers. Of course, we have the person of Altera company, too. And all people are struggling to solve their problems with mutual cooperation.

    Kazu

    --- Quote End ---

    Thank you for reply, Kazuyasu san.

    But,,, I do not want to participate again this unpleasant forum.

    Good bye.