Negative in wire indexes in Verilog, should I be worried?

628 views
Skip to first unread message

Rupert Smith

unread,
Nov 1, 2013, 12:59:04 PM11/1/13
to chisel...@googlegroups.com
I notice this in the generated Verilog:

  wire[-7:0] cs_3;
  wire[-7:0] cs_2;
  wire[-7:0] cs_1;
  wire[-7:0] cs_0;

Wired declared over a negative range of indexes. Is this Verilog ok? This was generated from this statement, which breaks a 32-bit integer down into its component bytes:

  val cs = Vec(Range(0, 4).map(i => io.in(i * 8, (i + 1) * 8 - 1)))

I'm curious as to why this ones gets mapped onto a negative range...

Rupert

Jonathan Bachrach

unread,
Nov 1, 2013, 1:35:54 PM11/1/13
to chisel...@googlegroups.com
this should be caught by chisel.
i’ll file the bug.
meanwhile i think you should be reversing the arguments

  val cs = Vec(Range(0, 4).map(i => io.in((i + 1) * 8 - 1, i * 8)))

to have the high index first then the low index.

--
You received this message because you are subscribed to the Google Groups "chisel-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chisel-users...@googlegroups.com.
To post to this group, send email to chisel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/f1300801-e40d-445b-a18d-51c784eb7bd3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Rupert Smith

unread,
Nov 1, 2013, 5:17:17 PM11/1/13
to chisel...@googlegroups.com
On 1 November 2013 17:35, Jonathan Bachrach <jackba...@gmail.com> wrote:
meanwhile i think you should be reversing the arguments

  val cs = Vec(Range(0, 4).map(i => io.in((i + 1) * 8 - 1, i * 8)))

to have the high index first then the low index.

Yes, of course. Thanks.

Rupert 
Reply all
Reply to author
Forward
0 new messages