Skip to content

Commit 0f947a3

Browse files
committed
Merge pull request #28 from metanest/case_insensitive_in_literal_spike
Thank you for your contribution! "change literals case insencitiveness"
2 parents 1ae9650 + 50f2bf6 commit 0f947a3

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

pyverilog/dataflow/dataflow.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,34 +120,34 @@ def tostr(self):
120120
def eval(self):
121121
targ = self.value.replace('_','')
122122
signed = False
123-
match = re.search(r's(.+)', targ)
123+
match = re.search(r'[Ss](.+)', targ)
124124
if match is not None:
125125
signed = True
126-
match = re.search(r'h(.+)', targ)
126+
match = re.search(r'[Hh](.+)', targ)
127127
if match is not None:
128128
return int(match.group(1), 16)
129-
match = re.search(r'd(.+)', targ)
129+
match = re.search(r'[Dd](.+)', targ)
130130
if match is not None:
131131
return int(match.group(1), 10)
132-
match = re.search(r'o(.+)', targ)
132+
match = re.search(r'[Oo](.+)', targ)
133133
if match is not None:
134134
return int(match.group(1), 8)
135-
match = re.search(r'b(.+)', targ)
135+
match = re.search(r'[Bb](.+)', targ)
136136
if match is not None:
137137
return int(match.group(1), 2)
138138
return int(targ, 10)
139139
def width(self):
140140
targ = self.value.replace('_','')
141-
match = re.search(r'(.+)\'h.+', targ)
141+
match = re.search(r'(.+)\'[Hh].+', targ)
142142
if match is not None:
143143
return int(match.group(1), 10)
144-
match = re.search(r'(.+)\'d.+', targ)
144+
match = re.search(r'(.+)\'[Dd].+', targ)
145145
if match is not None:
146146
return int(match.group(1), 10)
147-
match = re.search(r'(.+)\'o.+', targ)
147+
match = re.search(r'(.+)\'[Oo].+', targ)
148148
if match is not None:
149149
return int(match.group(1), 10)
150-
match = re.search(r'(.+)\'b.+', targ)
150+
match = re.search(r'(.+)\'[Bb].+', targ)
151151
if match is not None:
152152
return int(match.group(1), 10)
153153
return 32

pyverilog/dataflow/optimizer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def optimizeConstant(self, tree):
8787
if isinstance(tree, DFIntConst):
8888
if 'x' in tree.value or 'z' in tree.value:
8989
return DFUndefined(tree.width())
90+
if 'X' in tree.value or 'Z' in tree.value:
91+
return DFUndefined(tree.width())
9092
return DFEvalValue(tree.eval(), tree.width())
9193
if isinstance(tree, DFFloatConst):
9294
return DFEvalValue(tree.eval(), self.default_width, isfloat=True)
@@ -95,6 +97,8 @@ def optimizeConstant(self, tree):
9597
if isinstance(tree, DFConstant):
9698
if 'x' in tree.value or 'z' in tree.value:
9799
return DFUndefined()
100+
if 'X' in tree.value or 'Z' in tree.value:
101+
return DFUndefined()
98102
return DFEvalValue(tree.eval(), self.default_width)
99103

100104
if isinstance(tree, DFOperator):

0 commit comments

Comments
 (0)