Talk About Network

Google





Electronic Equipment > VHDL > Re: How to "or"...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 10 Topic 6070 of 6445
Post > Topic >>

Re: How to "or" a generic array of std_logic_vector ?

by Jonathan Bromley <jonathan.bromley@[EMAIL PROTECTED] > Jun 7, 2008 at 08:59 PM

On Sat, 7 Jun 2008 12:17:08 -0700 (PDT), HansWernerMarschke@[EMAIL PROTECTED]
>type array_of_std_logic_vector is array (0 to
>number_of_rotors_array-1) of std_logic_vector(0 to
>data_width_array-1);
>signal data_out_array       : array_of_std_logic_vector;
>
>I want to "or" the "bits" of std_logic_vector for each element of the
>vector like this.
>data_out(i) shall be '1' if one of the elements of the vector has set
>this bit to one.
>
>data_out(0) <= '1' when unsigned(data_out_array(0)) /= 0;
>data_out(1) <= '1' when unsigned(data_out_array(1)) /= 0;
>
>The problem is that number_of_rotors and although data_width_array are
>generic.

That's not so much a problem as a solution waiting to happen...

  for i in data_out_array'range loop
    data_out(i) <= reduction_or(data_out_array(i));
  end loop;

Oh, the function...

  function reduction_or(v: in std_logic_vector) return std_logic is
    variable r_or: std_logic;
  begin
    r_or := '0';
    for i in v'range loop
      r_or := r_or or v(i);
    end loop;
    return r;
  end;

This is the sort of thing that VHDL does best.
-- 
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@[EMAIL PROTECTED]
 contents of this message may contain personal views which 
are not the views of Doulos Ltd., unless specifically stated.
 




 10 Posts in Topic:
How to "or" a generic array of std_logic_vector ?
HansWernerMarschke@[EMAIL  2008-06-07 12:17:08 
Re: How to "or" a generic array of std_logic_vector ?
Jonathan Bromley <jona  2008-06-07 20:59:58 
Re: How to "or" a generic array of std_logic_vector ?
HansWernerMarschke@[EMAIL  2008-06-07 14:49:54 
Re: How to "or" a generic array of std_logic_vector ?
Mike Treseler <mtresel  2008-06-07 15:14:47 
Re: How to "or" a generic array of std_logic_vector ?
Jonathan Bromley <jona  2008-06-07 23:19:26 
Re: How to "or" a generic array of std_logic_vector ?
Brian Drummond <brian_  2008-06-08 14:17:12 
Re: How to "or" a generic array of std_logic_vector ?
HansWernerMarschke@[EMAIL  2008-06-08 06:20:53 
Re: How to "or" a generic array of std_logic_vector ?
"KJ" <kkjenn  2008-06-08 19:52:10 
Re: How to "or" a generic array of std_logic_vector ?
Andy <jonesandy@[EMAIL  2008-06-09 11:07:52 
Re: How to "or" a generic array of std_logic_vector ?
KJ <kkjennings@[EMAIL   2008-06-09 12:40:20 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Thu Jan 8 12:13:08 PST 2009.