public virtual void PopulateSnapshot(VCDSignalsSnapshot snapshot, RTLModuleSnapshotConfig config = null) { config = config ?? RTLModuleSnapshotConfig.Default; try { if (config.IsIncluded(RTLModuleSnapshotConfigInclude.Inputs)) { currentSnapshot = snapshot.Scope("Inputs"); foreach (var prop in InputProps) { currentMember = prop; var value = currentMember.GetValue(Inputs); currentSnapshot.SetVariables(ToVCDVariables(currentMember, value)); } } if (config.IsIncluded(RTLModuleSnapshotConfigInclude.Outputs)) { currentSnapshot = snapshot.Scope("Outputs"); foreach (var prop in OutputProps) { currentMember = prop; var value = currentMember.GetValue(this); currentSnapshot.SetVariables(ToVCDVariables(currentMember, value)); } } if (config.IsIncluded(RTLModuleSnapshotConfigInclude.Internals)) { currentSnapshot = snapshot.Scope("Internals"); foreach (var prop in InternalProps) { currentMember = prop; var value = currentMember.GetValue(this); currentSnapshot.SetVariables(ToVCDVariables(currentMember, value)); } } if (config.IsIncluded(RTLModuleSnapshotConfigInclude.Modules)) { currentSnapshot = null; foreach (var m in ModuleProps.Where(m => RTLModuleHelper.IsField(m))) { var value = m.GetValue(this); currentMember = m; if (value is IRTLCombinationalModule module) { var moduleScope = snapshot.Scope(m.Name); module.PopulateSnapshot(moduleScope); continue; } // TODO: support for modules array } } } catch (VCDSnapshotException) { throw; } catch (Exception ex) { ThrowVCDException(ex); } }
public override void PopulateSnapshot(VCDSignalsSnapshot snapshot, RTLModuleSnapshotConfig config = null) { config = config ?? RTLModuleSnapshotConfig.Default; try { base.PopulateSnapshot(snapshot, config); if (config.IsIncluded(RTLModuleSnapshotConfigInclude.State)) { currentSnapshot = snapshot.Scope("State"); if (State == null) { throw new NullReferenceException("State is not initialized"); } foreach (var prop in StateProps) { // TODO: support arrays in VCD if (prop.GetMemberType().IsArray) { continue; } currentMember = prop; var value = currentMember.GetValue(State); currentSnapshot.SetVariables(ToVCDVariables(currentMember, value)); } } if (config.IsIncluded(RTLModuleSnapshotConfigInclude.NextState)) { currentSnapshot = snapshot.Scope("NextState"); if (NextState == null) { throw new NullReferenceException("NextState is not initialized"); } foreach (var prop in StateProps) { // TODO: support arrays in VCD if (prop.GetMemberType().IsArray) { continue; } currentMember = prop; var value = currentMember.GetValue(NextState); currentSnapshot.SetVariables(ToVCDVariables(currentMember, value)); } } if (config.IsIncluded(RTLModuleSnapshotConfigInclude.Pipelines)) { var pipelinesScope = snapshot.Scope("Pipelines"); currentSnapshot = pipelinesScope; foreach (var pipelineProp in PipelineProps) { var pipeline = pipelineProp.GetValue(this) as IRTLPipeline; var head = pipeline.Diag.Head; var pipelineScope = pipelinesScope.Scope(pipelineProp.Name); currentSnapshot = pipelineScope.Scope("Control"); currentSnapshot.SetVariables(ToVCDVariables("", head.PipelineControl, true)); currentSnapshot = pipelineScope.Scope("Preview"); currentSnapshot.SetVariables(ToVCDVariables("", head.PipelinePreview, true)); var stagesScope = pipelineScope.Scope("Stages"); foreach (var stage in pipeline.Diag.Stages) { var index = pipeline.Diag.Stages.IndexOf(stage); var stageScope = stagesScope.Scope($"Stage{index}"); currentSnapshot = stageScope.Scope("Inputs"); currentSnapshot = stageScope.Scope("State"); var stateMember = stage.GetType().GetMember("State")[0]; currentSnapshot.SetVariables(ToVCDVariables("", stage.StateValue)); currentSnapshot = stageScope.Scope("NextState"); var nextStateMember = stage.GetType().GetMember("NextState")[0]; currentSnapshot.SetVariables(ToVCDVariables("", stage.NextStateValue)); var managed = stage.ManagedSignals; currentSnapshot = stageScope.Scope("Control"); currentSnapshot.SetVariables(ToVCDVariables("", managed.Control, true)); currentSnapshot = stageScope.Scope("Request"); currentSnapshot.SetVariables(ToVCDVariables("", managed.Request, true)); currentSnapshot = stageScope.Scope("Preview"); currentSnapshot.SetVariables(ToVCDVariables("", managed.Preview, true)); } } currentSnapshot = null; } } catch (VCDSnapshotException) { throw; } catch (Exception ex) { ThrowVCDException(ex); } }