Skip to content

Commit fffbaa2

Browse files
committed
Make space in short fields for the offset.
E.g. if the field is "hit" and the offset is "XLEN-18" then the field needs to be sized to accommodate that offset.
1 parent 66b857c commit fffbaa2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

registers.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,31 @@ def symbols( self ):
213213

214214
def columnWidth( self ):
215215
"""Return the width of the column in boxes."""
216-
charWidth = .33
216+
offsetCharWidth = .18
217+
nameCharWidth = .33
217218
xlen_symbol = sympy.symbols('XLEN')
219+
lengthCharWidth = .22
218220
try:
219221
# Pretend XLEN=32. This makes 32-bit registers with just a single
220222
# field be wide, while registers with XLEN-32 width be narrow.
221223
length = int(self.length().subs(xlen_symbol, 32))
222224
except TypeError:
223225
length = 20
226+
if self.length() == 1:
227+
bitText = f"{self.lowBit}"
228+
else:
229+
bitText = f"{self.highBit} {self.lowBit}"
224230
width = math.ceil(max(
231+
# Minimum length
225232
1,
233+
# Make fields with more bits take up more space visually
226234
1 + math.log(max(length, 0.1), 1.7),
227-
len( str( self.length() )) * charWidth,
228-
len( self.name ) * charWidth))
235+
# Wide enough to accommodate the string showing the field length
236+
len( str( self.length() )) * lengthCharWidth,
237+
# Wide enough to accommodate the high/low bit strings
238+
len( bitText ) * offsetCharWidth,
239+
# Wide enough to accommodate the name of the field
240+
len( self.name ) * nameCharWidth))
229241
# Make longer widths odd, so we can center the bit.
230242
if width > 1 and width % 2 == 0:
231243
width += 1

0 commit comments

Comments
 (0)