EmbDev.net

Forum: FPGA, VHDL & Verilog Bitwise OR of std_logic_vector


von Hamidreza A. (Company: Uni Siegen) (ahmadian)


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

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Hamidreza A. wrote:
> and I cannot figure out how to calculate the second signal in this case.
Check out the package reduce_pack and in there the functions or_reduce() 
as well as and_reduce().

See this also:
http://www.edaboard.com/thread253196.html

: Edited by Moderator
von Stefan Weide (Guest)


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';

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.