sb0 changed the topic of #m-labs to: https://m-labs.hk :: Mattermost https://chat.m-labs.hk :: Logs http://irclog.whitequark.org/m-labs
_whitelogger has joined #m-labs
_whitelogger has joined #m-labs
rohitksingh has joined #m-labs
_whitelogger has joined #m-labs
_whitelogger has joined #m-labs
rohitksingh has quit [Ping timeout: 264 seconds]
sb0 has joined #m-labs
zng has quit [Quit: ZNC 1.7.2 - https://znc.in]
zng has joined #m-labs
rohitksingh has joined #m-labs
kernlbob has joined #m-labs
<kernlbob> Is this the place for noob nMigen questions?
<cr1901_modern> Sure, but you may need to stick around for a while as IRC is async
<kernlbob> I hope the formatting isn't screwn up too horribly...
<kernlbob> I have this Verilog.
<kernlbob> ```
<kernlbob> module example(
<kernlbob> input clk,
<kernlbob> input [15:0] bits,
<kernlbob> output reg bit);
<kernlbob> reg [7:0] counter = 0;
<kernlbob> always @(posedge clk) begin
<kernlbob> bit <= bits[counter[6:3]];
<kernlbob> counter <= counter + 1;
<kernlbob> end
<kernlbob> endmodule
<kernlbob> ```
<kernlbob> I rewrote it in nMigen like this.
<kernlbob> ```
<kernlbob> class Example(Elaboratable):
<kernlbob> def elaborate(self, platform):
<kernlbob> bits = Signal(16)
<kernlbob> bit = Signal()
<kernlbob> counter = Signal(8)
<kernlbob> m = Module()
<kernlbob> m.d.comb += [
<kernlbob> bit.eq(bits[counter[3:7]]),
<kernlbob> counter.eq(counter + 1),
<kernlbob> ]
<kernlbob> ```
<kernlbob> When I elaborate this, I get
<kernlbob> TypeError: Cannot index value with (slice (sig counter) 3:7)
<kernlbob> What should I be doing?
<cr1901_modern> Huh, this feels like it should be supported
<cr1901_modern> Maybe the functionality hasn't been added in yet?
<cr1901_modern> (Along with a elaboration-time check to ensure that the slice is within the range of the signal?)
rohitksingh has quit [Ping timeout: 276 seconds]
rohitksingh has joined #m-labs
<kernlbob> Crap. I put that in m.d.comb for the example. Meant m.d.sync, of course.
<kernlbob> Any idea how I could express the intent in a way nMigen would accept?
<cr1901_modern> kernlbob: I think that functionality needs to be added and you'll need to wait for a commit.
<kernlbob> Is this equivalent?
<kernlbob> bit.eq(bits.bit_select(counter[3:7], 1)),
<vup> kernlbob: yeah, normal slices only support constant indices and bit_select (or word_select) is used for non-constant indices
<vup> alternatively you can also used `Array` which also supports non-constant indices and has special handling for indices bigger than the array length
<kernlbob> @vup: thanks.
_whitelogger has joined #m-labs
zng has quit [Quit: ZNC 1.7.2 - https://znc.in]
zng has joined #m-labs
rohitksingh has quit [Ping timeout: 240 seconds]