Do functions and procedures infer registers in VHDL?

Status
Not open for further replies.

matrixofdynamism

Advanced Member level 2
Joined
Apr 17, 2011
Messages
593
Helped
24
Reputation
48
Reaction score
23
Trophy points
1,298
Activity points
7,681
Functions and procedures are used to define often repeated sequence of instructions on data into a single place like in any other language. Is it true that in VHDL they are only able to infer combinatorial logic and never any registers? Is this true even if they are called from a process under rising_edge(clk) being true?

Is there no way for them to infer registers at all?
 

you would not usually infer registers from them directly, just how they are used.
If they are used inside a clocked process, then assuming they synthesise, they will infer registered logic. Technically here, the function/procedure have only infered logic, with the clocked process infering the register.

A function can NEVER infer a register on it's own, because a function cannot have timing inside it, and it always completes within a single delta.
But I believe it is possible to infer a register from a procedure. For example, the following procedures should infer a register when compiled:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
procedure reg(signal clk : in  std_logic; 
              signal d   : in  std_logic;
              signal q   : out std_logic ) is
begin
  if rising_edge(clk) then
    q <= d;
  end if;
end procedure;
 
-- this should also infer a register (if synth tool supports wait until in process, which most do if there is only 1)
procedure reg(signal clk : in  std_logic; 
              signal d   : in  std_logic;
              signal q   : out std_logic ) is
begin
  wait until rising_edge(clk);
  q <= d;
end procedure;
...
 
architecture rtl of my_ent is
begin
  reg(clk, ent_ip, ent_op);
end architecture rtl;



This works because code not inside a process actually infer a process, sensitive to all "input" signals.

so this line:

a <= b;

is actually this process:

Code:
process(b)
begin
  a <= b;
end process;
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…