/// <summary> /// Return a logically equivalent, (near) minimal cost set of product-terms to represent the ON-set and /// optionally minterms that lie in the DC-set, without containing any minterms of the OFF-set. /// </summary> /// <param name="cover"></param> /// <param name="type"></param> /// <returns></returns> public static unsafe IEspressoCover Espresso( IEspressoCover cover, EspressoCoverType type = EspressoCoverType.F_TYPE | EspressoCoverType.D_TYPE) { if (cover == null) { throw new ArgumentNullException(nameof(cover)); } if (cover.Count < 1) { throw new ArgumentException(nameof(cover)); } if (cover.Inputs.Count < 1) { throw new ArgumentException(nameof(cover)); } if (cover.Output.Count < 1) { throw new ArgumentException(nameof(cover)); } // default value for none type if (type == EspressoCoverType.None) { type = EspressoCoverType.F_TYPE | EspressoCoverType.D_TYPE; } if (!type.HasFlag(EspressoCoverType.F_TYPE) && !type.HasFlag(EspressoCoverType.R_TYPE)) throw new ArgumentOutOfRangeException(nameof(type), "Expected type in [F, R, FD, FR, DR, FDR]."); // obtain cover data and pin fixed(int *data = cover.ToTable()) { // invoke native method var ret = espressonet(new Native.net_cover_t() { ncubes = cover.Count, ninputs = cover.Inputs.Count, noutput = cover.Output.Count, data = data, }, (int)type); if (ret.data == null) { throw new EspressoException(); } // return managed wrapper return(new EspressoLibCover(ret.ncubes, ret.ninputs, ret.noutput, ret.data)); } }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="cover"></param> public PLA(IEspressoCover cover, EspressoCoverType coverType = EspressoCoverType.None) { Cover = cover ?? throw new System.ArgumentNullException(nameof(cover)); CoverType = coverType; }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="cover"></param> /// <param name="coverType"></param> /// <param name="inputs"></param> /// <param name="output"></param> public PLA(IEspressoCover cover, EspressoCoverType coverType, IEnumerable <string> inputs, IEnumerable <string> output) : this(cover, coverType) { InputsLabels = inputs?.ToList() ?? new List <string>(); OutputLabels = output?.ToList() ?? new List <string>(); }