Bitwise OR of std_logic_vector

OP (Company: Uni Siegen) #4465969
Rate this post
• ▲ useful
▼ not useful
Hello,

Suppose we have 4 buffer, each has a single bit which indicates if the 
buffer is empty and we connect this pin to the bellow signal.

signal buffer_empty       : std_logic_vector (3 downto 0);

Each bit of the above signal indicates whether the corresponding buffer 
is empty or not and the below signal indicates whether we have an empty 
buffer al all.

signal any_buffer_empty   : std_logic;

The second signal can be assigned as follows:

any_buffer_empty <= buffer_empty (0) and buffer_empty (1) and 
buffer_empty (2) and buffer_empty (3);

Now the problem gets difficult for me if the number of buffers is 
parameterized (by a generic or constant like NR_BUFF) and I cannot 
figure out how to calculate the second signal in this case.

Thanks in advance,
Hamid
Guest #4466163
Rate this post
• ▲ useful
▼ not useful
You can also use the following
1
  -- bit-wise or
2
  any_buffer_empty <= '0' when buffer_empty=(buffer_empty'range=>'0') else
3
                      '1';
4
  --bit-wise and
5
  all_buffer_empty <= '1' when buffer_empty=(buffer_empty'range=>'1') else
6
                      '0';

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.