Procedure in VHDL testbench

Guest #5610574
Rate this post
• ▲ useful
▼ not useful
Hello there,

I am trying to implement a procedure in my testbench to shorten the 
lenght.
1
entity tb is
2
end entity;
3

4
architecture sim of tb is
5

6
  procedure P_DATA(
7
      constant ctrl  : in std_logic_vector (8 downto 0);
8
      constant ht    : in std_logic_vector (16 downto 0);
9
      constant prd   : in std_logic_vector (16 downto 0))
10
      is
11
      variable i_sctrl  :  std_logic_vector (8 downto 0);
12
      variable i_sprd    :  std_logic_vector (16 downto 0);
13
      variable i_sht     :  std_logic_vector (16 downto 0);
14
 begin
15
     i_sctrl  := ctrl;
16
     i_sprd   := prd;
17
     i_sht    := ht;
18
 end procedure;
19

20
  signal i_clk   : std_logic;
21
  signal i_rst   : std_logic; 
22
  signal i_sctrl : std_logic_vector (8 downto 0);
23
  signal i_sprd  : std_logic_vector (16 downto 0;
24
  Signal i_sht   : std_logic_vector (16 downto 0;
25
  ....
26

27
begin
28

29
  -- Data generation
30
  pr_int : process
31
  begin
32
      
33
      i_rst <= '1';
34
      i_sctrl <= (others => '0');
35
      i_sprd  <= (others => '0');
36
      i_sht   <= (others => '0');
37
      wait for 5 ns;
38
      i_rst <= '0';
39
      wait for 2 ns;
40
      wait for rising_edge(i_clk);
41
      P_DATA(X"04", X"0009",X"000A");
42
      wait for 1 ns;
43
      wait;
44

45
     end process;
46

47
end architecture;

When I simulate to above Code my inputs data are all "zero" all the 
time. How can I modify the procedure to get the set values in the 
simulation waveform

Many thanks
Guest #5611686
Rate this post
• ▲ useful
▼ not useful
The signals i_sctrl, i_sprd and i_sht are in a diffrent scope, than the 
variables with the same name inside the procedure.

If you want zu use them, you have to add them to the parameter list:
1
  procedure P_DATA(
2
      constant ctrl  : in std_logic_vector (8 downto 0);
3
      constant ht    : in std_logic_vector (16 downto 0);
4
      constant prd   : in std_logic_vector (16 downto 0);
5
      signal x_sctrl : out std_logic_vector (8 downto 0);
6
      signal x_sprd  : out std_logic_vector (16 downto 0);
7
      signal x_sht   : out std_logic_vector (16 downto 0);
8
)
9
      is
10
 begin
11
     x_sctrl  <= ctrl;
12
     x_sprd   <= prd;
13
     x_sht    <= ht;
14
 end procedure;
15

16
...
17

18
P_DATA(X"04", X"0009",X"000A",i_sctrl,i_sprd,i_sht);

Duke
Guest #5612045
Rate this post
• ▲ useful
▼ not useful
Duke Scarring wrote:
> The signals i_sctrl, i_sprd and i_sht are in a diffrent scope,
> than the
> variables with the same name inside the procedure.
>
> If you want zu use them, you have to add them to the parameter list:
> procedure P_DATA(
>       constant ctrl  : in std_logic_vector (8 downto 0);
>       constant ht    : in std_logic_vector (16 downto 0);
>       constant prd   : in std_logic_vector (16 downto 0);
>       signal x_sctrl : out std_logic_vector (8 downto 0);
>       signal x_sprd  : out std_logic_vector (16 downto 0);
>       signal x_sht   : out std_logic_vector (16 downto 0);
> )
>       is
>  begin
>      x_sctrl  <= ctrl;
>      x_sprd   <= prd;
>      x_sht    <= ht;
>  end procedure;
>
> ...
>
> P_DATA(X"04", X"0009",X"000A",i_sctrl,i_sprd,i_sht);
>
> Duke

Hi Duke,

Thanks a lot. It's a exactly what I wanted to do. It works like a charm

Many Thanks

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.