from contextlib import contextmanager
import itertools
+import re
from vcd import VCDWriter
from vcd.gtkw import GTKWSave
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:
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):
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()