3

How can i declare a series of signal using generate statement in VHDL? i use generate statement but i can't compile code because of errer.

architecture DATAFLOW of P_2 is 
signal L3_0 : std_logic ;
signal L3_1 : std_logic ;
signal L3_2 : std_logic ;
signal L3_3 : std_logic ;
signal L3_4 : std_logic ;
signal L3_5 : std_logic ;
signal L3_6 : std_logic ;
signal L3_7 : std_logic ;
------------------------
signal L2_0 : std_logic ;
signal L2_1 : std_logic ;
signal L2_2 : std_logic ;
signal L2_3 : std_logic ;
------------------------
signal L1_0 : std_logic ;
signal L1_1 : std_logic ;
------------------------
signal L0_0 : std_logic ;
------------------------
begin
L3_0 <= DATA_IN(0) xor DATA_IN(1);
L3_1 <= DATA_IN(2) xor DATA_IN(3);
L3_2 <= DATA_IN(4) xor DATA_IN(5);
L3_3 <= DATA_IN(6) xor DATA_IN(7);
-----------------------
L2_0 <= L3_0 xor L3_1;
L2_1 <= L3_2 xor L3_3;

end DATAFLOW;

thank for your helping. I also use block statement but i can't declare signal in declaration part.

architecture DATAFLOW of P_2 is

begin
u1 : for i in 0 to 7 generate
signal L3_i : std_logic ;
begin
end generate;

u2 : for i in 0 to 3 generate
signal L2_i : std_logic ;
begin
end generate;

u3 : for i in 0 to 1 generate
signal L1_i : std_logic ;
begin
end generate;

u4 : for i in 0 to 0 generate
signal L0_i : std_logic ;
begin
end generate;

end DATAFLOW;
ali.329
  • 31
  • 1
  • 5
  • 1
    You can declare a block within a generate statement : that will have its own declaration region. –  Nov 03 '16 at 12:37
  • thank you for comment. but i beginner in VHDL. can you explain for me more details? – ali.329 Nov 03 '16 at 13:03
  • Any good VHDL teaching resource should cover the `block` statement. –  Nov 03 '16 at 13:53
  • i use the block statement but i can't declare signals in declaration part. I have to declare in the body of block. and in the rest of my code compiler doesn't identifier these signals. – ali.329 Nov 03 '16 at 15:18
  • Show a [Minimal Complete and Verifiable Example](http://stackoverflow.com/help/mcve). By adding a context clause and entity declaration to your second architecture DATAFLOW (`library ieee;use ieee.std_logic_1164.all; entity P_2 is end entity;`) it analyzes (compiles) and elaborates (links). –  Nov 03 '16 at 17:20
  • Block statements are used to define hierarchy by limiting scope. The signals declared in a block via a generate are not available outside the inner declarative region defined by the block statement. –  Nov 03 '16 at 17:23
  • I understand function of block statement.my problem is how generate all these signal with the name that mention above and then use them for evaluate XOR. thank you.I have worked for 3 days but... – ali.329 Nov 03 '16 at 21:37
  • I suggest you explain what are you trying to achieve instead of asking for help making your solution to work. Your question, as is now, has already been answered; if you can't get it to work, there are other issues you may be unaware of. You might find interesting to read http://xyproblem.info/ – suoto Nov 04 '16 at 12:43

0 Answers0