1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00

Merge pull request #277 from josyb/enum

enum: added string output for enums in _traceSignals.py
This commit is contained in:
Christopher Felton 2019-05-19 14:57:55 -05:00 committed by GitHub
commit e37ec45008
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,6 @@
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function from __future__ import print_function
import sys import sys
import time import time
import os import os
@ -45,6 +44,8 @@ vcdpath = ''
class _error: class _error:
pass pass
_error.TopLevelName = "result of traceSignals call should be assigned to a top level name" _error.TopLevelName = "result of traceSignals call should be assigned to a top level name"
_error.ArgType = "traceSignals first argument should be a classic function" _error.ArgType = "traceSignals first argument should be a classic function"
_error.MultipleTraces = "Cannot trace multiple instances simultaneously" _error.MultipleTraces = "Cannot trace multiple instances simultaneously"
@ -138,8 +139,8 @@ class _TraceSignalsClass(object):
return h.top return h.top
traceSignals = _TraceSignalsClass()
traceSignals = _TraceSignalsClass()
_codechars = "" _codechars = ""
for i in range(33, 127): for i in range(33, 127):
@ -212,11 +213,19 @@ def _writeVcdSigs(f, hierarchy, tracelists):
siglist.append(s) siglist.append(s)
w = s._nrbits w = s._nrbits
# use real for enum strings # use real for enum strings
if w and not isinstance(sval, EnumItemType): if w:
if w == 1: if not isinstance(sval, EnumItemType):
print("$var reg 1 %s %s $end" % (s._code, n), file=f) if w == 1:
print("$var reg 1 %s %s $end" % (s._code, n), file=f)
else:
print("$var reg %s %s %s $end" % (w, s._code, n), file=f)
else: else:
print("$var reg %s %s %s $end" % (w, s._code, n), file=f) # 18-04-2014 jb
# it is an enum, and as Impulse doesn't know the awkward 'real' representation yet, so let's 'degrade' it to a binary type
# 30-04-2014 jb
# Impulse now has a 'string'type
print("$var string %s %s %s $end" % (w, s._code, n), file=f)
# print "30-04-2014 jb: Representing enum as string" # leave a trace
else: else:
print("$var real 1 %s %s $end" % (s._code, n), file=f) print("$var real 1 %s %s $end" % (s._code, n), file=f)
# Memory dump by Frederik Teichert, http://teichert-ing.de, date: 2011.03.28 # Memory dump by Frederik Teichert, http://teichert-ing.de, date: 2011.03.28