Skip to content

Commit e04fe80

Browse files
author
Jasper van Bourgognie
committed
SmartScopeAWG: reduce decimation registers to 3
1 parent e0b951e commit e04fe80

File tree

8 files changed

+13
-16
lines changed

8 files changed

+13
-16
lines changed

Devices/IWaveGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public interface IWaveGenerator : IDevice
1313
byte[] GeneratorDataByte { set; }
1414
bool GeneratorToAnalogEnabled { set; get; }
1515
bool GeneratorToDigitalEnabled { set; get; }
16-
UInt32 GeneratorStretcherForFrequency(double frequency);
16+
Int32 GeneratorStretcherForFrequency(double frequency);
1717
int GeneratorNumberOfSamplesForFrequency(double frequency);
1818
int GeneratorNumberOfSamples { set; get; }
19-
UInt32 GeneratorStretching { set; get; }
19+
Int32 GeneratorStretching { set; get; }
2020
double GeneratorFrequencyMax { get; }
2121
double GeneratorFrequencyMin { get; }
2222
double GeneratorFrequency { get; set; }

Devices/SmartScopeAwg.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ partial class SmartScope
1313
const double AWG_SAMPLE_PERIOD_0 = 10e-9; //10ns
1414
const int AWG_SAMPLES_MAX = 2048;
1515
const int AWG_SAMPLES_MIN = 1;
16-
const UInt32 AWG_STRETCHER_MAX = UInt32.MaxValue;
16+
const Int32 AWG_STRETCHER_MAX = 256*256*256-1;
1717
public bool DataOutOfRange { get; private set; }
1818

1919
/// <summary>
@@ -83,7 +83,7 @@ public int GeneratorNumberOfSamples
8383
}
8484
}
8585

86-
public UInt32 GeneratorStretching
86+
public Int32 GeneratorStretching
8787
{
8888
set
8989
{
@@ -94,15 +94,13 @@ public UInt32 GeneratorStretching
9494
FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B0].Set((byte)(value & 0xFF));
9595
FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B1].Set((byte)((value >> 8) & 0xFF));
9696
FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B2].Set((byte)((value >> 16) & 0xFF));
97-
FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B3].Set((byte)((value >> 24) & 0xFF));
9897
}
9998
get
10099
{
101100
return
102-
(UInt32)(FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B0].GetByte() ) +
103-
(UInt32)(FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B1].GetByte() << 8) +
104-
(UInt32)(FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B2].GetByte() << 16) +
105-
(UInt32)(FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B3].GetByte() << 24);
101+
(Int32)(FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B0].GetByte() ) +
102+
(Int32)(FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B1].GetByte() << 8) +
103+
(Int32)(FpgaSettingsMemory[REG.GENERATOR_DECIMATION_B2].GetByte() << 16);
106104
}
107105
}
108106

@@ -150,21 +148,21 @@ public double GeneratorFrequencyMin
150148
return 1.0 / ((AWG_SAMPLES_MAX - 1) * AWG_SAMPLE_PERIOD_0 * ((double)(AWG_STRETCHER_MAX) + 1));
151149
}
152150
}
153-
public UInt32 GeneratorStretcherForFrequency(double frequency)
151+
public Int32 GeneratorStretcherForFrequency(double frequency)
154152
{
155153
if (frequency > GeneratorFrequencyMax || frequency < GeneratorFrequencyMin)
156154
throw new ValidationException(String.Format("AWG frequency {0} out of range [{1},{2}]", frequency, GeneratorFrequencyMin, GeneratorFrequencyMax));
157155

158156
double numberOfSamplesAtFullRate = Math.Floor(1 / (AWG_SAMPLE_PERIOD_0 * frequency));
159-
return (UInt32)Math.Floor(numberOfSamplesAtFullRate / AWG_SAMPLES_MAX); ;
157+
return (Int32)Math.Floor(numberOfSamplesAtFullRate / AWG_SAMPLES_MAX); ;
160158
}
161159
public int GeneratorNumberOfSamplesForFrequency(double frequency)
162160
{
163161
if (frequency > GeneratorFrequencyMax || frequency < GeneratorFrequencyMin)
164162
throw new ValidationException(String.Format("AWG frequency {0} out of range [{1},{2}]", frequency, GeneratorFrequencyMin, GeneratorFrequencyMax));
165163

166164
double numberOfSamplesAtFullRate = Math.Floor(1 / (AWG_SAMPLE_PERIOD_0 * frequency));
167-
UInt32 stretcher = GeneratorStretcherForFrequency(frequency);
165+
Int32 stretcher = GeneratorStretcherForFrequency(frequency);
168166
return (int)Math.Floor(numberOfSamplesAtFullRate / (stretcher + 1));
169167
}
170168
public double GeneratorFrequency
@@ -186,7 +184,7 @@ public double GeneratorSamplePeriod
186184
{
187185
set {
188186
double samples = value / AWG_SAMPLE_PERIOD_0;
189-
UInt32 samplesRounded = (UInt32)Math.Floor(samples);
187+
Int32 samplesRounded = (Int32)Math.Floor(samples);
190188
GeneratorStretching = samplesRounded;
191189
}
192190
get {

Memories/ScopeConstants_GEN.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ enum REG
4949
GENERATOR_DECIMATION_B0 = 34,
5050
GENERATOR_DECIMATION_B1 = 35,
5151
GENERATOR_DECIMATION_B2 = 36,
52-
GENERATOR_DECIMATION_B3 = 37,
53-
GENERATOR_SAMPLES_B0 = 38,
54-
GENERATOR_SAMPLES_B1 = 39,
52+
GENERATOR_SAMPLES_B0 = 37,
53+
GENERATOR_SAMPLES_B1 = 38,
5554
}
5655

5756
#if DEBUG

SmartScope_A10.bin

278 Bytes
Binary file not shown.

SmartScope_A12.bin

132 Bytes
Binary file not shown.

SmartScope_A14.bin

132 Bytes
Binary file not shown.

SmartScope_A15.bin

132 Bytes
Binary file not shown.

SmartScope_A16.bin

-2.37 KB
Binary file not shown.

0 commit comments

Comments
 (0)