From 61c3efc5f5a9931b4c6ab3cb87d8414b31c447a0 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 24 Apr 2015 12:00:46 +0200 Subject: [PATCH] migen/test: rename asic_syntax to test_syntax and simplify --- migen/test/{asic_syntax.py => test_syntax.py} | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) rename migen/test/{asic_syntax.py => test_syntax.py} (52%) diff --git a/migen/test/asic_syntax.py b/migen/test/test_syntax.py similarity index 52% rename from migen/test/asic_syntax.py rename to migen/test/test_syntax.py index cf137638..5f531085 100644 --- a/migen/test/asic_syntax.py +++ b/migen/test/test_syntax.py @@ -6,8 +6,9 @@ from migen.fhdl.std import * from migen.fhdl.verilog import convert -# Create a module with some combinatorial, some sequential, and some simple assigns -class ThingBlock(Module): +# Create a module with some combinatorial, some sequential, and some simple +# assigns +class SyntaxModule(Module): def __init__(self): x = [Signal(8) for y in range(10)] y = [Signal(8) for z in range(10)] @@ -31,28 +32,29 @@ class ThingBlock(Module): # Create unit test to build module, run Verilator and check for errors -class TestThingBlock(unittest.TestCase): - def test_mode_true(self): - filename = "test_module_true.v" - t = ThingBlock() - with open(filename, "w") as fh: - fh.write("/* verilator lint_off WIDTH */\n") - fh.write(str(convert(t, t.io, name="test_module", - asic_syntax=True))) - - subprocess.check_call("verilator --lint-only " + filename, +class SyntaxCase(unittest.TestCase): + def base_test(self, name, asic_syntax, options=[]): + filename = "test_module_{}.v".format(name) + t = SyntaxModule() + c = convert(t, t.io, name="test_module", asic_syntax=asic_syntax) + f = open(filename, "w") + f.write(str(c)) + f.close() + subprocess.check_call("verilator --lint-only " + " ".join(options) + " " + filename, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True) os.unlink(filename) - def test_mode_false(self): - filename = "test_module_false.v" - t = ThingBlock() - with open(filename, "w") as fh: - fh.write(str(convert(t, t.io, name="test_module"))) - - with self.assertRaises(subprocess.CalledProcessError): - subprocess.check_call("verilator --lint-only " + filename, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, shell=True) - os.unlink(filename) + def test_generic_syntax(self): + options = [ + "-Wno-WIDTH", + "-Wno-COMBDLY", + "-Wno-INITIALDLY" + ] + self.base_test("generic", False, options) + + def test_asic_syntax(self): + options = [ + "-Wno-WIDTH", # XXX should we improve ASIC backend to remove this? + ] + self.base_test("asic", True, options) -- 2.30.2