2
\$\begingroup\$

EDIT:

I am working with a lookup table which is generated in compile time.

Is this compile time code:

  • because sinus_table is a constant

  • or because any computation before begin is compile time.

Or maybe both?

ARCHITECTURE Behavioral OF set_output IS

----------------------------------------------------------------------
-- Begin - Generate the lookup table
------------------------------------------------------------------------

  -- Elements per Signal
  CONSTANT table_length : integer := 2**sinus_width;

  IMPURE FUNCTION createSamples RETURN output_sinus IS
    VARIABLE result : output_sinus(0 TO table_length - 1);
    VARIABLE table_step : real := 2.0 * math_pi / real(table_length);
    VARIABLE sinus_result : real;
  BEGIN
    FOR i IN 0 TO table_length - 1 LOOP
      sinus_result := sin((real(i)) * table_step) / 2.0;
      result(i) := std_logic_vector(to_signed(integer(sinus_result * real(table_length - 1)), sinus_width));
    END LOOP;
    RETURN result;
  END FUNCTION createSamples;

  CONSTANT sinus_table : output_sinus := createSamples;

------------------------------------------------------------------------
-- End - Generate the lookup table
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Begin - Manage the address and return the sine wave
------------------------------------------------------------------------

BEGIN

PS: Do you know of any literature that I can cite about this?

(Most of the literature that I found explains synthesis/elaboration)...

\$\endgroup\$
  • 1
    \$\begingroup\$ "I want to know if this code is compile/elaboration time because sinus_table is a constant or if any computation before begin is compile time." - not sure what you mean by this. Do you want to know if the table values (or any computed values) are generated during compilation (ie. before elaboration)? \$\endgroup\$ – Bruce Abbott Aug 10 '17 at 15:02
  • 3
    \$\begingroup\$ Subprogram calls are dynamically elaborated, neither locally static (analysis or compile time) nor elaboration (linking) time, rather when called. The same for a loop parameter. You don't show the declaration of sinus_width, which if locally static (known at compile time) would allow populating sinus_table at analysis time, otherwise at elaboration time. See IEEE Std 1076-2008, 9.4 Static expressions. Analysis time depends on locally static expressions, elaboration time on any globally static expressions. \$\endgroup\$ – user8352 Aug 10 '17 at 16:33
  • 2
    \$\begingroup\$ @user8352 that looks a lot like an answer to me :) \$\endgroup\$ – scary_jeff Aug 10 '17 at 16:43
  • \$\begingroup\$ Sorry for the confusion, I reworded it.. \$\endgroup\$ – Chandran Goodchild Aug 10 '17 at 19:53
  • \$\begingroup\$ @BruceAbbott Yes that's what I meant. user8352 Thanks, that's good to have :-) \$\endgroup\$ – Chandran Goodchild Aug 10 '17 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.