Forum Discussion

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

Function application

Hi

When we use “ function” and where is its exact usage? what is the difference between it and “component”? if it is possible explain it by examples.

Thank you

2 Replies

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

    good question.

    component is meant to be direct definition of a design modul with its inputs/outputs and internal functionality.

    function( also has inputs/outputs and internal functionality but these are not meant to be direct module definition but rather a piece of user code to be inserted when that function is called up.

    it could due to the way HDL evolved (component from symbol era, function of programming language)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Hi

    When we use “ function” and where is its exact usage? what is the difference between it and “component”? if it is possible explain it by examples.

    Thank you

    --- Quote End ---

    A component is basically an entity. And of course an entity is something which encapsulates your logic design. It has inputs, outputs, internal signals and whatever logic you can imagine.

    A function is a bit of logic which executes in delta time, and is commonly used to implement code which gets reused. The various conversions you find in numeric_std, such as to_unsigned(), are examples of functions. Unlike its cousin the procedure, a function may not include any delay or wait mechanisms.