Skip to content

Commit

Permalink
polish waveform sim configuration
Browse files Browse the repository at this point in the history
more
  • Loading branch information
tomcl committed Aug 21, 2024
1 parent f31c21d commit 68e7364
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 49 deletions.
30 changes: 9 additions & 21 deletions src/Renderer/Simulator/NumberHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,14 @@ let UInt32ToPaddedString maxChars radix (width: int) (fd: uint32) =
let pre, digits = stripLeadingZeros s
let n = digits.Length

let pre' =
(match displayRadix with
| Dec
| SDec -> ""
| _ -> $"{width}'")
+ pre

if pre'.Length + digits.Length <= maxChars then
if pre.Length + digits.Length <= maxChars then
// stripping leading zeros makes length ok
pre' + digits
pre + digits
else
// truncate MS digits replacing by '..'
pre'
pre
+ ".."
+ digits[n + 2 + pre'.Length - maxChars .. n - 1]
+ digits[n + 2 + pre.Length - maxChars .. n - 1]
let BigIntToPaddedString maxChars radix (width: int) (fd: bigint) =
let getPrefixAndDigits (s: string) =
match s.Length, s.[0], s.[1] with
Expand Down Expand Up @@ -376,21 +369,16 @@ let BigIntToPaddedString maxChars radix (width: int) (fd: bigint) =
let pre, digits = stripLeadingZeros s
let n = digits.Length

let pre' =
(match displayRadix with
| Dec
| SDec -> ""
| _ -> $"{width}'")
+ pre


if pre'.Length + digits.Length <= maxChars then
if pre.Length + digits.Length <= maxChars then
// stripping leading zeros makes length ok
pre' + digits
pre + digits
else
// truncate MS digits replacing by '..'
pre'
pre
+ ".."
+ digits[n + 2 + pre'.Length - maxChars .. n - 1]
+ digits[n + 2 + pre.Length - maxChars .. n - 1]

/// Convert an int into a Bit list with the provided width. The Least
/// Significant Bits are the one with low index (e.g. LSB is at position 0, MSB
Expand Down
5 changes: 3 additions & 2 deletions src/Renderer/UI/ModelHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ module Constants =
FirstClock = 0; // first clock accessible - limits scroll range. NOT IMPLEMENTED
FontSize = 14; // size of text on waveforms
FontWeight = 500 // weight of text on waveforms
}
let maxSimulationSize = 1000000
}
let maxWarnSimulationSize = 100000
let maxSimulationSize = 10000000
let minScrollingWindow = 200
let wsButtonHeight = 30
let wsButtonWidth = 120
Expand Down
8 changes: 7 additions & 1 deletion src/Renderer/UI/UIPopups.fs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ let dialogWaveSimConfigPopup (dispatch: Msg -> unit) (model:Model) =
be at least {Constants.minScrollingWindow} cycles."
["fontsize"], not <| inBounds 12 24 c.FontSize, $"Font size must be between 12 and 24"
["fontweight"], not <| inBounds 100 900 c.FontWeight, $"Font weight must be between 100 and 900"
[], c.LastClock > Constants.maxWarnSimulationSize, $"Warning: very large simulation lengths and big designs result in high memory use, \
and possible crashes."

]
|> List.filter (fun (_, isError, _) -> isError)
|> List.map (fun (key, _, message) -> key, message)
Expand All @@ -523,8 +526,11 @@ let dialogWaveSimConfigPopup (dispatch: Msg -> unit) (model:Model) =
let isValid = List.isEmpty errorKeys

let closeAction changeConfig dispatch model =
let wsm = getWSModel model
if changeConfig then
dispatch <| UpdateModel (Optic.set (waveSimModel_ >-> wSConfig_) (Option.defaultValue initWSModel.WSConfig (getWSModel model).WSConfigDialog))
let dialog = wsm.WSConfigDialog
if dialog = None then printf $"Unexpected WSConfigDialog = None when closing configuration popup. changeConfig = {changeConfig}"
dispatch <| UpdateModel (Optic.set (waveSimModel_ >-> wSConfig_) (Option.defaultValue wsm.WSConfig dialog))
dispatch <| ClosePopup
dispatch <| UpdateModel (Optic.map (waveSimModel_ >-> wSConfigDialog_) (fun _ -> None))

Expand Down
55 changes: 35 additions & 20 deletions src/Renderer/UI/WaveSim/WaveSimStyle.fs
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,19 @@ let endCycle wsModel = wsModel.StartCycle + (wsModel.ShownCycles) - 1
let zoomOutSVG = DiagramStyle.zoomOutSVG
let zoomInSVG = DiagramStyle.zoomInSVG

/// Style for top row in wave viewer.
let topRowStyle = Style [
Height Constants.rowHeight
BorderBottom "2px solid rgb(219,219,219)"
]
let valueTopPadding (ws:WaveSimModel) =
(float Constants.rowHeight - float ws.WSConfig.FontSize - 8.) / 2.


/// Empty row used in namesColumn and valuesColumn. Shifts these down by one
/// to allow for the row of clk cycle numbers in waveformsColumn.
let topRow topRowContent = [ div [ topRowStyle ] topRowContent ]
let topRow (ws:WaveSimModel) topRowContent =
[ div [ Style [
Height Constants.rowHeight
BorderBottom "2px solid rgb(219,219,219)"
PaddingTop (valueTopPadding ws)
]]
topRowContent ]

