/// <summary> /// Calculates and writes some statistics about the connected Top Programmer /// and the UBS connection. /// </summary> /// <param name="shouter">The public address instance.</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> public static int ProgStat(IShouter shouter) { using (var td = TopDevice.Create(shouter)) { var writeZif = new ZIFSocket(40); writeZif.SetAll(false); td.WriteZIF(writeZif, ""); td.WriteZIF(writeZif, ""); Stopwatch sw = new Stopwatch(); sw.Start(); for (var i = 0; i < 1000; i++) { td.WriteZIF(writeZif, ""); } sw.Stop(); shouter.ShoutLine(0, "Average WriteZif = {0}ms (1000 performed)", (double)sw.ElapsedMilliseconds / 1000); sw.Reset(); sw.Start(); for (var i = 0; i < 1000; i++) { td.ReadZIF(""); } sw.Stop(); shouter.ShoutLine(0, "Average ReadZif = {0}ms (1000 performed)", (double)sw.ElapsedMilliseconds / 1000); } return(0); }
/// <summary> /// Displays the SRAM inserted into the Top-programmer. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="type">The type of SRAM.</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> public static int SRamInfo(IShouter shouter, string type) { var sram = SRamXml.Specified[type]; Console.WriteLine(sram); return(0); }
/// <summary> /// Displays the EPROM inserted into the Top-programmer. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="type"></param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> public static int RomInfo(IShouter shouter, string type) { var eprom = EpromXml.Specified[type]; Console.WriteLine(eprom); return(0); }
/// <summary> /// Displays a list of all supported ROMs. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="option">If option "type" is passed, only the type is displayed.</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> public static int RomAll(IShouter shouter, string option) { var onlyDisplayTypeName = option == "type"; shouter.ShoutLine(1, "Supported ROMs:"); shouter.ShoutLine(1, "==============="); foreach (var pair in EpromXml.Specified.OrderBy(pair => pair.Key)) { if (onlyDisplayTypeName) { shouter.ShoutLine(1, pair.Key); } else { var rom = pair.Value; shouter.ShoutLine(1, "Type:"); shouter.ShoutLine(1, " {0}", rom.Type); if (!String.IsNullOrWhiteSpace(rom.Description)) { shouter.ShoutLine(1, "Description:"); shouter.ShoutLine(1, rom.Description); } if (!String.IsNullOrWhiteSpace(rom.Notes)) { shouter.ShoutLine(1, "Notes:"); shouter.ShoutLine(1, rom.Notes); } shouter.ShoutLine(1, "-----------"); } } return(0); }
/// <summary> /// Processes a binary dump. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="format">Format.</param> /// <param name="numberOfOutputs">Number of input pins.</param> /// <param name="numberOfInputs">Number of output pins.</param> /// <param name="path">The file name.</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> public static int BDumpProcess( IShouter shouter, string format, int numberOfOutputs, int numberOfInputs, string path) { var processor = new BinaryDumpProcessor(path); string output; switch (format) { case "ceqn": output = processor.GenerateCUPLEquations(numberOfOutputs, numberOfInputs); break; case "ctt": output = processor.GenerateCUPLTruthTable(numberOfOutputs, numberOfInputs); break; case "tt": output = processor.GenerateHumanReadableTruthTable(numberOfOutputs, numberOfInputs); break; default: shouter.ShoutLine(1, "Unknown bdump format {0}", format); return(1); } Console.WriteLine(); Console.WriteLine(output); return(0); }
/// <summary> /// Entry point for the 'sram' category of commands. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="args">Command line argumsnts</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> private static int SRam(IShouter shouter, IList <string> args) { if (args.Count == 1) { args.Insert(0, "help"); Help(shouter, args); return(0); } switch (args[1]) { case "all": var option = args.Count == 3 ? args[2] : null; return(Kernel.SRamAll(shouter, option)); case "test": return(Kernel.SRamTest(shouter, args[2])); case "info": return(Kernel.SRamInfo(shouter, args[2])); default: shouter.ShoutLine(1, "Unknown sram command {0}", args[1]); return(1); } }
/// <summary> /// ctor. /// </summary> /// <param name="shouter">Public shouter instance.</param> /// <param name="size">The total number of progresses before finished.</param> public ProgressBar(IShouter shouter, int size) { this.shouter = shouter; this.size = size; stride = size / 64; savedVerbosity = shouter.VerbosityLevel; }
/// <summary> /// Reads the id string of the connected Top Programmer. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <returns>The read id string.</returns> public static string ReadTopDeviceIdString(IShouter shouter) { using (var bulkDevice = OpenBulkDevice(shouter)) { return(ReadTopDeviceIdString(shouter, bulkDevice)); } }
/// <summary> /// Entry point for the 'help' category of commands. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="args">Command line arguments</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> private static int Help(IShouter shouter, IList <string> args) { if (args.Count <= 1) { Console.Write(HelpTexts["main"]); return(0); } if (args.Count <= 2) { if (!HelpTexts.ContainsKey(args[1])) { throw new U2PaException("No help entry for {0}", args[1]); } Console.Write(HelpTexts[args[1]]); return(0); } var arg = args[1] + "_" + args[2]; if (!HelpTexts.ContainsKey(arg)) { throw new U2PaException("No help entry for {0}", arg); } Console.Write(HelpTexts[arg]); return(0); }
/// <summary> /// A simple SRAM-test. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="type">The type of SRAM.</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> public static int SRamTest(IShouter shouter, string type) { var sram = SRamXml.Specified[type]; var totalNumberOfAdresses = sram.AddressPins.Length == 0 ? 0 : 1 << sram.AddressPins.Length; List <Tuple <int, string, string> > firstRandomPass, secondRandomPass, firstSimplePass, secondSimplePass; using (var progressBar = new ProgressBar(shouter, totalNumberOfAdresses * 8)) { using (var topDevice = TopDevice.Create(shouter)) { shouter.ShoutLine(1, "Testing SRAM{0}", type); progressBar.Init(); firstRandomPass = topDevice.SRamTestPass(shouter, sram, progressBar, "First random test", totalNumberOfAdresses, new RandomDataGenerator(sram.DataPins.Length, totalNumberOfAdresses)); secondRandomPass = topDevice.SRamTestPass(shouter, sram, progressBar, "Second random test", totalNumberOfAdresses, new RandomDataGenerator(sram.DataPins.Length, totalNumberOfAdresses)); firstSimplePass = topDevice.SRamTestPass(shouter, sram, progressBar, "First simple test (01..)", totalNumberOfAdresses, new SimpleDataGenerator(sram.DataPins.Length, false)); secondSimplePass = topDevice.SRamTestPass(shouter, sram, progressBar, "Second simple test (10..)", totalNumberOfAdresses, new SimpleDataGenerator(sram.DataPins.Length, true)); } } var returnValue = 0; var printingVerbosity = 1; returnValue = PrintTestPassResult(shouter, "first random", firstRandomPass, ref printingVerbosity); returnValue = PrintTestPassResult(shouter, "second random", secondRandomPass, ref printingVerbosity); returnValue = PrintTestPassResult(shouter, "first simple", firstSimplePass, ref printingVerbosity); returnValue = PrintTestPassResult(shouter, "second simple", secondSimplePass, ref printingVerbosity); if (returnValue == 0) { shouter.ShoutLine(1, "This piece of SRAM is just a'okay }};-P"); } return(returnValue); }
/// <summary> /// Reads the id string of the connected Top Programmer. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="bulkDevice">The bulk device instance.</param> /// <returns>The read id string.</returns> public static string ReadTopDeviceIdString(IShouter shouter, IUsbBulkDevice bulkDevice) { bulkDevice.SendPackage(4, new byte[] { 0x0E, 0x11, 0x00, 0x00 }, "Write version string to buffer"); bulkDevice.SendPackage(4, new byte[] { 0x07 }, "07 command"); var readBuffer = bulkDevice.RecievePackage(4, "Reading buffer"); return(readBuffer.Take(16).Aggregate("", (current, t) => current + (char)t).TrimEnd()); }
/// <summary> /// Programs an EPROM. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="type">The type of the rom the be programmed.</param> /// <param name="fileData">The data to be written.</param> /// <param name="vppLevel">The Vpp-level; if not present, the one from the EPROM definition is used. /// <remarks>Not yet used!</remarks> /// </param> public static void RomWrite(IShouter shouter, string type, IList <byte> fileData, params string[] vppLevel) { using (var topDevice = TopDevice.Create(shouter)) { var eprom = EpromXml.Specified[type]; topDevice.WriteEpromClassic(eprom, fileData); //topDevice.WriteEpromFast(eprom, fileData); } }
/// <summary> /// Entry point for the 'dev' category of commands. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="args">Command line argumsnts</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> private static int Dev(IShouter shouter, IList <string> args) { shouter.VerbosityLevel = 5; return(Kernel.Dev(shouter)); //return Kernel.DevVppLevels(pa); //return Kernel.DevVccLevels(pa); //return Kernel.DevVppPins(pa); //return Kernel.DevVccPins(pa); //return Kernel.DevGndPins(pa); }
/// <summary> /// For dev. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> public static int Dev(IShouter shouter) { //var fpgaFile = new FPGAProgram(@"C:\Top\Topwin6\Blib2\ictest.bit"); //Console.WriteLine(fpgaFile); { var tr = new PinTranslator(40, 40, 0); var zif = new ZIFSocket(40); zif.SetAll(true); using (var td = TopDevice.Create(shouter)) { td.SetVccLevel(5.0); td.SetVppLevel(13.0); td.ApplyGnd(tr.ToZIF, new Pin { Number = 10 }); td.ApplyVcc(tr.ToZIF, new Pin { Number = 40 }); td.PullUpsEnable(true); td.WriteZIF(zif, ""); Console.ReadLine(); } } { var tr = new PinTranslator(40, 40, 0); var zif = new ZIFSocket(40); zif.SetAll(false); using (var td = TopDevice.Create(shouter)) { td.SetVccLevel(5.0); td.SetVppLevel(21.0); td.ApplyGnd(tr.ToZIF, new Pin { Number = 10 }); td.ApplyVcc(tr.ToZIF, new Pin { Number = 40 }); td.PullUpsEnable(true); td.WriteZIF(zif, ""); Console.ReadLine(); } } //Console.WriteLine("Testing {0} for Erasure }};-P", args[1]); //var fileData = Tools.ReadBinaryFile(args[1]).ToArray(); //if(fileData.Any(b => b != 0xff)) // throw new U2PaException("No good }};-("); //else Console.WriteLine("File {0} filled with all nice little 0xFF's }};-P", args[1]); return(0); }
/// <summary> /// Creates a new instance of the Top Device connected to the Top Programmer. /// <remarks>Atm. only works for model Top2005+.</remarks> /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="bulkDevice">The bulk device to use.</param> /// <returns>The created instance of the Top Device.</returns> public static TopDevice Create(IShouter shouter, IUsbBulkDevice bulkDevice) { var idString = ReadTopDeviceIdString(shouter, bulkDevice); shouter.ShoutLine(2, "Connected Top device is: {0}.", idString); if (idString.StartsWith("top2005+")) { return(new Top2005Plus(shouter, bulkDevice)); } throw new U2PaException("Not supported Top Programmer {0}", idString); }
/// <summary> /// A simple vector test. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="type">The type of test.</param> /// <returns>The results of the test.</returns> public static int VectorTest(IShouter shouter, string type) { IList <byte> bytes = new List <byte>(); var vectorTest = VectorTestXml.Specified[type]; List <VectorResult> results; using (var progressBar = new ProgressBar(shouter, vectorTest.Vectors.Count)) { using (var topDevice = TopDevice.Create(shouter)) { results = topDevice.VectorTest(vectorTest, progressBar); } } return(0); }
/// <summary> /// Writes the id of the connected Top Programmer. /// </summary> /// <param name="shouter">The public address instance.</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> public static int ProgId(IShouter shouter) { var v = shouter.VerbosityLevel; try { shouter.VerbosityLevel = 0; shouter.ShoutLine(0, "Connected Top Programmer has id: {0}", TopDevice.ReadTopDeviceIdString(shouter)); return(0); } finally { shouter.VerbosityLevel = v; } }
/// <summary> /// ctor. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="vendorId">The vendor id.</param> /// <param name="productId">The product id.</param> /// <param name="configuration">The configuration id.</param> /// <param name="@interface">The interface id.</param> /// <param name="readEndpointInt">The read endpoint id.</param> /// <param name="writeEndpointInt">The write end point id.</param> public RawUsbBulkDevice( IShouter shouter, int vendorId, int productId, byte configuration, int @interface, int readEndpointInt, int writeEndpointInt) { Shouter = shouter; VendorId = vendorId; ProductId = productId; Configuration = configuration; Interface = @interface; ReadEndpointID = (ReadEndpointID)readEndpointInt; WriteEndpointID = (WriteEndpointID)writeEndpointInt; Init(); }
private static int PrintTestPassResult(IShouter shouter, string text, List <Tuple <int, string, string> > pass, ref int printingVerbosity) { int returnValue = 0; var oldPrintingVerbosity = printingVerbosity; foreach (var tuple in pass) { shouter.ShoutLine(printingVerbosity, "Bad cell in {0} pass. Address: {1} Expected {2} Read {3}", text, tuple.Item1.ToString("X4"), tuple.Item3, tuple.Item2); printingVerbosity = 5; returnValue = 1; if (oldPrintingVerbosity <= 5) { break; } } return(returnValue); }
/// <summary> /// ctor. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="vendorId">The vendor id.</param> /// <param name="productId">The product id.</param> /// <param name="configuration">The configuration id.</param> /// <param name="@interface">The interface id.</param> /// <param name="readEndpointInt">The read endpoint id.</param> /// <param name="writeEndpointInt">The write end point id.</param> public UsbBulkDevice( IShouter shouter, int vendorId, int productId, byte configuration, int @interface, int readEndpointInt, int writeEndpointInt) : base( new RawUsbBulkDevice( shouter, vendorId, productId, configuration, @interface, readEndpointInt, writeEndpointInt)) { }
/// <summary> /// Verifies an EPROM against a list of bytes. /// </summary> /// <remarks> /// At present only works for 8-bit roms! /// </remarks> /// <param name="shouter">The shouter instance.</param> /// <param name="type">The type of the rom the be verified.</param> /// <param name="fileData">The list of data to verify against.</param> /// <returns> /// A list of tuples representing bytes that didn't verify. /// The tupeles has the form (address, actual_byte_on_EPROM, expected_byte). /// </returns> public static List <Tuple <int, byte, byte> > RomVerify(IShouter shouter, string type, IList <byte> fileData) { var didntVerify = new List <Tuple <int, byte, byte> >(); var epromData = RomRead(shouter, type); if (epromData.Count != fileData.Count) { throw new U2PaException("Filedata doesn't have the same length as EPROM data."); } for (var address = 0; address < fileData.Count; address++) { if (epromData[address] != fileData[address]) { didntVerify.Add(Tuple.Create(address, epromData[address], fileData[address])); } } return(didntVerify); }
/// <summary> /// Entry point for the 'bdump' category of commands. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="args">Command line argumsnts</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> private static int BDump(IShouter shouter, IList <string> args) { if (args.Count < 6) { args.Insert(0, "help"); Help(shouter, args); return(0); } var numberOfOutputs = Int32.Parse(args[3]); var numberOfInputs = Int32.Parse(args[4]); switch (args[1]) { case "process": Kernel.BDumpProcess(shouter, args[2], numberOfOutputs, numberOfInputs, args[5]); return(0); default: shouter.ShoutLine(1, "Unknown bdump command {0}", args[1]); return(1); } }
/// <summary> /// ctor. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="bulkDevice">The bulk device.</param> internal Top2005Plus(IShouter shouter, IUsbBulkDevice bulkDevice) : base(shouter, bulkDevice) { Func <double, byte, Tuple <double, byte> > t = Tuple.Create <double, byte>; VppLevels = new List <Tuple <double, byte> > { t(4.8, 0x00), t(6.9, 0x41), t(7.3, 0x46), t(7.5, 0x4B), t(8.8, 0x50), t(9.0, 0x5A), t(9.5, 0x5F), t(9.9, 0x64), t(10.4, 0x69), //t(4.8, 0x6E), t(12.0, 0x78), t(12.4, 0x7D), t(12.9, 0x82), t(13.4, 0x87), t(14.0, 0x8C), t(14.5, 0x91), t(15.0, 0x96), t(15.5, 0x9B), t(16.2, 0xA0), //t(4.8, 0xAA), t(20.9, 0xD2), //t(4.8, 0xD3), t(20.9, 0xFA), t(4.8, 0xFB) }; VccLevels = new List <Tuple <double, byte> > { //t(3.1, 0x00), t(4.9, 0x01), t(3.1, 0x19), t(3.6, 0x1F), t(4.3, 0x28), t(4.9, 0x2D) }; UpLoadFPGAProgramTopWin6Style(Config.ICTestBinPath); }
/// <summary> /// The main method for reading a rom that is defined in the Eproms.xml file. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="type">The type of the rom the be read.</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> public static IList <byte> RomRead(IShouter shouter, string type) { IList <byte> bytes = new List <byte>(); var eprom = EpromXml.Specified[type]; var totalNumberOfAdresses = eprom.AddressPins.Length == 0 ? 0 : 1 << eprom.AddressPins.Length; var startAddress = 0; using (var progressBar = new ProgressBar(shouter, totalNumberOfAdresses)) { while (startAddress < totalNumberOfAdresses) { using (var topDevice = TopDevice.Create(shouter)) { startAddress = topDevice.ReadEprom(eprom, progressBar, bytes, startAddress, totalNumberOfAdresses); } if (startAddress < totalNumberOfAdresses) { progressBar.Shout("Disposing Top USB interface and inits a new"); } } } return(bytes); }
/// <summary> /// Entry point for the 'prog' category of commands. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="args">Command line argumsnts</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> private static int Prog(IShouter shouter, IList <string> args) { if (args.Count == 1) { args.Insert(0, "help"); Help(shouter, args); return(0); } switch (args[1]) { case "id": Kernel.ProgId(shouter); return(0); case "stat": Kernel.ProgStat(shouter); return(0); default: shouter.ShoutLine(1, "Unknown prog command {0}", args[1]); return(1); } }
/// <summary> /// Opens a new instace of a bulk device using the constants specified for this Top Device. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <returns>The created instace of the bulk device.</returns> public static IUsbBulkDevice OpenBulkDevice(IShouter shouter) { return(new UsbBulkDevice(shouter, VendorId, ProductId, Configuration, Interface, ReadEndpointInt, WriteEndpointInt)); }
/// <summary> /// A simple SRAM test. /// </summary> /// <param name="shouter">Public shouter instance.</param> /// <param name="sram">The SRAM type.</param> /// <param name="progressBar">The progress bar.</param> /// <param name="totalNumberOfAdresses">The total number of adresses.</param> /// <param name="firstBit">The value of the first bit to write to the SRAM.</param> /// <returns>Tuples of non-working addresses: (address, read_byte, expected_byte).</returns> public List <Tuple <int, string, string> > OldSRamTest(IShouter shouter, SRam sram, ProgressBar progressBar, int totalNumberOfAdresses, bool firstBit) { var translator = sram.GetPinTranslator(ZIFType); SetVccLevel(sram.VccLevel); ApplyGnd(translator.ToZIF, sram.GndPins); ApplyVcc(translator.ToZIF, sram.VccPins); PullUpsEnable(true); var badCells = new List <Tuple <int, string, string> >(); var writerZif = new ZIFSocket(40); var startBit = firstBit; for (var address = 0; address < totalNumberOfAdresses; address++) { var bit = startBit; writerZif.SetAll(true); writerZif.Disable(sram.GndPins, translator.ToZIF); writerZif.Enable(sram.Constants, translator.ToZIF); writerZif.Enable(sram.ChipEnable, translator.ToZIF); sram.SetAddress(writerZif, address); foreach (var i in sram.DataPins.Select(translator.ToZIF)) { writerZif[i] = bit; bit = !bit; } startBit = !startBit; WriteZIF(writerZif, ""); writerZif.Enable(sram.WriteEnable, translator.ToZIF); WriteZIF(writerZif, ""); writerZif.Disable(sram.WriteEnable, translator.ToZIF); WriteZIF(writerZif, ""); progressBar.Progress(); } startBit = firstBit; for (var address = 0; address < totalNumberOfAdresses; address++) { var bit = startBit; writerZif.SetAll(true); writerZif.Disable(sram.GndPins, translator.ToZIF); writerZif.Enable(sram.Constants, translator.ToZIF); writerZif.Enable(sram.ChipEnable, translator.ToZIF); writerZif.Enable(sram.OutputEnable, translator.ToZIF); writerZif.Disable(sram.WriteEnable, translator.ToZIF); sram.SetAddress(writerZif, address); WriteZIF(writerZif, "Writing SRam address."); var readerZif = ReadZIF("Reading SRam data.")[0]; var dataOutPins = sram.DataOutPins.Length != 0 ? sram.DataOutPins : sram.DataPins; foreach (var i in dataOutPins.Select(translator.ToZIF)) { if (readerZif[i] != bit) { var expected = ""; var read = ""; bit = startBit; foreach (var j in dataOutPins.Select(translator.ToZIF)) { expected = expected + (bit ? "1" : "0"); read = read + (readerZif[j] ? "1" : "0"); bit = !bit; } badCells.Add(Tuple.Create(address, read, expected)); progressBar.Shout("Bad cell at address {0}", address.ToString("X4")); break; } bit = !bit; } startBit = !startBit; progressBar.Progress(); } return(badCells); }
/// <summary> /// Entry point for the 'rom' category of commands. /// </summary> /// <param name="shouter">The shouter instance.</param> /// <param name="args">Command line arguments</param> /// <returns>Exit code. 0 is fine; all other is bad.</returns> private static int Rom(IShouter shouter, IList <string> args) { if (args.Count == 1) { args.Insert(0, "help"); Help(shouter, args); return(0); } switch (args[1]) { case "all": var option = args.Count == 3 ? args[2] : null; return(Kernel.RomAll(shouter, option)); case "id": shouter.ShoutLine(1, "rom id not yet implemented!"); return(1); case "info": return(Kernel.RomInfo(shouter, args[2])); case "read": var data = Kernel.RomRead(shouter, args[2]); Tools.WriteBinaryFile(args[3], data); shouter.ShoutLine(2, "EPROM{0} data written to file {1}", args[2], args[3]); return(0); case "verify": var fileData = Tools.ReadBinaryFile(args[3]).ToArray(); var didntVerify = Kernel.RomVerify(shouter, args[2], fileData).ToArray(); if (didntVerify.Any()) { foreach (var tuple in didntVerify) { shouter.ShoutLine( 3, "Address {0} didn't verify. In file {1}, in EPROM {2}. Can{3} be patched", tuple.Item1.ToString("X4"), tuple.Item2.ToString("X2"), tuple.Item3.ToString("X2"), Tools.CanBePatched(tuple.Item2, tuple.Item3) ? "" : "'t"); } } if (didntVerify.Length == 0) { shouter.ShoutLine(2, "EPROM verifies nicely }};-)"); } return(0); case "write": fileData = Tools.ReadBinaryFile(args[3]).ToArray(); Kernel.RomWrite(shouter, args[2], fileData); shouter.ShoutLine(2, "Filedata from {0} written to EPROM", args[2], args[3]); return(0); default: shouter.ShoutLine(1, "Unknown rom command {0}", args[1]); return(1); } }
/// <summary> /// A simple SRAM test. /// </summary> /// <param name="shouter">Public shouter instance.</param> /// <param name="sram">The SRAM type.</param> /// <param name="progressBar">The progress bar.</param> /// <param name="passName">The name of the pass.</param> /// <param name="totalNumberOfAdresses">The total number of adresses.</param> /// <param name="dataGenerator">A device the generates values for addresses.</param> /// <returns>Tuples of non-working addresses: (address, read_byte, expected_byte).</returns> public List <Tuple <int, string, string> > SRamTestPass(IShouter shouter, SRam sram, ProgressBar progressBar, string passName, int totalNumberOfAdresses, IDataGenerator dataGenerator) { progressBar.Shout(passName); var translator = sram.GetPinTranslator(ZIFType); SetVccLevel(sram.VccLevel); ApplyGnd(translator.ToZIF, sram.GndPins); ApplyVcc(translator.ToZIF, sram.VccPins); PullUpsEnable(true); var badCells = new List <Tuple <int, string, string> >(); var writerZif = new ZIFSocket(40); for (var address = 0; address < totalNumberOfAdresses; address++) { writerZif.SetAll(true); writerZif.Disable(sram.GndPins, translator.ToZIF); writerZif.Enable(sram.Constants, translator.ToZIF); writerZif.Enable(sram.ChipEnable, translator.ToZIF); sram.SetAddress(writerZif, address); sram.SetData(writerZif, dataGenerator.GetData(address)); WriteZIF(writerZif, ""); writerZif.Enable(sram.WriteEnable, translator.ToZIF); WriteZIF(writerZif, ""); writerZif.Disable(sram.WriteEnable, translator.ToZIF); WriteZIF(writerZif, ""); progressBar.Progress(); } for (var address = 0; address < totalNumberOfAdresses; address++) { writerZif.SetAll(true); writerZif.Disable(sram.GndPins, translator.ToZIF); writerZif.Enable(sram.Constants, translator.ToZIF); writerZif.Enable(sram.ChipEnable, translator.ToZIF); writerZif.Enable(sram.OutputEnable, translator.ToZIF); writerZif.Disable(sram.WriteEnable, translator.ToZIF); sram.SetAddress(writerZif, address); WriteZIF(writerZif, "Writing SRam address."); var readerZif = ReadZIF("Reading SRam data.")[0]; var dataOutPins = sram.DataOutPins.Length != 0 ? sram.DataOutPins : sram.DataPins; var expectedData = dataGenerator.GetData(address); var addressBitCounter = 0; foreach (var i in dataOutPins.Select(translator.ToZIF)) { if (readerZif[i] != expectedData[addressBitCounter++]) { addressBitCounter = 0; var expected = ""; var read = ""; foreach (var j in dataOutPins.Select(translator.ToZIF)) { expected = expected + (expectedData[addressBitCounter++] ? "1" : "0"); read = read + (readerZif[j] ? "1" : "0"); } badCells.Add(Tuple.Create(address, read, expected)); progressBar.Shout("{0}: Bad cell at address {1}", passName, address.ToString("X4")); break; } } progressBar.Progress(); } return(badCells); }
/// <summary> /// Creates a new instance of the Top Device connected to the Top Programmer. /// <remarks>Atm. only works for model Top2005+.</remarks> /// </summary> /// <param name="shouter">The shouter instance.</param> /// <returns>The created instance of the Top Device.</returns> public static TopDevice Create(IShouter shouter) { return(Create(shouter, OpenBulkDevice(shouter))); }