Skip to content

Commit

Permalink
fix new simulation bug that leads to missing waveforms
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcl committed Sep 8, 2022
1 parent 49f5a6d commit cd0c4b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/Renderer/Simulator/FastCreate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ let addComponentWaveDrivers (f:FastSimulation) (fc: FastComponent) (pType: PortT
| SplitWire _
| BusSelection _
| MergeWires
| Constant _
| Constant1 _ ->
[||]
| Output _ when fc.SubSheet <> [] ->
[||]
| Input1 _ when fc.SubSheet <> [] ->
Expand Down
11 changes: 6 additions & 5 deletions src/Renderer/UI/UpdateHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,13 @@ let shortDisplayMsg (msg:Msg) =
| FinishUICmd
| ReadUserData _
| SetUserData _
| ExecCmd _
| ExecFuncInMessage _
| ExecFuncAsynch _
| ExecCmdAsynch _
| SendSeqMsgAsynch _
| SetThemeUserData _ -> None
| ExecCmd _ -> Some "ExecCmd"
| ExecFuncInMessage _ -> Some "ExecFuncInMessage"
| ExecFuncAsynch _ -> Some "ExecFuncAsync"
| ExecCmdAsynch _ -> Some "ExecCmdAsynch"
| SendSeqMsgAsynch _ -> Some "SendSeqMsgAsynch"




Expand Down
11 changes: 9 additions & 2 deletions src/Renderer/UI/WaveSim/WaveSim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ let waveformIsUptodate (ws: WaveSimModel) (wave:Wave) =
/// Generates or updates the SVG for a specific waveform if necessary
/// Assumes that the fast simulation data has not changed and has enough cycles
let generateWaveform (ws: WaveSimModel) (index: WaveIndexT) (wave: Wave): Wave =
//if wave.ViewerDisplayName.StartsWith "DATAPATH.MUX" then
//let wave1 = {wave with SVG=None ; WaveValues = {wave.WaveValues with Step = Array.empty}}
//printfn $"Generating waveform '{wave.ViewerDisplayName}'\n wave={wave1}"
let waveform =
match wave.Width with
| 0 -> failwithf "Cannot have wave of width 0"
Expand Down Expand Up @@ -763,16 +766,19 @@ let rec refreshWaveSim (newSimulation: bool) (wsModel: WaveSimModel) (model: Mod
getWaves wsModel fs
else wsModel.AllWaves

let simulationIsUptodate = wsModel.FastSim.ClockTick > wsModel.ShownCycles + wsModel.StartCycle
let wavesToBeMade =
allWaves
|> Map.filter (fun wi wave ->
// Only generate waveforms for selected waves.
// Regenerate waveforms whenever they have changed
let hasChanged = not <| waveformIsUptodate wsModel wave
let simulationIsUptodate = wsModel.FastSim.ClockTick > wsModel.ShownCycles + wsModel.StartCycle
//if List.contains index ws.SelectedWaves then
List.contains wi wsModel.SelectedWaves && hasChanged && simulationIsUptodate)
|> Map.toList

//|> (fun lst -> lst |> List.iter (fun (wi,wave) ->
//printfn $"wave={wi.SimArrayIndex},{wi.PortNumber},{wi.PortType},{wave.ViewerDisplayName}"); lst)
|> List.map fst

let model, allWaves, spinnerPayload, numToDo =
Expand All @@ -787,7 +793,8 @@ let rec refreshWaveSim (newSimulation: bool) (wsModel: WaveSimModel) (model: Mod
failwithf "What? makewaveformsWithTimeOut must make at least one waveform"
| numToDo, Some t when
float wavesToBeMade.Length * t / float numDone < Constants.maxSimulationTimeWithoutSpinner ->
model, allWaves, None, numToDo
let (allWaves, numDone, timeOpt) = makeWaveformsWithTimeOut None wsModel allWaves wavesToBeMade
model, allWaves, None, numToDo - numDone
| numToDo, _ ->
let payload = Some ("Making waves", refreshWaveSim false {wsModel with AllWaves = allWaves} >> fst)
model, allWaves, payload, numToDo)
Expand Down

0 comments on commit cd0c4b1

Please sign in to comment.