/// Style for showing error messages in waveform simulator.
let errorMessageStyle = Style [
Expand Down Expand Up @@ -471,14 +475,18 @@ let nameLabelStyle isHovered = Style [
Cursor "grab"
]



/// Style for value label
let valueLabelStyle =
let valueLabelStyle (ws: WaveSimModel)=
Style [
Height Constants.rowHeight
BorderBottom "1px solid rgb(219,219,219)"
PaddingLeft Constants.labelPadding
PaddingTop (valueTopPadding ws)
FontFamily Constants.valueColumnFontFamily
FontSize Constants.valueColumnFontSize
FontSize ws.WSConfig.FontSize
FontWeight ws.WSConfig.FontWeight
]

/// Prop for Level.left in name row.
Expand Down Expand Up @@ -520,7 +528,7 @@ let waveSimColumn = [
Width "100%"
Display DisplayOptions.Grid
GridAutoRows Constants.rowHeight
FontSize Constants.valueColumnFontSize
//FontSize Constants.valueColumnFontSize
FontFamily Constants.valueColumnFontFamily
OverflowX OverflowOptions.Auto
WhiteSpace WhiteSpaceOptions.Nowrap
Expand All @@ -533,6 +541,8 @@ let namesColumnStyle (ws:WaveSimModel) = Style (
Width (calcNamesColWidth ws)
Float FloatOptions.Left
BackgroundColor Constants.namesValuesColumnColor
FontSize ws.WSConfig.FontSize
FontWeight ws.WSConfig.FontWeight
BorderRight Constants.borderProperties
GridColumnStart 1
OverflowX OverflowOptions.Clip
Expand Down Expand Up @@ -572,16 +582,21 @@ let valuesColumnSize wsModel =
|> (fun (w,num) -> int w + 20, num)

/// Style properties for values column
let valuesColumnStyle (colWidth:int) = Style (
(waveSimColumn) @ [
MinWidth colWidth
Float FloatOptions.Left
BorderLeft Constants.borderProperties
OverflowX OverflowOptions.Auto
BackgroundColor Constants.namesValuesColumnColor
Opacity 1.0
GridColumnStart 3
])
let valuesColumnStyle (ws: WaveSimModel) (colWidth:int) =
let size = ws.WSConfig.FontSize
let weight = ws.WSConfig.FontWeight
Style (
(waveSimColumn) @ [
FontSize size
FontWeight weight
MinWidth colWidth
Float FloatOptions.Left
BorderLeft Constants.borderProperties
OverflowX OverflowOptions.Auto
BackgroundColor Constants.namesValuesColumnColor
Opacity 1.0
GridColumnStart 3
])



Expand All @@ -596,7 +611,7 @@ let waveRowsStyle width = Style [
Height "100%"
OverflowX OverflowOptions.Hidden
Display DisplayOptions.Grid
FontSize "13px"
//FontSize "13px"
GridAutoRows Constants.rowHeight
BorderTop Constants.borderProperties
Width width
Expand Down
14 changes: 9 additions & 5 deletions src/Renderer/UI/WaveSim/WaveSimWaveforms.fs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ let namesColumn model wsModel dispatch : ReactElement =
let rows =
nameRows model wsModel dispatch
div (namesColumnProps wsModel)
(List.concat [ topRow []; rows ])
(List.concat [ topRow wsModel []; rows ])
//|> TimeHelpers.instrumentInterval "namesColumn" start


Expand All @@ -199,7 +199,7 @@ let valueRows (wsModel: WaveSimModel) =
match fd.Width, fd.Dat with
| 1, Word b -> $" {b}"
| _ -> fastDataToPaddedString valueColNumChars wsModel.Radix fd)
|> List.map (fun value -> label [ valueLabelStyle ] [ str value ])
|> List.map (fun value -> label [ valueLabelStyle wsModel] [ str value ])
|> (fun rows -> valueColWidth, rows)


Expand All @@ -226,9 +226,13 @@ let private valuesColumn wsModel : ReactElement =
let start = TimeHelpers.getTimeMs ()
let width, rows = valueRows wsModel
let cursorClkNum = wsModel.CurrClkCycleDetail
let topRowNumber = [ div [Style [FontSize "10pt" ; VerticalAlign "bottom"; FontWeight "bold"; PaddingLeft "4pt"]] [str (string <| cursorClkNum)] ]
div [ HTMLAttr.Id "ValuesCol" ; valuesColumnStyle width]
(List.concat [ topRow topRowNumber ; rows ])
let topRowNumber = [ div [Style [
FontSize wsModel.WSConfig.FontSize ;
VerticalAlign "bottom";
FontWeight wsModel.WSConfig.FontWeight;
PaddingLeft "4pt"]] [str (string <| cursorClkNum)] ]
div [ HTMLAttr.Id "ValuesCol" ; valuesColumnStyle wsModel width]
(List.concat [ topRow wsModel topRowNumber ; rows ])
//|> TimeHelpers.instrumentInterval "valuesColumn" start

/// Generate a column of waveforms corresponding to selected waves.
Expand Down

0 comments on commit 68e7364

Please sign in to comment.