[libre-riscv-dev] pinmux in nmigen

Luke Kenneth Casson Leighton lkcl at lkcl.net
Wed Apr 3 23:19:31 BST 2019


On Wed, Apr 3, 2019 at 6:05 PM Rishabh Jain <rishucoding at gmail.com> wrote:
>
> Hello luke,
>
> I have started with migen. I found a good tutorial at
> http://blog.lambdaconcept.com/doku.php?id=migen:tutorial
> I am getting to like it :)

 oo that's a good tutorial example, i'll make a note of it here
https://libre-riscv.org/3d_gpu/

> Now, I have a better understanding of migen.
> I found there are some good examples in migen and nmigen repo. I am going
> to check them soon.

 yehyeh they're pretty good.  now if you look again at daniel's work
(and also back at the tutorial) you'll see how to set up a simulaton
(a unit test), which is a key step.

> I was wondering if there is any technical document on migen or nmigen
> giving complete documentation about this library. are you aware of anything
> here?

 *sigh* ok so one way is to run epydoc on the actual source code
(remember that in the Makefile of the pinmux?) and that will give you
something current, based on the docstrings.  or, you can go here but
bear in mind it's based on migen not nmigen:
https://m-labs.hk/migen/manual/

> I find migen similar to cocotb in the sense, we write the design logic in
> high level abstract manner (FHDL).

 yehyeh

> I remember, we were using myHdl?

 that's right.

> So, may you give me some pointers on choosing nmigen over it?

 myhdl you are forced to conform to a strict subset of python.  using
classes is extremely awkward, and constructing complex data structures
even more so.

 by contrast, in nmigen and migen, you get to use *python* features to
construct the HDL.

> I haven't checked pinmux yet, but for starting writing modules in nmigen,
> may you share thoughts on where can I begin?

 well, try looking at two similar examples from migen and nmigen, then
pick say that tutorial and do a conversion from migen to nmigen.

 first of course, have a unit test working and be familiar with the
gtkwave output.   you *should* be able to do it nearly line-by-line
and still on each change have the unit test running, because there is
a compatibility from migen to nmigen.

 just... do it :)

 btw when you get to the pinmux, have a look at nmigen Record
(hdl/rec.py) - you'll find it *already has* the exact in/out
capability we need!

l.



More information about the libre-riscv-dev mailing list