Skip to content

Commit a8766a5

Browse files
committed
Parse rule of variable without width is modified. The previous implementation appends [0:0] as implicit data width for variables without width field. The current implementation appends None instead of [0:0]. Analysis rule in dataflow is modified as well.
1 parent 0febcce commit a8766a5

File tree

9 files changed

+13
-60
lines changed

9 files changed

+13
-60
lines changed

pyverilog/dataflow/bindvisitor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,8 @@ def searchTaskPorts(self, name, scope):
807807
def makeConstantTerm(self, name, node, scope):
808808
termtype = node.__class__.__name__
809809
termtypes = set([termtype])
810-
msb = DFEvalValue(31) if node.width is None else self.makeDFTree(node.width.msb, scope)
811-
lsb = DFEvalValue(0) if node.width is None else self.makeDFTree(node.width.lsb, scope)
810+
msb = DFIntConst('31') if node.width is None else self.makeDFTree(node.width.msb, scope)
811+
lsb = DFIntConst('0') if node.width is None else self.makeDFTree(node.width.lsb, scope)
812812
return Term(name, termtypes, msb, lsb)
813813

814814
def addTerm(self, node, rscope=None):
@@ -821,8 +821,12 @@ def addTerm(self, node, rscope=None):
821821
if self.frames.isTaskcall(): termtype = 'Task'
822822
termtypes = set([termtype])
823823

824-
msb = DFEvalValue(31) if node.width is None else self.makeDFTree(node.width.msb, scope)
825-
lsb = DFEvalValue(0) if node.width is None else self.makeDFTree(node.width.lsb, scope)
824+
if isinstance(node, (Parameter, Localparam)):
825+
msb = DFIntConst('31') if node.width is None else self.makeDFTree(node.width.msb, scope)
826+
else:
827+
msb = DFIntConst('0') if node.width is None else self.makeDFTree(node.width.msb, scope)
828+
lsb = DFIntConst('0') if node.width is None else self.makeDFTree(node.width.lsb, scope)
829+
826830
lenmsb = None
827831
lenlsb = None
828832
if isinstance(node, RegArray) or isinstance(node, WireArray):

pyverilog/dataflow/signalvisitor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,8 @@ def searchConstantValue(self, key, name):
477477
def makeConstantTerm(self, name, node, scope):
478478
termtype = node.__class__.__name__
479479
termtypes = set([termtype])
480-
msb = DFEvalValue(31) if node.width is None else self.makeDFTree(node.width.msb, scope)
481-
lsb = DFEvalValue(0) if node.width is None else self.makeDFTree(node.width.lsb, scope)
480+
msb = DFIntConst('31') if node.width is None else self.makeDFTree(node.width.msb, scope)
481+
lsb = DFIntConst('0') if node.width is None else self.makeDFTree(node.width.lsb, scope)
482482
return Term(name, termtypes, msb, lsb)
483483

484484
def getTree(self, node, scope):

pyverilog/vparser/ast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class Variable(Value):
166166
attr_names = ('name', 'signed')
167167
def __init__(self, name, width=None, signed=False):
168168
self.name = name
169-
self.width = width if width else Width(IntConst('0'),IntConst('0'))
169+
self.width = width
170170
self.signed = signed
171171
def children(self):
172172
nodelist = []
@@ -223,7 +223,7 @@ class Parameter(Node):
223223
def __init__(self, name, value, width=None, signed=False):
224224
self.name = name
225225
self.value = value
226-
self.width = width #if width else Width(msb=IntConst('31'),lsb=IntConst('0'))
226+
self.width = width
227227
self.signed = signed
228228
def children(self):
229229
nodelist = []

pyverilog/vparser/parser.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ def p_ioports_one(self, p):
272272
p[0] = (p[1],)
273273

274274
def ioport_create(self, sigtypes, name, width=None):
275-
width = Width(IntConst('0'),IntConst('0')) if width is None else width
276275
self.ioport_typecheck(sigtypes)
277276
first = None
278277
second = None
@@ -377,7 +376,6 @@ def p_standard_item(self, p):
377376

378377
# Signal Decl
379378
def decl_create(self, sigtypes, name, width=None, length=None):
380-
width = Width(msb=IntConst('0'), lsb=IntConst('0')) if width is None else width
381379
self.decl_typecheck(sigtypes, length)
382380
decls = []
383381
signed = False
@@ -465,7 +463,6 @@ def p_declarray(self, p):
465463

