saleae/AnalyzerSDK

Missing data when generating simulation data with minimum number of channels enabled

Opened this issue · 2 comments

I'm generating simulation data for a clocked serial interface (PDM audio). It seems like the lowest channel fail to generate data properly unless there is an additional unused channel in the Logic program. This is best shown by images:
failing_sim_data
failing_sim_data2
working_sim_data
As can be seen from the images, something seems to go wrong when generating data with a limited number of channels enabled. In the images I'm using Channel 1 and 2, I also tried with Channels 0 and 1, and that combination shows same behavior.
I'm using Windows 64x version of the Logic application.
This seems more like an application issue, but I'm reporting for SDK in lack of better place to put it.

I think I've seen this problem before.

I think the root cause of the problem is with the amount of data simulated in each call to your analyzer's GenerateSimulationData method.

Specifically, you need to generate enough data so that all sumulaton channel descriptors have at least newest_sample_requested samples.

However, I think there is a bug in the simulation data thread, such that if there is not a transition in the simulated data past the newest_sample_requested point, the simulator will get into an invalid state and stop simulating that channel.

Unfortunately I'm knee deep in the analog data processing system at the moment, and can't take a closer look at this.

It might also be a problem with transitionIfNeeded. If you call transitionIfNeeded after already calling Transition and without advancing, the software tries to create a zero length transition and the simulation data generator stops producing simulation data for that channel.

Both of these issues are logged, but are going to have to wait until after we're done overhauling the data processing pipeline, which has pretty much been the theme for the last few quarters. The good news is that this will be much easier to unit test & fix once we're done.

Thanks for your valuable suggestions.

I debugged a bit further. You are correct that it has to do with the amount of data simulated by my GenerateSimulatedData function. I found that I had to generate a couple of "samples" past the adjusted newest_sample_requested in order for the data to show properly.

Below is my debug GenerateSimulationData function, I added a + 3 in the while-loop and then simulated data shows up properly.

U32 MicSimulationDataGenerator::GenerateSimulationData(U64 largest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels)
{

U64 adjusted_largest_sample_requested = AnalyzerHelpers::AdjustSimulationTargetSample(largest_sample_requested, sample_rate, mSimulationSampleRateHz);

	while (mSck->GetCurrentSampleNumber() < adjusted_largest_sample_requested + 3) {
		mMicSimulationChannels.AdvanceAll(mClockGenerator.AdvanceByHalfPeriod(1.0));
		mSck->Transition();
		mSdo->Transition();
	}

	*simulation_channels = mMicSimulationChannels.GetArray();
	return mMicSimulationChannels.GetCount();
}

When changing from + 3 to + 2 the simulated data does not show up properly.