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

Accepts '?' in Case, maps to '-' #204

Closed
nmigen-issue-migration opened this issue Sep 11, 2019 · 1 comment
Closed

Accepts '?' in Case, maps to '-' #204

nmigen-issue-migration opened this issue Sep 11, 2019 · 1 comment

Comments

@nmigen-issue-migration
Copy link

Issue by RobertBaruch
Wednesday Sep 11, 2019 at 05:04 GMT
Originally opened as m-labs/nmigen#203


- is the don't-care value in IL, but ? is the don't-care value in Verilog. This change allows you to use both in a Case.

Tested:

  • Added test case
  • Tested using this example, generating via -t il and -t v and inspecting output is well-formed:
from nmigen import *
from nmigen.cli import main
from nmigen.asserts import *


class TestCase(Elaboratable):
    def __init__(self):
        self.input = Signal(8)
        self.output = Signal()

    def elaborate(self, platform):
        m = Module()

        with m.Switch(self.input):
            with m.Case(0b00000000):
                m.d.comb += self.output.eq(1)
            with m.Case("1???0000"):
                m.d.comb += self.output.eq(0)
            with m.Default():
                m.d.comb += self.output.eq(1)
        return m


if __name__ == "__main__":
    clk = Signal()
    rst = Signal()

    pos = ClockDomain()
    pos.clk = clk
    pos.rst = rst

    testcase = TestCase()

    m = Module()
    m.domains.pos = pos
    m.submodules.testcase = testcase

    main(
        m,
        ports=[clk, rst, testcase.input, testcase.output],
        platform="formal")

RobertBaruch included the following code: https://github.com/m-labs/nmigen/pull/203/commits

@nmigen-issue-migration
Copy link
Author

Comment by codecov[bot]
Wednesday Sep 11, 2019 at 05:17 GMT


Codecov Report

Merging #203 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #203      +/-   ##
==========================================
+ Coverage   82.84%   82.85%   +<.01%     
==========================================
  Files          33       33              
  Lines        5294     5296       +2     
  Branches     1136     1137       +1     
==========================================
+ Hits         4386     4388       +2     
  Misses        783      783              
  Partials      125      125
Impacted Files Coverage Δ
nmigen/hdl/dsl.py 99.69% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7342662...7f389f6. Read the comment docs.

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

No branches or pull requests

1 participant