static void TestRegOperation() { UInt32 myInt = 0; var a = FpgaOp.RegWrite(0, 94); var b = FpgaOp.RegRead(ref myInt, 0); uint[] dataIn = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; uint[] dataOut = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var c = FpgaOp.RegArrayWrite(dataIn, 0x100, 10); var d = FpgaOp.RegArrayRead(ref dataOut, 0x100, 10); }
static void Main(string[] args) { SessionOpen(); ShowAddressMap(); #region Test //TestMemory(); //TestRegOperation(); //TestDDR(); #endregion //goto label; #region ET Test const int numOfSamples = 1024; const int osr = 8; const UInt64 Et_RegBase = 0x21000; const UInt64 Streamer_DMA_RegBase = 0x20000; const UInt64 paInAddr = 0x02000000; const UInt64 envOutAddr = 0x03000000; //Step 1. Load Waveform into DDR StreamReader sr = new StreamReader(@"c:\wjh\IQ.csv"); double[] iqData = new double[numOfSamples * 2]; string line = ""; int LineNumber = 0; while ((line = sr.ReadLine()) != null) { var iq = line.Split(','); var iData = float.Parse(iq[0]); var qData = float.Parse(iq[1]); if (LineNumber < numOfSamples) { iqData[2 * LineNumber] = iData; iqData[2 * LineNumber + 1] = qData; } LineNumber++; } var fixedPointData = ScaleToFixedPoint(iqData, true, ref scaleFactor); Console.WriteLine("scaleFactor = {0}", scaleFactor); var dataToDdr = PackToUInt32(fixedPointData); FpgaOp.DdrWrite(dataToDdr, paInAddr, numOfSamples); //Step 2. Setup ET registers FpgaOp.RegWrite(Et_RegBase + 0x4, 0x80000000 / osr); // Resampler rate = 1 FpgaOp.RegWrite(Et_RegBase + 0x10, numOfSamples); // Input Sample=1024 FpgaOp.RegWrite(Et_RegBase + 0x14, numOfSamples * osr); // Output Sample=1024 FpgaOp.RegWrite(Et_RegBase + 0x8, 0); FpgaOp.RegWrite(Et_RegBase + 0xc, 0); FpgaOp.RegWrite(Et_RegBase + 0x18, 0); var shapingTable = CreateShapingTable(); FpgaOp.RegArrayWrite(shapingTable, Et_RegBase + 0x400, 256); //Shaping Table FpgaOp.RegWrite(Et_RegBase + 0x0, 1); // Clr //Step 3. Setup Streamer32 ConfigS2MM(Streamer_DMA_RegBase, envOutAddr, numOfSamples * osr * 2); // envOut each sample 2 bytes ConfigMM2S(Streamer_DMA_RegBase, paInAddr, numOfSamples * 4); // paIn each sample 4 bytes //Step 4. Read back the ET output UInt32[] dataFromDdr = new UInt32[numOfSamples * osr / 2]; FpgaOp.DdrRead(dataFromDdr, envOutAddr, numOfSamples * osr / 2); var envData = UnpackToShort(dataFromDdr); var envData_Double = ScaleToFloatingPoint(envData); #endregion //label: //Step 5. Write Env output to file StreamWriter sw = new StreamWriter(@"c:\wjh\EnvOut.csv"); for (int i = 0; i < envData_Double.Length; i++) { sw.WriteLine("{0}", envData_Double[i]); } sw.Close(); SessionClose(); Console.ReadKey(); }