File tree Expand file tree Collapse file tree 1 file changed +170
-2
lines changed Expand file tree Collapse file tree 1 file changed +170
-2
lines changed Original file line number Diff line number Diff line change 1+ # prefer output name
2+ design -reset
3+ read_rtlil <<EOT
4+ module \top
5+ wire output 3 \y
6+ wire input 1 \a
7+ wire input 2 \b
8+ cell $and $name
9+ parameter \A_SIGNED 0
10+ parameter \A_WIDTH 1
11+ parameter \B_SIGNED 0
12+ parameter \B_WIDTH 1
13+ parameter \Y_WIDTH 1
14+ connect \A \a
15+ connect \B \b
16+ connect \Y \y
17+ end
18+ end
19+ EOT
20+ logger -expect log "Rename cell .name in top to y_.and_Y" 1
21+ debug autoname
22+ logger -check-expected
23+
24+ # fallback to shortest name if output is private
25+ design -reset
126read_rtlil <<EOT
227autoidx 2
328module \top
429 wire output 3 $y
30+ wire input 1 \ab
31+ wire input 2 \abcd
32+ cell $or $name
33+ parameter \A_SIGNED 0
34+ parameter \A_WIDTH 1
35+ parameter \B_SIGNED 0
36+ parameter \B_WIDTH 1
37+ parameter \Y_WIDTH 1
38+ connect \A \ab
39+ connect \B \abcd
40+ connect \Y $y
41+ end
42+ end
43+ EOT
44+ logger -expect log "Rename cell .name in top to ab_.or_A" 1
45+ debug autoname
46+ logger -check-expected
47+
48+ # prefer low fanout over low name length
49+ design -reset
50+ read_rtlil <<EOT
51+ module \top
52+ wire output 1 $y
53+ wire input 2 \a
54+ wire input 3 \bcd
55+ wire input 4 \c_has_a_long_name
56+ cell $and $name
57+ parameter \A_SIGNED 0
58+ parameter \A_WIDTH 1
59+ parameter \B_SIGNED 0
60+ parameter \B_WIDTH 1
61+ parameter \Y_WIDTH 1
62+ connect \A \a
63+ connect \B \bcd
64+ connect \Y $y
65+ end
66+
67+ cell $or $name2
68+ parameter \A_SIGNED 0
69+ parameter \A_WIDTH 1
70+ parameter \B_SIGNED 0
71+ parameter \B_WIDTH 1
72+ parameter \Y_WIDTH 1
73+ connect \A \a
74+ connect \B \c_has_a_long_name
75+ connect \Y $y
76+ end
77+ end
78+ EOT
79+ logger -expect log "Rename cell .name in top to bcd_.and_B" 1
80+ logger -expect log "Rename cell .name2 in top to c_has_a_long_name_.or_B" 1
81+ debug autoname
82+ logger -check-expected
83+
84+ # names are unique
85+ design -reset
86+ read_rtlil <<EOT
87+ module \top
88+ wire output 3 \y
589 wire input 1 \a
690 wire input 2 \b
7- cell $and \b_$and_B
91+ cell $and $name
92+ parameter \A_SIGNED 0
93+ parameter \A_WIDTH 1
94+ parameter \B_SIGNED 0
95+ parameter \B_WIDTH 1
96+ parameter \Y_WIDTH 1
97+ connect \A \a
98+ connect \B \b
99+ connect \Y \y
100+ end
101+
102+ cell $and $name2
8103 parameter \A_SIGNED 0
9104 parameter \A_WIDTH 1
10105 parameter \B_SIGNED 0
11106 parameter \B_WIDTH 1
12107 parameter \Y_WIDTH 1
13108 connect \A \a
14109 connect \B \b
110+ connect \Y \y
111+ end
112+ end
113+ EOT
114+ logger -expect log "Rename cell .name in top to y_.and_Y" 1
115+ logger -expect log "Rename cell .name2 in top to y_.and_Y_1" 1
116+ debug autoname
117+ logger -check-expected
118+
119+ # wires get autonames too
120+ design -reset
121+ read_rtlil <<EOT
122+ module \top
123+ wire output 1 $y
124+ wire input 2 \a
125+ wire input 3 \bcd
126+ wire $c
127+ wire $d
128+ wire $e
129+ cell $__unknown $name
130+ parameter \A_SIGNED 0
131+ parameter \A_WIDTH 1
132+ parameter \B_SIGNED 0
133+ parameter \B_WIDTH 1
134+ parameter \Y_WIDTH 1
135+ connect \A \a
136+ connect \B \bcd
137+ connect \Y $c
138+ end
139+
140+ cell $or \or
141+ parameter \A_SIGNED 0
142+ parameter \A_WIDTH 1
143+ parameter \B_SIGNED 0
144+ parameter \B_WIDTH 1
145+ parameter \Y_WIDTH 1
146+ connect \A \a
147+ connect \B \bcd
148+ connect \Y $d
149+ end
150+
151+ cell $or $name2
152+ parameter \A_SIGNED 0
153+ parameter \A_WIDTH 1
154+ parameter \B_SIGNED 0
155+ parameter \B_WIDTH 1
156+ parameter \Y_WIDTH 1
157+ connect \A $c
158+ connect \B $d
159+ connect \Y $e
160+ end
161+
162+ cell $and $name3
163+ parameter \A_SIGNED 0
164+ parameter \A_WIDTH 1
165+ parameter \B_SIGNED 0
166+ parameter \B_WIDTH 1
167+ parameter \Y_WIDTH 1
168+ connect \A $c
169+ connect \B $e
15170 connect \Y $y
16171 end
17172end
18173EOT
19- autoname
174+ # wires all named for being cell outputs
175+ logger -expect log "Rename wire .d in top to or_Y" 1
176+ # $name gets shortest name (otherwise bcd_$__unknown_B)
177+ logger -expect log "Rename cell .name in top to a_.__unknown_A" 1
178+ logger -expect log "Rename cell .name2 in top to or_Y_.or_B" 1
179+ # another output wire
180+ logger -expect log "Rename wire .e in top to or_Y_.or_B_Y" 1
181+ # $name3 named for lowest fanout wire (otherwise a_$__unknown_A_Y_$and_A)
182+ logger -expect log "Rename cell .name3 in top to or_Y_.or_B_Y_.and_B" 1
183+ # $c gets shortest name, since the cell driving it doesn't have known port
184+ # directions
185+ logger -expect log "Rename wire .c in top to or_Y_.or_B_A" 1
186+ debug autoname t:$and
187+ logger -check-expected
You can’t perform that action at this time.
0 commit comments