466464
# Decl and Assign
467465
def declassign_create(self, sigtypes, name, assign, width=None):
468-
width = Width(msb=IntConst('0'), lsb=IntConst('0')) if width is None else width
469466
self.declassign_typecheck(sigtypes)
470467
decls = []
471468
signed = False

tests/dataflow_test/test_led.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
(Term name:led.CLK type:['Input'] msb:(IntConst 0) lsb:(IntConst 0))
1313
(Term name:led.LED type:['Output', 'Reg'] msb:(IntConst 7) lsb:(IntConst 0))
1414
(Term name:led.RST type:['Input'] msb:(IntConst 0) lsb:(IntConst 0))
15-
(Term name:led.STEP type:['Parameter'] msb:'d31 lsb:'d0)
15+
(Term name:led.STEP type:['Parameter'] msb:(IntConst 31) lsb:(IntConst 0))
1616
(Term name:led.count type:['Reg'] msb:(IntConst 31) lsb:(IntConst 0))
1717
Bind:
1818
(Bind dest:led.LED tree:(Branch Cond:(Terminal led.RST) True:(IntConst 0) False:(Branch Cond:(Operator Eq Next:(Terminal led.count),(Operator Minus Next:(Terminal led.STEP),(IntConst 1))) True:(Operator Plus Next:(Terminal led.LED),(IntConst 1)))))

tests/parser_test/test_delay.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@
2121
Portlist:
2222
Ioport:
2323
Input: CLK, False
24-
Width:
25-
IntConst: 0
26-
IntConst: 0
2724
Ioport:
2825
Input: RST, False
29-
Width:
30-
IntConst: 0
31-
IntConst: 0
3226
Ioport:
3327
Output: LED, False
3428
Width:

tests/parser_test/test_escape.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,9 @@
2020
Port: \\1234RST*%&, None
2121
Decl:
2222
Input: \\CLK~, False
23-
Width:
24-
IntConst: 0
25-
IntConst: 0
2623
Input: \\1234RST*%&, False
27-
Width:
28-
IntConst: 0
29-
IntConst: 0
3024
Decl:
3125
Output: LE$D, False
32-
Width:
33-
IntConst: 0
34-
IntConst: 0
3526
Decl:
3627
Genvar: i, False
3728
Width:

tests/parser_test/test_instance_array.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,10 @@
3737
IntConst: 0
3838
Ioport:
3939
Input: in3, False
40-
Width:
41-
IntConst: 0
42-
IntConst: 0
4340
Ioport:
4441
Input: in4, False
45-
Width:
46-
IntConst: 0
47-
IntConst: 0
4842
Ioport:
4943
Input: in5, False
50-
Width:
51-
IntConst: 0
52-
IntConst: 0
5344
Ioport:
5445
Output: LED0, False
5546
Width:
@@ -72,14 +63,8 @@
7263
IntConst: 0
7364
Ioport:
7465
Output: LED4, False
75-
Width:
76-
IntConst: 0
77-
IntConst: 0
7866
Ioport:
7967
Output: LED5, False
80-
Width:
81-
IntConst: 0
82-
IntConst: 0
8368
InstanceList: SUB
8469
ParamArg: MODE
8570
IntConst: 0
@@ -191,14 +176,8 @@
191176
Portlist:
192177
Ioport:
193178
Input: VAL, False
194-
Width:
195-
IntConst: 0
196-
IntConst: 0
197179
Ioport:
198180
Output: LED, False
199-
Width:
200-
IntConst: 0
201-
IntConst: 0
202181
Assign:
203182
Lvalue:
204183
Identifier: LED

tests/parser_test/test_led_main.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@
2121
Portlist:
2222
Ioport:
2323
Input: CLK, False
24-
Width:
25-
IntConst: 0
26-
IntConst: 0
2724
Ioport:
2825
Input: RST, False
29-
Width:
30-
IntConst: 0
31-
IntConst: 0
3226
Ioport:
3327
Output: LED, False
3428
Width:
@@ -94,14 +88,8 @@
9488
Portlist:
9589
Ioport:
9690
Input: CLK, False
97-
Width:
98-
IntConst: 0
99-
IntConst: 0
10091
Ioport:
10192
Input: RST, False
102-
Width:
103-
IntConst: 0
104-
IntConst: 0
10593
Ioport:
10694
Output: LED, False
10795
Width:

0 commit comments

Comments
 (0)