sim.pysim: refuse to write VCD files with whitespace in signal names.
Closes #595.
This commit is contained in:
parent
b452e0e871
commit
66295fa388
|
@ -1,5 +1,6 @@
|
|||
from contextlib import contextmanager
|
||||
import itertools
|
||||
import re
|
||||
from vcd import VCDWriter
|
||||
from vcd.gtkw import GTKWSave
|
||||
|
||||
|
@ -94,6 +95,10 @@ class _VCDWriter:
|
|||
var_init = signal.reset
|
||||
|
||||
for (*var_scope, var_name) in names:
|
||||
if re.search(r"[ \t\r\n]", var_name):
|
||||
raise NameError("Signal '{}.{}' contains a whitespace character"
|
||||
.format(".".join(var_scope), var_name))
|
||||
|
||||
suffix = None
|
||||
while True:
|
||||
try:
|
||||
|
|
|
@ -806,8 +806,9 @@ class SimulatorIntegrationTestCase(FHDLTestCase):
|
|||
sim.run_until(1e-5)
|
||||
with self.assertRaisesRegex(ValueError,
|
||||
r"^Cannot start writing waveforms after advancing simulation time$"):
|
||||
with sim.write_vcd(open(os.path.devnull, "wt")):
|
||||
pass
|
||||
with open(os.path.devnull, "w") as f:
|
||||
with sim.write_vcd(f):
|
||||
pass
|
||||
|
||||
|
||||
class SimulatorRegressionTestCase(FHDLTestCase):
|
||||
|
@ -827,3 +828,15 @@ class SimulatorRegressionTestCase(FHDLTestCase):
|
|||
self.assertEqual((yield -(Const(0b11, 2).as_signed())), 1)
|
||||
sim.add_process(process)
|
||||
sim.run()
|
||||
|
||||
def test_bug_595(self):
|
||||
dut = Module()
|
||||
with dut.FSM(name="name with space"):
|
||||
with dut.State(0):
|
||||
pass
|
||||
sim = Simulator(dut)
|
||||
with self.assertRaisesRegex(NameError,
|
||||
r"^Signal 'top\.name with space_state' contains a whitespace character$"):
|
||||
with open(os.path.devnull, "w") as f:
|
||||
with sim.write_vcd(f):
|
||||
sim.run()
|
||||
|
|
Loading…
Reference in a new issue