[libre-riscv-dev] [Bug 316] bperm TODO

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Fri May 15 22:06:44 BST 2020


https://bugs.libre-soc.org/show_bug.cgi?id=316

--- Comment #1 from Cole Poirier <colepoirier at gmail.com> ---
The code below is what I have so far in my first attempt at solving this
problem:

 from nmigen import Elaboratable, Signal, Module, Repl, Cat
 from nmigen.cli import main

 class Bpermd(Elaboratable):
     def __init__(self, width):
         self.perm = Signal(width)
         self.rs   = Signal(width)
         self.ra   = Signal(width)
         self.rb   = Signal(width)

     def elaborate(self, platform):
         m = Module()
         m.d.comb += self.perm.eq(Cat(0, Repl(8)))
         index = Signal(8)
         for i in range(0, 7 + 1):
             index = rs[8 * i:8 * i + 7 + 1]
             with m.If(index.lt(64)):
                 m.d.comb += self.perm[i].eq(rb[index])
             with m.Else():
                 m.d.comb += self.perm[i].eq(0)
         m.d.comb += ra.eq(Cat(Cat(0, Repl(56)),prem[0:8]))
         return m

 if __name__ == "__main__":
     bperm = Bpermd(width=8)
     main(bperm, ports=[bperm.perm, bperm.rs, bperm.ra, bperm.rb])
```

When I try running a command (python3 bperm.py simulate -c 20 -v bperm.vcd)
taken from this
(http://blog.lambdaconcept.com/doku.php?id=nmigen:nmigen_hello_world) tutorial
I get the following error:
```
Traceback (most recent call last):
  File "bperm.py", line 26, in <module>
    main(bperm, ports=[bperm.perm, bperm.rs, bperm.ra, bperm.rb])
  File "/home/colepoirier/src/nmigen/nmigen/cli.py", line 74, in main
    main_runner(parser, parser.parse_args(), *args, **kwargs)
  File "/home/colepoirier/src/nmigen/nmigen/cli.py", line 65, in main_runner
    fragment = Fragment.get(design, platform)
  File "/home/colepoirier/src/nmigen/nmigen/hdl/ir.py", line 39, in get
    obj = obj.elaborate(platform)
  File "bperm.py", line 13, in elaborate
    m.d.comb += self.perm.eq(Cat(0, Repl(8)))
TypeError: __init__() missing 1 required positional argument: 'count'
```

I don't understand why I am getting the error that I'm missing a positional
argument count in my __init__() function, since it only takes the parameters
self and width. I'm sure this error is just due to my not understanding nmigen
properly yet, so any help will be very much appreciated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-riscv-dev mailing list