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.
libraryieee;useieee.std_logic_1164.all;entity tb isendentity tb;architecture ar_tb of tb issignal a :std_logic_vector(3downto0);beginprocessisbeginwaitfor1ns;
a <= x"0";waitfor49ns;
a <= x"1";waitfor97ns;
a <= x"2";waitfor17ns;
a <= x"3";waitfor10ns;wait;endprocess;
a_block :blocksignal a :std_logic_vector(3downto0);beginprocess(ar_tb.a)is-- , work.ar_tb.b_block.b) is -- , ar_tb.b_block.b)beginif ar_tb.a'eventthen
a <= ar_tb.a ;endif;--if ar_tb.b_block.b'event then--a <= ar_tb.b_block.b;--end if;endprocess;endblock a_block;
b_block :blocksignal b :std_logic_vector(3downto0);beginprocessbeginwaitfor5ns;
b <= X"F";waitfor9ns;
b <= X"E";waitfor99ns;
b <= X"9";wait;endprocess;endblock b_block;processbeginwaitfor1us;report""severity failure;endprocess;endarchitecture;
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(3downto0)>>;
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(3downto0)>>;
...
a <= b_block_b;
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.
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)
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.