Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple memory doesn't seem to work with a simple Cover statement? #260

Closed
RobertBaruch opened this issue Oct 27, 2019 · 2 comments
Closed
Labels

Comments

@RobertBaruch
Copy link

Possibly I'm not understanding how to use Memory?

mem.py:

from nmigen import *
from nmigen.asserts import *
from nmigen.cli import main


class A(Elaboratable):
    def __init__(self):
        a = [1, 2, 3, 4, 5, 6]
        self.addr = Signal.range(0, len(a))
        self.data = Signal(8)
        self.mem = Memory(width=8, depth=len(a), init=a)

    def elaborate(self, platform):
        m = Module()
        m.submodules.rdport = rdport = self.mem.read_port()
        m.d.comb += [
            rdport.addr.eq(self.addr),
            self.data.eq(rdport.data),
        ]
        return m


if __name__ == "__main__":
    m = Module()
    a = A()
    m.submodules.a = a

    m.d.comb += Cover(a.addr == 0)

    main(m, ports=[a.addr, a.data])

mem.sby:

[tasks]
cover

[options]
cover: mode cover
cover: depth 61

[engines]
smtbmc boolector

[script]
read_ilang mem.il
prep -top top

[files]
mem.il

The output seems to imply that the memory is never initialized, and the output is always 10000000.

@whitequark
Copy link
Contributor

That looks correct. Are you taking into account that memory ports (read and write) are synchronous by default?

@RobertBaruch
Copy link
Author

Ah, that was it. I had to set up the read_port properly:

        m.submodules.rdport = rdport = self.mem.read_port(domain="comb")

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants