Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] VHDL scope vs visibility vs visibility by selection

Status
Not open for further replies.

wtr

Full Member level 5
Full Member level 5
Joined
May 1, 2014
Messages
299
Helped
29
Reputation
58
Reaction score
25
Trophy points
1,308
Activity points
4,108
Hello all,

This following is a derived from my desire to keep a signal declaration local to a specific block, but use it in a different block. I know if I was to move the "scope" of the signal declaration to the architecture I would be able to apply visibility by selection.

Can a signal local to a specific block ever be used elsewhere? I'm experimenting with visibility by selection.

See the following. I would like to assign signal b to the a_block.a.


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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
library ieee;
use ieee.std_logic_1164.all;
 
 
entity tb is
    end entity tb;
 
 
architecture ar_tb of tb is
 
    signal a : std_logic_vector(3 downto 0);
 
begin
 
    process is
    begin
        wait for 1 ns;
        a <= x"0";
        wait for 49 ns;
        a <= x"1";
        wait for 97 ns;
        a <= x"2";
        wait for 17  ns;
        a <= x"3";
        wait for 10 ns;
        wait;
    end process;
 
    a_block : block
 
        signal a : std_logic_vector(3 downto 0);
 
    begin
        
        process(ar_tb.a) is -- , work.ar_tb.b_block.b) is -- , ar_tb.b_block.b)
        begin
            if ar_tb.a'event then
                a <= ar_tb.a ;
            end if;
            --if ar_tb.b_block.b'event then
                --a <= ar_tb.b_block.b;
            --end if;
        end process;
 
    end block a_block;
 
    b_block : block
        signal b : std_logic_vector(3 downto 0);
    begin
        process
        begin
            wait for 5 ns;
            b <= X"F";
            wait for 9 ns;
            b <= X"E";
            wait for 99 ns;
            b <= X"9";
            wait;
        end process;
    end block b_block;
    
    process
    begin
        wait for 1 us;
        report "" severity failure;
    end process;
 
end architecture;

 

With VHDL 2008, you can use external names. But you can only see inside something thats already in scope. So in your example, you cannot see inside "b_block" from "a_block" because it is declared after a_block. If you moved b_block ahead of a_block, you could write this:


Code VHDL - [expand]
1
a <= << signal ^.b_block.b : std_logic_vector(3 downto 0) >> ;



Because of the long syntax, it is normal to create aliases to external items when you need it multiple times:


Code VHDL - [expand]
1
2
3
alias b_block_b is << signal ^.b_block.b : std_logic_vector(3 downto 0) >> ;
...
a <= b_block_b;

 
  • Like
Reactions: wtr

    wtr

    Points: 2
    Helpful Answer Positive Rating
Thanks Tricky,

I was aware that the ^ - equivalent to "cd .." - looks up a level.

However I'm surprised to see that the order of block declarations matter. Although the statements declared within the architecture are concurrent to each other, it appears that the order matters. I don't know how the scope of b_block is visible by a_block when it's above, but not when below. I'd love to understand. In sw programming they have local & global variables. whereas in the land of firmware hdl - we have scope and visibility.

Below are two pictures. One from b_block after a_block and one with b_block before a_block.
b_block_after.PNGb_block_before.PNG

Is the scope overflow possible because during the initialisation phase?

I'm reading "effective coding with vhdl - principles and best practice" by ricardo jasinski. <- so far I think the book is brilliant.

However going beyond the book I'm trying to understand the scope and visibility within a simulation.
Given what you said about order. Where does it fail because of order?
anaylsis -> elaboration > initialisation > signal update | process execution (loop)
 
Last edited:

VHDL is a procedural language like any other, with scope the same as any other language. Statements are executed in the order they are written. So during the elaboration, everything is elaborated in order. It elaborates block_a before block_b (because of code order), and hence cannot find the path to B if you try an external name to it.
 
  • Like
Reactions: wtr

    wtr

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top