-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt to address #98 and related issues
- Loading branch information
1 parent
ebb7bcb
commit 14dc28f
Showing
3 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from myhdl import * | ||
from myhdl.conversion import analyze | ||
|
||
import pytest | ||
|
||
def issue_98(sda, scl, sda_i, sda_o, scl_i, scl_o): | ||
sda_d, scl_d = sda.driver(), scl.driver() | ||
@always_comb | ||
def hdl(): | ||
sda_i.next = sda | ||
#sda_d.next = 0 if not sda_o else None | ||
scl_i.next = scl | ||
#scl_d.next = None if not scl_o else 1 | ||
scl_d.next = None | ||
return hdl | ||
|
||
@pytest.mark.xfail(analyze.simulator in ('vcom', 'GHDL'), | ||
reason="requires VHDL support for ternary operator") | ||
def test_issue_98_1(): | ||
sda_i, sda_o, scl_i, scl_o = [Signal(False) for i in range(4)] | ||
sda, scl = [TristateSignal(False) for i in range(2)] | ||
toVHDL.name = 'issue_98_1' | ||
assert analyze(issue_98, sda, scl, sda_i, sda_o, scl_i, scl_o) == 0 | ||
|
||
@pytest.mark.xfail(analyze.simulator in ('vcom', 'GHDL'), | ||
reason="requires VHDL support for ternary operator") | ||
def test_issue_98_2(): | ||
sda_i, sda_o, scl_i, scl_o = [Signal(intbv(0)[2:0]) for i in range(4)] | ||
sda, scl = [TristateSignal(intbv(0)[2:0]) for i in range(2)] | ||
toVHDL.name = 'issue_98_2' | ||
assert analyze(issue_98, sda, scl, sda_i, sda_o, scl_i, scl_o) == 0 | ||
|
||
@pytest.mark.xfail(analyze.simulator in ('vcom', 'GHDL'), | ||
reason="requires VHDL support for ternary operator") | ||
def test_issue_98_3(): | ||
sda_i, sda_o, scl_i, scl_o = [Signal(intbv(0)[1:0]) for i in range(4)] | ||
sda, scl = [TristateSignal(intbv(0)[1:0]) for i in range(2)] | ||
toVHDL.name = 'issue_98_3' | ||
assert analyze(issue_98, sda, scl, sda_i, sda_o, scl_i, scl_o) == 0 | ||
|