decoder

B

bir

Guest
I have a decoding logic which decodes bit 34 - 32 of a shift register.
But the the compiler complains "bit select operator cannot be applied
to scalar"

Can I implement the decoder in this format??


wire [2:0] a;
wire [7:0] addr_dec;

// Address Decode
assign a0 = shift_dr[32];
assign a1 = shift_dr[33];
assign a2 = shift_dr[34];

assign addr_dec[0] = !a2 && !a1 && !a0;
assign addr_dec[1] = !a2 && !a1 && a0;
assign addr_dec[2] = !a2 && a1 && !a0;
assign addr_dec[3] = !a2 && a1 && a0;
assign addr_dec[4] = a2 && !a1 && !a0;
assign addr_dec[5] = a2 && !a1 && a0;
assign addr_dec[6] = a2 && a1 && !a0;
assign addr_dec[7] = a2 && a1 && a0;

Thanks
 
bir wrote:
I have a decoding logic which decodes bit 34 - 32 of a shift register.
But the the compiler complains "bit select operator cannot be applied
to scalar"

Can I implement the decoder in this format??


wire [2:0] a;
wire [7:0] addr_dec;

// Address Decode
assign a0 = shift_dr[32];
assign a1 = shift_dr[33];
assign a2 = shift_dr[34];

assign addr_dec[0] = !a2 && !a1 && !a0;
assign addr_dec[1] = !a2 && !a1 && a0;
assign addr_dec[2] = !a2 && a1 && !a0;
assign addr_dec[3] = !a2 && a1 && a0;
assign addr_dec[4] = a2 && !a1 && !a0;
assign addr_dec[5] = a2 && !a1 && a0;
assign addr_dec[6] = a2 && a1 && !a0;
assign addr_dec[7] = a2 && a1 && a0;

Thanks
As long as shift_dr is properly dimensiones, I don't see a problem with
your approach.

You could, however, do things much more concisely:

wire [7:0] addr_dec = 8'h1 << shift_dr[34:32];
 
On 20 Dec 2006 08:29:16 -0800, "bir" <ritwikbiswas@gmail.com> wrote:

I have a decoding logic which decodes bit 34 - 32 of a shift register.
But the the compiler complains "bit select operator cannot be applied
to scalar"
What's your declaration of "shift_dr" look like? It should be OK
to select bits [34:32] off any suitable vector. Sounds as though
you may have mistakenly declared it as "reg" instead of
"reg [34:0]" or somesuch.

Can I implement the decoder in this format??
Yes, if your typing fingers have lots of stamina.

a;
wire [7:0] addr_dec;

// Address Decode
assign a0 = shift_dr[32];
assign a1 = shift_dr[33];
assign a2 = shift_dr[34];
//
Why not just "assign a = shift_dr [34:32]; " ??

= !a2 && !a1 && !a0;
//
Or "assign addr_dec[0] = (a==0);"

= !a2 && !a1 && a0;
assign addr_dec[2] = !a2 && a1 && !a0;
assign addr_dec[3] = !a2 && a1 && a0;
assign addr_dec[4] = a2 && !a1 && !a0;
assign addr_dec[5] = a2 && !a1 && a0;
assign addr_dec[6] = a2 && a1 && !a0;
assign addr_dec[7] = a2 && a1 && a0;
Or, easiest of all,
assign addr_dec = 1 << shift_dr[34:32];

--
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@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 

Welcome to EDABoard.com

Sponsor

Back
Top