Verilog: “… is not a constant”

前端 未结 1 897
终归单人心
终归单人心 2020-12-11 13:09

I have three wires created like this:

wire [11:0] magnitude;
wire [3:0] bitsEnd;
wire [3:0] leadingBits;

All of them are assign

相关标签:
1条回答
  • 2020-12-11 13:58

    In Verilog you can't use a variable (i.e. bitsEnd) as the end of range. You can use +:/-: operator to solve your issue:

    assign leadingBits = magnitude[bitsEnd+3 -: 4];
    

    In the first case you only calculate single index (it's not a range). That's why the compiler is not complaining about it.

    0 讨论(0)
提交回复
热议问题