03:12
_whitelogger has joined #m-labs
03:45
_whitelogger has joined #m-labs
03:46
rohitksingh has joined #m-labs
04:24
_whitelogger has joined #m-labs
05:06
_whitelogger has joined #m-labs
08:16
rohitksingh has quit [Ping timeout: 264 seconds]
15:14
sb0 has joined #m-labs
17:54
zng has joined #m-labs
18:35
rohitksingh has joined #m-labs
19:40
kernlbob has joined #m-labs
19:50
<
kernlbob >
Is this the place for noob nMigen questions?
19:59
<
cr1901_modern >
Sure, but you may need to stick around for a while as IRC is async
20:00
<
kernlbob >
I hope the formatting isn't screwn up too horribly...
20:00
<
kernlbob >
I have this Verilog.
20:00
<
kernlbob >
module example(
20:00
<
kernlbob >
input clk,
20:00
<
kernlbob >
input [15:0] bits,
20:00
<
kernlbob >
output reg bit);
20:00
<
kernlbob >
reg [7:0] counter = 0;
20:01
<
kernlbob >
always @(posedge clk) begin
20:01
<
kernlbob >
bit <= bits[counter[6:3]];
20:01
<
kernlbob >
counter <= counter + 1;
20:01
<
kernlbob >
endmodule
20:01
<
kernlbob >
I rewrote it in nMigen like this.
20:01
<
kernlbob >
class Example(Elaboratable):
20:01
<
kernlbob >
def elaborate(self, platform):
20:01
<
kernlbob >
bits = Signal(16)
20:01
<
kernlbob >
bit = Signal()
20:01
<
kernlbob >
counter = Signal(8)
20:01
<
kernlbob >
m = Module()
20:01
<
kernlbob >
m.d.comb += [
20:01
<
kernlbob >
bit.eq(bits[counter[3:7]]),
20:01
<
kernlbob >
counter.eq(counter + 1),
20:01
<
kernlbob >
When I elaborate this, I get
20:01
<
kernlbob >
TypeError: Cannot index value with (slice (sig counter) 3:7)
20:01
<
kernlbob >
What should I be doing?
20:02
<
cr1901_modern >
Huh, this feels like it should be supported
20:03
<
cr1901_modern >
Maybe the functionality hasn't been added in yet?
20:04
<
cr1901_modern >
(Along with a elaboration-time check to ensure that the slice is within the range of the signal?)
20:07
rohitksingh has quit [Ping timeout: 276 seconds]
20:07
rohitksingh has joined #m-labs
20:09
<
kernlbob >
Crap. I put that in m.d.comb for the example. Meant m.d.sync, of course.
20:12
<
kernlbob >
Any idea how I could express the intent in a way nMigen would accept?
20:16
<
cr1901_modern >
kernlbob: I think that functionality needs to be added and you'll need to wait for a commit.
20:18
<
kernlbob >
Is this equivalent?
20:18
<
kernlbob >
bit.eq(bits.bit_select(counter[3:7], 1)),
20:53
<
vup >
kernlbob: yeah, normal slices only support constant indices and bit_select (or word_select) is used for non-constant indices
20:55
<
vup >
alternatively you can also used `Array` which also supports non-constant indices and has special handling for indices bigger than the array length
21:00
<
kernlbob >
@vup: thanks.
22:27
_whitelogger has joined #m-labs
22:59
zng has joined #m-labs
23:13
rohitksingh has quit [Ping timeout: 240 seconds]