From ea6cba2f404d909e10fc944d4ddb068e163f7833 Mon Sep 17 00:00:00 2001 From: Marcel Hellwig <1hellwig@informatik.uni-hamburg.de> Date: Sat, 30 Jan 2016 20:17:01 +0100 Subject: [PATCH 01/18] Add 'filename' attribute to traceSignals --- doc/source/manual/reference.rst | 5 +++++ myhdl/_traceSignals.py | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/source/manual/reference.rst b/doc/source/manual/reference.rst index 38ce3afa..f3842684 100644 --- a/doc/source/manual/reference.rst +++ b/doc/source/manual/reference.rst @@ -90,6 +90,11 @@ Waveform tracing This attribute is used to set the directory to which VCD files are written. By default, the current working directory is used. + .. attribute:: filename + + This attribute is used to set the filename to which VCD files are written. By + default, the name attribbute is used. + .. attribute:: timescale This attribute is used to set the timescale corresponding to unit steps, diff --git a/myhdl/_traceSignals.py b/myhdl/_traceSignals.py index abd8dd5a..15f71324 100644 --- a/myhdl/_traceSignals.py +++ b/myhdl/_traceSignals.py @@ -50,6 +50,7 @@ class _TraceSignalsClass(object): __slot__ = ("name", "directory", + "filename", "timescale", "tracelists" ) @@ -57,6 +58,7 @@ class _TraceSignalsClass(object): def __init__(self): self.name = None self.directory = None + self.filename = None self.timescale = "1ns" self.tracelists = True @@ -89,8 +91,13 @@ class _TraceSignalsClass(object): else: directory = self.directory + if self.filename is None: + filename = self.name + else + filename = self.filename + h = _HierExtr(name, dut, *args, **kwargs) - vcdpath = os.path.join(directory, name + ".vcd") + vcdpath = os.path.join(directory, filename + ".vcd") if path.exists(vcdpath): backup = vcdpath + '.' + str(path.getmtime(vcdpath)) shutil.copyfile(vcdpath, backup) From 02c4f92ff69f6f0f2950de16f024654f95859ddb Mon Sep 17 00:00:00 2001 From: Marcel Hellwig <1hellwig@informatik.uni-hamburg.de> Date: Sat, 30 Jan 2016 21:26:46 +0100 Subject: [PATCH 02/18] fixed missing colon in _traceSignals --- myhdl/_traceSignals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myhdl/_traceSignals.py b/myhdl/_traceSignals.py index 15f71324..37661b20 100644 --- a/myhdl/_traceSignals.py +++ b/myhdl/_traceSignals.py @@ -93,7 +93,7 @@ class _TraceSignalsClass(object): if self.filename is None: filename = self.name - else + else: filename = self.filename h = _HierExtr(name, dut, *args, **kwargs) From cff6f1e54e1efb5d1d29d89e9fc5c2d45ab5498b Mon Sep 17 00:00:00 2001 From: Marcel Hellwig <1hellwig@informatik.uni-hamburg.de> Date: Sat, 30 Jan 2016 21:44:46 +0100 Subject: [PATCH 03/18] replaced self.name with name in _traceSignals --- myhdl/_traceSignals.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/myhdl/_traceSignals.py b/myhdl/_traceSignals.py index 37661b20..b2e16745 100644 --- a/myhdl/_traceSignals.py +++ b/myhdl/_traceSignals.py @@ -92,12 +92,12 @@ class _TraceSignalsClass(object): directory = self.directory if self.filename is None: - filename = self.name + filename = name else: - filename = self.filename + filename = str(self.filename) h = _HierExtr(name, dut, *args, **kwargs) - vcdpath = os.path.join(directory, filename + ".vcd") + vcdpath = os.path.join(directory, name + ".vcd") if path.exists(vcdpath): backup = vcdpath + '.' + str(path.getmtime(vcdpath)) shutil.copyfile(vcdpath, backup) From 04b9935626cc04a74aa3046cc836723496efd611 Mon Sep 17 00:00:00 2001 From: Marcel Hellwig <1hellwig@informatik.uni-hamburg.de> Date: Sun, 31 Jan 2016 01:10:05 +0100 Subject: [PATCH 04/18] fixed mistake where I replaced filename with name --- myhdl/_traceSignals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myhdl/_traceSignals.py b/myhdl/_traceSignals.py index b2e16745..df4cc4ec 100644 --- a/myhdl/_traceSignals.py +++ b/myhdl/_traceSignals.py @@ -97,7 +97,7 @@ class _TraceSignalsClass(object): filename = str(self.filename) h = _HierExtr(name, dut, *args, **kwargs) - vcdpath = os.path.join(directory, name + ".vcd") + vcdpath = os.path.join(directory, filename + ".vcd") if path.exists(vcdpath): backup = vcdpath + '.' + str(path.getmtime(vcdpath)) shutil.copyfile(vcdpath, backup) From 0ea0fef555b90f354d6584345a3eed0ae8104b18 Mon Sep 17 00:00:00 2001 From: srivatsansoft Date: Tue, 23 Feb 2016 22:41:48 +0530 Subject: [PATCH 05/18] A single simulation instance issue#104 --- myhdl/_Simulation.py | 22 +++++++++++++----- myhdl/test/bugs/test_issue_104.py | 34 ++++++++++++++++++++++++++++ myhdl/test/core/test_traceSignals.py | 8 +++++-- 3 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 myhdl/test/bugs/test_issue_104.py diff --git a/myhdl/_Simulation.py b/myhdl/_Simulation.py index 80ec07c1..e16b987b 100644 --- a/myhdl/_Simulation.py +++ b/myhdl/_Simulation.py @@ -54,6 +54,7 @@ class Simulation(object): run -- run a simulation for some duration """ + _run_call_static = 0 def __init__(self, *args): """ Construct a simulation object. @@ -63,6 +64,7 @@ class Simulation(object): """ _simulator._time = 0 + self._run_call = 0 arglist = _flatten(*args) self._waiters, self._cosim = _makeWaiters(arglist) if not self._cosim and _simulator._cosim: @@ -70,8 +72,8 @@ class Simulation(object): self._finished = False del _futureEvents[:] del _siglist[:] - - + + def _finalize(self): cosim = self._cosim if cosim: @@ -85,9 +87,13 @@ class Simulation(object): # clean up for potential new run with same signals for s in _signals: s._clear() + self._run_call = 0 + Simulation._run_call_static = 0 self._finished = True - - + + def quit(self): + self._finalize() + def runc(self, duration=0, quiet=0): simrunc.run(sim=self, duration=duration, quiet=quiet) @@ -105,6 +111,10 @@ class Simulation(object): # From this point it will propagate to the caller, that can catch it. if self._finished: raise StopSimulation("Simulation has already finished") + if Simulation._run_call_static > self._run_call: + raise StopSimulation("Previous Simulation is still running") + Simulation._run_call_static += 1 + self._run_call += 1 waiters = self._waiters maxTime = None if duration: @@ -201,7 +211,7 @@ class Simulation(object): self._finalize() # now reraise the exepction raise - + def _makeWaiters(arglist): waiters = [] @@ -231,4 +241,4 @@ def _makeWaiters(arglist): if hasattr(sig, '_waiter'): waiters.append(sig._waiter) return waiters, cosim - + diff --git a/myhdl/test/bugs/test_issue_104.py b/myhdl/test/bugs/test_issue_104.py new file mode 100644 index 00000000..da33f2c7 --- /dev/null +++ b/myhdl/test/bugs/test_issue_104.py @@ -0,0 +1,34 @@ +import pytest +from myhdl import Simulation, always, delay, Signal, intbv, StopSimulation + + +def clk_driver(clk, period=20): + @always(delay(period/2)) + def drive_clk(): + clk.next = not clk + return drive_clk + +def issue_104_quit_method(): + clk = Signal(intbv(1)) + sim = Simulation(clk_driver(clk)) + sim.run(1000) + sim.run(500) + sim.quit() + return sim._finished +sim2 = None +def issue_104_multiple_instance(): + global sim2 + clk = Signal(intbv(1)) + sim = Simulation(clk_driver(clk)) + sim.run(1000) + sim2 = Simulation(clk_driver(clk)) + sim2.run(10) + +def test_issue_104(): + + assert issue_104_quit_method() == True + + with pytest.raises(StopSimulation) as excinfo: + issue_104_multiple_instance() + assert 'Previous Simulation is still running' in str(excinfo.value) + sim2.quit() \ No newline at end of file diff --git a/myhdl/test/core/test_traceSignals.py b/myhdl/test/core/test_traceSignals.py index 7f79c00a..1fea552a 100644 --- a/myhdl/test/core/test_traceSignals.py +++ b/myhdl/test/core/test_traceSignals.py @@ -155,12 +155,16 @@ class TestTraceSigs: assert not path.exists(psub) def testTristateTrace(self, vcd_dir): - Simulation(topTristate()).run(100, quiet=QUIET) + sim = Simulation(topTristate()) + sim.run(100, quiet=QUIET) + sim.quit() def testBackupOutputFile(self, vcd_dir): p = "%s.vcd" % fun.__name__ dut = traceSignals(fun) - Simulation(dut).run(1000, quiet=QUIET) + sim = Simulation(dut) + sim.run(1000, quiet=QUIET) + sim.quit() _simulator._tf.close() _simulator._tracing = 0 size = path.getsize(p) From 48692d4c4a720ae92631edb525c34ed44ec82037 Mon Sep 17 00:00:00 2001 From: srivatsansoft Date: Wed, 24 Feb 2016 00:12:13 +0530 Subject: [PATCH 06/18] changed to instance counter instead of run counter --- myhdl/_Simulation.py | 15 +++++++-------- myhdl/test/bugs/test_issue_104.py | 12 ++++++------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/myhdl/_Simulation.py b/myhdl/_Simulation.py index e16b987b..8eba2190 100644 --- a/myhdl/_Simulation.py +++ b/myhdl/_Simulation.py @@ -45,6 +45,7 @@ class _error: _error.ArgType = "Inappriopriate argument type" _error.MultipleCosim = "Only a single cosimulator argument allowed" _error.DuplicatedArg = "Duplicated argument" +_error.MultipleSim = "Only a single Simulation instance is allowed" class Simulation(object): @@ -54,7 +55,7 @@ class Simulation(object): run -- run a simulation for some duration """ - _run_call_static = 0 + _no_of_instances = 0 def __init__(self, *args): """ Construct a simulation object. @@ -64,9 +65,12 @@ class Simulation(object): """ _simulator._time = 0 - self._run_call = 0 arglist = _flatten(*args) self._waiters, self._cosim = _makeWaiters(arglist) + if Simulation._no_of_instances>0: + Simulation._no_of_instances = 0 + raise SimulationError(_error.MultipleSim) + Simulation._no_of_instances += 1 if not self._cosim and _simulator._cosim: warn("Cosimulation not registered as Simulation argument") self._finished = False @@ -87,8 +91,7 @@ class Simulation(object): # clean up for potential new run with same signals for s in _signals: s._clear() - self._run_call = 0 - Simulation._run_call_static = 0 + Simulation._no_of_instances = 0 self._finished = True def quit(self): @@ -111,10 +114,6 @@ class Simulation(object): # From this point it will propagate to the caller, that can catch it. if self._finished: raise StopSimulation("Simulation has already finished") - if Simulation._run_call_static > self._run_call: - raise StopSimulation("Previous Simulation is still running") - Simulation._run_call_static += 1 - self._run_call += 1 waiters = self._waiters maxTime = None if duration: diff --git a/myhdl/test/bugs/test_issue_104.py b/myhdl/test/bugs/test_issue_104.py index da33f2c7..416bffa0 100644 --- a/myhdl/test/bugs/test_issue_104.py +++ b/myhdl/test/bugs/test_issue_104.py @@ -1,5 +1,5 @@ import pytest -from myhdl import Simulation, always, delay, Signal, intbv, StopSimulation +from myhdl import Simulation, always, delay, Signal, intbv, StopSimulation, SimulationError def clk_driver(clk, period=20): @@ -15,9 +15,8 @@ def issue_104_quit_method(): sim.run(500) sim.quit() return sim._finished -sim2 = None + def issue_104_multiple_instance(): - global sim2 clk = Signal(intbv(1)) sim = Simulation(clk_driver(clk)) sim.run(1000) @@ -28,7 +27,8 @@ def test_issue_104(): assert issue_104_quit_method() == True - with pytest.raises(StopSimulation) as excinfo: + with pytest.raises(SimulationError) as excinfo: issue_104_multiple_instance() - assert 'Previous Simulation is still running' in str(excinfo.value) - sim2.quit() \ No newline at end of file + assert 'Only a single Simulation instance is allowed' in str(excinfo.value) + + From 584e576b440e085351f60f91d51f3051ffa0d09b Mon Sep 17 00:00:00 2001 From: srivatsansoft Date: Wed, 24 Feb 2016 01:01:37 +0530 Subject: [PATCH 07/18] bug fix in _no_of_instance reset and test code updated --- myhdl/_Simulation.py | 3 +-- myhdl/test/bugs/test_issue_104.py | 45 ++++++++++++++++++------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/myhdl/_Simulation.py b/myhdl/_Simulation.py index 8eba2190..07014b8d 100644 --- a/myhdl/_Simulation.py +++ b/myhdl/_Simulation.py @@ -67,8 +67,7 @@ class Simulation(object): _simulator._time = 0 arglist = _flatten(*args) self._waiters, self._cosim = _makeWaiters(arglist) - if Simulation._no_of_instances>0: - Simulation._no_of_instances = 0 + if Simulation._no_of_instances > 0: raise SimulationError(_error.MultipleSim) Simulation._no_of_instances += 1 if not self._cosim and _simulator._cosim: diff --git a/myhdl/test/bugs/test_issue_104.py b/myhdl/test/bugs/test_issue_104.py index 416bffa0..c56eb1e9 100644 --- a/myhdl/test/bugs/test_issue_104.py +++ b/myhdl/test/bugs/test_issue_104.py @@ -1,34 +1,41 @@ import pytest -from myhdl import Simulation, always, delay, Signal, intbv, StopSimulation, SimulationError +from myhdl import Simulation, always, delay, Signal, intbv, StopSimulation, SimulationError, instance, now -def clk_driver(clk, period=20): - @always(delay(period/2)) - def drive_clk(): - clk.next = not clk - return drive_clk +def test(): + @instance + def tbstim(): + yield delay(10) + print("{:<8d} ".format(now())) + yield delay(1000) + print("{:<8d} ".format(now())) + for _ in range(10): + yield delay(1000) + + return tbstim + def issue_104_quit_method(): - clk = Signal(intbv(1)) - sim = Simulation(clk_driver(clk)) + sim = Simulation(test()) sim.run(1000) sim.run(500) sim.quit() return sim._finished def issue_104_multiple_instance(): - clk = Signal(intbv(1)) - sim = Simulation(clk_driver(clk)) - sim.run(1000) - sim2 = Simulation(clk_driver(clk)) - sim2.run(10) + sim1 = Simulation(test()) + sim1.run(1000) + # sim1 is "puased" + + # try and create a second, third, forth simulation instance + for ii in range(4): + with pytest.raises(SimulationError) as excinfo: + another_sim = Simulation(test()) + assert 'Only a single Simulation instance is allowed' in str(excinfo.value) + # generating more sims should have failed + sim1.run(1000) def test_issue_104(): - assert issue_104_quit_method() == True - - with pytest.raises(SimulationError) as excinfo: - issue_104_multiple_instance() - assert 'Only a single Simulation instance is allowed' in str(excinfo.value) - + issue_104_multiple_instance() From 3f245896fcdef24d8985215c1e0cc1ece1eaab05 Mon Sep 17 00:00:00 2001 From: srivatsansoft Date: Wed, 24 Feb 2016 20:32:48 +0530 Subject: [PATCH 08/18] replaced pytest.raises with raises_kind for consistency --- myhdl/test/bugs/test_issue_104.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/myhdl/test/bugs/test_issue_104.py b/myhdl/test/bugs/test_issue_104.py index c56eb1e9..b1e10a58 100644 --- a/myhdl/test/bugs/test_issue_104.py +++ b/myhdl/test/bugs/test_issue_104.py @@ -1,6 +1,7 @@ import pytest -from myhdl import Simulation, always, delay, Signal, intbv, StopSimulation, SimulationError, instance, now - +from myhdl import Simulation, delay, SimulationError, instance, now +from myhdl._Simulation import _error +from helpers import raises_kind def test(): @instance @@ -29,13 +30,13 @@ def issue_104_multiple_instance(): # try and create a second, third, forth simulation instance for ii in range(4): - with pytest.raises(SimulationError) as excinfo: + with raises_kind(SimulationError, _error.MultipleSim): another_sim = Simulation(test()) - assert 'Only a single Simulation instance is allowed' in str(excinfo.value) # generating more sims should have failed sim1.run(1000) + sim1.quit() def test_issue_104(): + assert issue_104_quit_method() == True issue_104_multiple_instance() - From 8f0678bdea85317d8a4633cdf50609af5e8c9deb Mon Sep 17 00:00:00 2001 From: srivatsansoft Date: Wed, 24 Feb 2016 21:31:48 +0530 Subject: [PATCH 09/18] added 'from __future__ import print_function' --- myhdl/test/bugs/test_issue_104.py | 1 + 1 file changed, 1 insertion(+) diff --git a/myhdl/test/bugs/test_issue_104.py b/myhdl/test/bugs/test_issue_104.py index b1e10a58..7dbfb81b 100644 --- a/myhdl/test/bugs/test_issue_104.py +++ b/myhdl/test/bugs/test_issue_104.py @@ -1,3 +1,4 @@ +from __future__ import print_function import pytest from myhdl import Simulation, delay, SimulationError, instance, now from myhdl._Simulation import _error From 41081e381705e9fed7177a5ff434c3d825eb40ba Mon Sep 17 00:00:00 2001 From: srivatsansoft Date: Wed, 24 Feb 2016 21:52:38 +0530 Subject: [PATCH 10/18] supporting python 2.6 --- myhdl/test/bugs/test_issue_104.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myhdl/test/bugs/test_issue_104.py b/myhdl/test/bugs/test_issue_104.py index 7dbfb81b..9734d29b 100644 --- a/myhdl/test/bugs/test_issue_104.py +++ b/myhdl/test/bugs/test_issue_104.py @@ -8,9 +8,9 @@ def test(): @instance def tbstim(): yield delay(10) - print("{:<8d} ".format(now())) + print("{0:<8d} ".format(now())) yield delay(1000) - print("{:<8d} ".format(now())) + print("{0:<8d} ".format(now())) for _ in range(10): yield delay(1000) From 62aa73f2c27a0485adb99a680307e902f2bec6dd Mon Sep 17 00:00:00 2001 From: Jan Decaluwe Date: Tue, 1 Mar 2016 16:06:29 +0100 Subject: [PATCH 11/18] Moved to 2008 version of ghdl - requires 0.33, expect travis fail --- myhdl/conversion/_verify.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/myhdl/conversion/_verify.py b/myhdl/conversion/_verify.py index 34e4192f..caac3098 100644 --- a/myhdl/conversion/_verify.py +++ b/myhdl/conversion/_verify.py @@ -22,7 +22,7 @@ _simulators = {} sim = namedtuple('sim', 'name hdl analyze elaborate simulate skiplines skipchars ignore') -def registerSimulator(name=None, hdl=None, analyze=None, elaborate=None, simulate=None, +def registerSimulator(name=None, hdl=None, analyze=None, elaborate=None, simulate=None, skiplines=None, skipchars=None, ignore=None): if not isinstance(name, str) or (name.strip() == ""): raise ValueError("Invalid simulator name") @@ -41,8 +41,8 @@ def registerSimulator(name=None, hdl=None, analyze=None, elaborate=None, simulat registerSimulator( name="ghdl", hdl="VHDL", - analyze="ghdl -a --workdir=work pck_myhdl_%(version)s.vhd %(topname)s.vhd", - elaborate="ghdl -e --workdir=work -o %(unitname)s %(topname)s", + analyze="ghdl -a --std=08 --workdir=work pck_myhdl_%(version)s.vhd %(topname)s.vhd", + elaborate="ghdl -e --std=08 --workdir=work %(unitname)s", simulate="ghdl -r --workdir=work %(unitname)s" ) @@ -96,7 +96,7 @@ class _VerificationClass(object): __slots__ = ("simulator", "_analyzeOnly") def __init__(self, analyzeOnly=False): - self.simulator = None + self.simulator = None self._analyzeOnly = analyzeOnly @@ -178,7 +178,7 @@ class _VerificationClass(object): if ret != 0: print("Elaboration failed", file=sys.stderr) return ret - + g = tempfile.TemporaryFile(mode='w+t') #print(simulate) ret = subprocess.call(simulate, stdout=g, shell=True) From e1e9ada5e808c96207e61770650a7e675d7bc411 Mon Sep 17 00:00:00 2001 From: Jan Decaluwe Date: Tue, 1 Mar 2016 17:25:23 +0100 Subject: [PATCH 12/18] Try ghdl 0.33 in travis --- .travis.yml | 12 +++++++++--- scripts/install_ghdl.sh | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 scripts/install_ghdl.sh diff --git a/.travis.yml b/.travis.yml index 35fbacdb..914ebe81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,13 +9,19 @@ python: - "3.4" - "3.5" +# binary install as per travis instructions +# used to install latest version of ghdl +before_script: + - ./scripts/install_ghdl.sh + - export PATH=$PATH:$PWD/ghdl-0.33/bin/ + addons: apt: - sources: - - pgavin-ghdl + # sources: + # - pgavin-ghdl packages: - iverilog - - ghdl + # - ghdl install: - pip install . diff --git a/scripts/install_ghdl.sh b/scripts/install_ghdl.sh new file mode 100644 index 00000000..5104f226 --- /dev/null +++ b/scripts/install_ghdl.sh @@ -0,0 +1,5 @@ +#!/bin/bash# +set -evx +wget https://sourceforge.net/projects/ghdl-updates/files/Builds/ghdl-0.33/debian/ghdl_0.33-1ubuntu1_amd64.deb -O /tmp/ghdl.tar.gz +mkdir ghdl-0.33 +tar -C ghdl-0.33 -xvf /tmp/ghdl.tar.gz From 8aa54b797fa511946490bdf7efc1b4f05b7b5e5d Mon Sep 17 00:00:00 2001 From: Jan Decaluwe Date: Tue, 1 Mar 2016 17:59:28 +0100 Subject: [PATCH 13/18] script execution mode --- scripts/install_ghdl.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/install_ghdl.sh diff --git a/scripts/install_ghdl.sh b/scripts/install_ghdl.sh old mode 100644 new mode 100755 From b81450ead2d36586cb67d645d559b907bd4ac5d9 Mon Sep 17 00:00:00 2001 From: Jan Decaluwe Date: Tue, 1 Mar 2016 18:02:21 +0100 Subject: [PATCH 14/18] typo --- scripts/install_ghdl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_ghdl.sh b/scripts/install_ghdl.sh index 5104f226..ccb82e67 100755 --- a/scripts/install_ghdl.sh +++ b/scripts/install_ghdl.sh @@ -1,4 +1,4 @@ -#!/bin/bash# +#!/bin/bash set -evx wget https://sourceforge.net/projects/ghdl-updates/files/Builds/ghdl-0.33/debian/ghdl_0.33-1ubuntu1_amd64.deb -O /tmp/ghdl.tar.gz mkdir ghdl-0.33 From bb2882a6d0dac5fa33ddb81cc2d3fbd9ec031ec0 Mon Sep 17 00:00:00 2001 From: Jan Decaluwe Date: Tue, 1 Mar 2016 19:42:54 +0100 Subject: [PATCH 15/18] Actually select the binary distro for Ubuntu 12.04 --- scripts/install_ghdl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_ghdl.sh b/scripts/install_ghdl.sh index ccb82e67..ef655d42 100755 --- a/scripts/install_ghdl.sh +++ b/scripts/install_ghdl.sh @@ -1,5 +1,5 @@ #!/bin/bash set -evx -wget https://sourceforge.net/projects/ghdl-updates/files/Builds/ghdl-0.33/debian/ghdl_0.33-1ubuntu1_amd64.deb -O /tmp/ghdl.tar.gz +wget https://sourceforge.net/projects/ghdl-updates/files/Builds/ghdl-0.33/ghdl-0.33-x86_64-linux.tgz -O /tmp/ghdl.tar.gz mkdir ghdl-0.33 tar -C ghdl-0.33 -xvf /tmp/ghdl.tar.gz From c6613238b979854a668ea7bf2bce6c4d7f1bdae2 Mon Sep 17 00:00:00 2001 From: Jan Decaluwe Date: Wed, 2 Mar 2016 12:03:47 +0100 Subject: [PATCH 16/18] Must be dead code, no impact on test suite --- myhdl/conversion/_toVHDL.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/myhdl/conversion/_toVHDL.py b/myhdl/conversion/_toVHDL.py index dca792e1..96d451f8 100644 --- a/myhdl/conversion/_toVHDL.py +++ b/myhdl/conversion/_toVHDL.py @@ -654,10 +654,6 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin): self.shiftOp(node) elif isinstance(node.op, (ast.BitAnd, ast.BitOr, ast.BitXor)): self.BitOp(node) - elif isinstance(node.op, ast.Mod) and (self.context == _context.PRINT): - self.visit(node.left) - self.write(", ") - self.visit(node.right) else: self.BinOp(node) @@ -1362,9 +1358,7 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin): elif isinstance(a.vhdOri, vhd_enum): a.vhd = vhd_string() self.write("write(L, ") - self.context = _context.PRINT self.visit(a) - self.context = None if s.justified == 'LEFT': self.write(", justified=>LEFT") if s.width: From 28533d2541e406facf84d8569784c5e7a4c7f558 Mon Sep 17 00:00:00 2001 From: Jan Decaluwe Date: Wed, 2 Mar 2016 16:44:19 +0100 Subject: [PATCH 17/18] Move to use VHDL 2008's to_string --- myhdl/conversion/_analyze.py | 8 +++++++- myhdl/conversion/_toVHDL.py | 23 +++++++++-------------- myhdl/conversion/_toVerilog.py | 8 ++------ 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/myhdl/conversion/_analyze.py b/myhdl/conversion/_analyze.py index c8d94957..744db3a0 100644 --- a/myhdl/conversion/_analyze.py +++ b/myhdl/conversion/_analyze.py @@ -578,10 +578,14 @@ class _AnalyzeVisitor(ast.NodeVisitor, _ConversionMixin): node.obj = int(0) # XXX elif f is bool: node.obj = bool() - elif f in _flatten(integer_types, ord): + elif f in _flatten(integer_types): node.obj = int(-1) ## elif f in (posedge , negedge): ## node.obj = _EdgeDetector() + elif f is ord: + node.obj = int(-1) + if not (isinstance(node.args[0], ast.Str) and (len(node.args[0].s) == 1)): + self.raiseError(node, _error.NotSupported, "ord: expect string argument with length 1") elif f is delay: node.obj = delay(0) ### suprize: identity comparison on unbound methods doesn't work in python 2.5?? @@ -915,6 +919,8 @@ class _AnalyzeVisitor(ast.NodeVisitor, _ConversionMixin): s = s[m.end():] continue self.raiseError(node, _error.UnsupportedFormatString, "%s" % s) + elif isinstance(n, ast.Str): + f.append(n.s) else: f.append(defaultConvSpec) a.append(n) diff --git a/myhdl/conversion/_toVHDL.py b/myhdl/conversion/_toVHDL.py index 96d451f8..dcb9c4a1 100644 --- a/myhdl/conversion/_toVHDL.py +++ b/myhdl/conversion/_toVHDL.py @@ -602,9 +602,9 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin): pre, suf = "", "(0)" else: pre, suf = "stdl(", ")" - elif isinstance(vhd, vhd_string): - if isinstance(ori, vhd_enum): - pre, suf = "%s'image(" % ori._type._name, ")" + # elif isinstance(vhd, vhd_string): + # if isinstance(ori, vhd_enum): + # pre, suf = "%s'image(" % ori._type._name, ")" return pre, suf @@ -949,11 +949,10 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin): return elif f is ord: opening, closing = '', '' - if isinstance(node.args[0], ast.Str): - if len(node.args[0].s) > 1: - self.raiseError(node, _error.UnsupportedType, "Strings with length > 1" ) - else: - node.args[0].s = ord(node.args[0].s) + v = ord(node.args[0].s) + node.args[0].s = v + self.write(v) + return elif f in integer_types: opening, closing = '', '' pre, suf = self.inferCast(node.vhd, node.vhdOri) @@ -1357,13 +1356,9 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin): a.vhd = vhd_boolean() elif isinstance(a.vhdOri, vhd_enum): a.vhd = vhd_string() - self.write("write(L, ") + self.write("write(L, to_string(") self.visit(a) - if s.justified == 'LEFT': - self.write(", justified=>LEFT") - if s.width: - self.write(", field=>%s" % s.width) - self.write(")") + self.write("))") self.write(';') self.writeline() self.write("writeline(output, L);") diff --git a/myhdl/conversion/_toVerilog.py b/myhdl/conversion/_toVerilog.py index be213ea7..b533054a 100644 --- a/myhdl/conversion/_toVerilog.py +++ b/myhdl/conversion/_toVerilog.py @@ -151,7 +151,7 @@ class _ToVerilogConvertor(object): genlist = _analyzeGens(arglist, h.absnames) siglist, memlist = _analyzeSigs(h.hierarchy) _annotateTypes(genlist) - + intf = _analyzeTopFunc(func, *args, **kwargs) intf.name = name doc = _makeDoc(inspect.getdoc(func)) @@ -750,11 +750,7 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin): return elif f is ord: opening, closing = '', '' - if isinstance(node.args[0], ast.Str): - if len(node.args[0].s) > 1: - self.raiseError(node, _error.UnsupportedType, "Strings with length > 1") - else: - node.args[0].s = str(ord(node.args[0].s)) + node.args[0].s = str(ord(node.args[0].s)) elif f in integer_types: opening, closing = '', '' # convert number argument to integer From 8e69e0f334d8b675fd5f1b6ecbfc78532ff54289 Mon Sep 17 00:00:00 2001 From: srivatsansoft Date: Thu, 3 Mar 2016 07:46:19 +0530 Subject: [PATCH 18/18] updated doc for the new public method sim.quit() --- doc/source/manual/reference.rst | 8 ++++++++ example/cookbook/dff/dff.py | 1 + example/cookbook/dffa/dffa.py | 1 + example/cookbook/latch/latch.py | 1 + 4 files changed, 11 insertions(+) diff --git a/doc/source/manual/reference.rst b/doc/source/manual/reference.rst index f3842684..53ef0163 100644 --- a/doc/source/manual/reference.rst +++ b/doc/source/manual/reference.rst @@ -41,6 +41,14 @@ A :class:`Simulation` object has the following method: Run the simulation forever (by default) or for a specified duration. +.. method:: Simulation.quit() + + Quit the simulation after it has run for a specified duration. The method should + be called (the simulation instance must be quit) before another simulation + instance is created. The method is called by default when the simulation is run + forever. + + .. _ref-simsupport: Simulation support functions diff --git a/example/cookbook/dff/dff.py b/example/cookbook/dff/dff.py index ecd18d71..e69fcd45 100644 --- a/example/cookbook/dff/dff.py +++ b/example/cookbook/dff/dff.py @@ -33,6 +33,7 @@ def simulate(timesteps): tb = traceSignals(test_dff) sim = Simulation(tb) sim.run(timesteps) + sim.quit() simulate(2000) diff --git a/example/cookbook/dffa/dffa.py b/example/cookbook/dffa/dffa.py index ac6e66bb..be0da586 100644 --- a/example/cookbook/dffa/dffa.py +++ b/example/cookbook/dffa/dffa.py @@ -44,6 +44,7 @@ def simulate(timesteps): tb = traceSignals(test_dffa) sim = Simulation(tb) sim.run(timesteps) + sim.quit() simulate(20000) diff --git a/example/cookbook/latch/latch.py b/example/cookbook/latch/latch.py index 9ab1b3b6..7439357d 100644 --- a/example/cookbook/latch/latch.py +++ b/example/cookbook/latch/latch.py @@ -33,6 +33,7 @@ def simulate(timesteps): tb = traceSignals(test_latch) sim = Simulation(tb) sim.run(timesteps) + sim.quit() simulate(20000)