public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { if (!instr.Name.Equals(InstructionCodes.RdPort)) { yield break; } var ts = taSite as DirectPortReadTransactionSite; if (ts == null) { yield break; } //if (ts.Host != _host) // yield break; var tgPort = (ISignalOrPortDescriptor)instr.Operand; if (!ts.Port.Equals(tgPort)) { yield break; } yield return(new DirectPortReadXILMapping(ts.Host, ts)); }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; Slicer slicer = fu as Slicer; if (slicer == null) { yield break; } bool isSigned; int inputWidth, hiOffset, loOffset; if (!GetSliceParams(instr, operandTypes, resultTypes, out isSigned, out inputWidth, out hiOffset, out loOffset)) { yield break; } if (slicer.IsSigned != isSigned) { yield break; } if (slicer.InputWidth != inputWidth) { yield break; } if (hiOffset != slicer.HiOffset || loOffset != slicer.LoOffset) { yield break; } yield return(new SlicerXILMapping(slicer)); }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; //if (fu != _host) // yield break; var taBM = taSite as InlineBCUTransactionSite; if (taBM == null) { yield break; } switch (instr.Name) { case InstructionCodes.Goto: yield return(new InlineBCUMapping(taBM, InstructionCodes.Goto, (BranchLabel)instr.Operand)); break; case InstructionCodes.BranchIfTrue: yield return(new InlineBCUMapping(taBM, InstructionCodes.BranchIfTrue, (BranchLabel)instr.Operand)); break; case InstructionCodes.BranchIfFalse: yield return(new InlineBCUMapping(taBM, InstructionCodes.BranchIfFalse, (BranchLabel)instr.Operand)); break; default: yield break; } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var scc = fu as SinCosLUTCore; if (scc == null) { yield break; } if (operandTypes.Length != 1 || resultTypes.Length != 2) { yield break; } var xType = TypeDescriptor.GetTypeOf(SFix.FromDouble(0.0, scc.XIntWidth, scc.XFracWidth)); var yType = TypeDescriptor.GetTypeOf(SFix.FromDouble(0.0, scc.YIntWidth, scc.YFracWidth)); if (!operandTypes[0].Equals(xType) || !resultTypes[0].Equals(yType) || !resultTypes[1].Equals(yType)) { yield break; } if (instr.Name != InstructionCodes.ScSinCos) { yield break; } yield return(new Mapping(scc)); }
public TAVerb(ITransactionSite target, ETVMode tmode, Action op) { Contract.Requires(target != null); Contract.Requires(op != null); Target = target; TMode = tmode; Op = op; }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var mapping = TryMapOne(taSite, instr, operandTypes, resultTypes); if (mapping != null) { yield return(mapping); } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var fna = fu as FloatNegAbs; if (fna == null) { yield break; } if (operandTypes.Length != 1 || resultTypes.Length != 1) { yield break; } int totalWidth; if (operandTypes[0].CILType.Equals(typeof(float)) && resultTypes[0].CILType.Equals(typeof(float))) { totalWidth = 32; } else if (operandTypes[0].CILType.Equals(typeof(double)) && resultTypes[0].CILType.Equals(typeof(double))) { totalWidth = 64; } else { yield break; } if (fna.TotalWidth != totalWidth) { yield break; } switch (fna.Operation) { case FloatNegAbs.EOperation.Abs: if (instr.Name != InstructionCodes.Abs) { yield break; } break; case FloatNegAbs.EOperation.Neg: if (instr.Name != InstructionCodes.Neg) { yield break; } break; default: throw new NotImplementedException(); } yield return(new Mapping(fna)); }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; FixFPMod1 fpmod1 = fu as FixFPMod1; if (fpmod1 == null) { yield break; } if (instr.Name != InstructionCodes.Mod2 && instr.Name != InstructionCodes.Rempow2) { yield break; } if (instr.Name == InstructionCodes.Rempow2) { int n = (int)instr.Operand; if (n != 0) { yield break; } } FixFormat infmt = GetFixFormat(operandTypes[0]); FixFormat outfmt = GetFixFormat(resultTypes[0]); if (infmt == null || outfmt == null) { yield break; } if (infmt.IntWidth < 2 || outfmt.IntWidth < 2) { yield break; } if (infmt.FracWidth != outfmt.FracWidth) { yield break; } if (infmt.IntWidth != fpmod1.InIntWidth) { yield break; } if (infmt.FracWidth != fpmod1.FracWidth) { yield break; } if (outfmt.IntWidth != fpmod1.OutIntWidth) { yield break; } yield return(new FPMod1XILMapping(fpmod1)); }
/// <summary> /// Constructs a new instance. /// </summary> /// <param name="target">transaction site on which verb is operated</param> /// <param name="tmode">mode of verb</param> /// <param name="op">relict of an out-dated concept, please specify () => { }</param> /// <param name="during">process which describes the active register transfers within the scope of the created verb</param> public TAVerb(ITransactionSite target, ETVMode tmode, Action op, IProcess during) { Contract.Requires <ArgumentNullException>(target != null, "target"); Contract.Requires <ArgumentNullException>(op != null, "op"); Target = target; TMode = tmode; Op = op; During = during; }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var fsas = fu as FloatSignAsSigned; if (fsas == null) { yield break; } if (instr.Name != InstructionCodes.Sign) { yield break; } int floatWidth; if (operandTypes[0].CILType.Equals(typeof(float))) { floatWidth = 32; } else if (operandTypes[0].CILType.Equals(typeof(double))) { floatWidth = 64; } else if (operandTypes[0].CILType.Equals(typeof(Signed)) || operandTypes[0].CILType.Equals(typeof(SFix))) { floatWidth = operandTypes[0].GetFixFormat().TotalWidth; } else { yield break; } if (floatWidth != fsas.FloatWidth) { yield break; } var fmt = resultTypes[0].GetFixFormat(); if (fmt == null || !fmt.IsSigned || fmt.IntWidth < 2) { yield break; } if (!fmt.Equals(fsas.OutFormat)) { yield break; } yield return(new Mapping(fsas)); }
public IXILMapping TryMapOne(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes, bool swap) { var fu = taSite.Host; var asub = fu as XilinxAdderSubtracter; if (asub == null) { return(null); } bool iisAdd = instr.Name == InstructionCodes.Add; bool iisSub = instr.Name == InstructionCodes.Sub; if ((asub.AddMode == XilinxAdderSubtracter.EAddMode.Add && !iisAdd) || (asub.AddMode == XilinxAdderSubtracter.EAddMode.Subtract && !iisSub) || (!iisAdd && !iisSub)) { return(null); } FixFormat fmta, fmtb, fmtr; fmta = GetFixFormat(operandTypes[0]); fmtb = GetFixFormat(operandTypes[1]); fmtr = GetFixFormat(resultTypes[0]); if (fmta == null || fmtb == null || fmtr == null) { return(null); } bool expectSigned = fmta.IsSigned || fmtb.IsSigned; if (expectSigned != fmtr.IsSigned) { return(null); } if (fmta.FracWidth != fmtb.FracWidth || fmtr.FracWidth != fmta.FracWidth) { return(null); } if (fmta.TotalWidth != asub.Awidth || fmtb.TotalWidth != asub.Bwidth || fmtr.TotalWidth != asub.OutWidth) { return(null); } return(new XILMapping(asub, iisAdd, swap)); }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; Shifter shifter = fu as Shifter; if (shifter == null) { yield break; } if (instr.Name != InstructionCodes.LShift && instr.Name != InstructionCodes.RShift) { yield break; } int fmtData = GetFixSize(operandTypes[0]); int fmtShift = GetFixSize(operandTypes[1]); int fmtResult = GetFixSize(resultTypes[0]); if (fmtData < 0 || fmtShift < 0 || fmtResult < 0) { yield break; } if (fmtData != fmtResult) { yield break; } if (shifter.DataWidth != fmtData || shifter.ShiftWidth != fmtShift) { yield break; } switch (instr.Name) { case InstructionCodes.LShift: yield return(new LShiftXILMapping(shifter)); break; case InstructionCodes.RShift: yield return(new RShiftXILMapping(shifter)); break; default: throw new NotImplementedException(); } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; //if (fu != _host) // yield break; var taNop = taSite as NopTASite; if (taNop == null) { yield break; } switch (instr.Name) { case InstructionCodes.Nop: case InstructionCodes.Barrier: if (instr.Operand is int) { yield return(new NopXILMapping(taNop, (int)instr.Operand)); } else { yield return(new NopXILMapping(taNop, 0)); } break; case InstructionCodes.Convert: if (TypeLowering.Instance.HasWireType(operandTypes[0]) && TypeLowering.Instance.HasWireType(resultTypes[0]) && !operandTypes[0].CILType.Equals(resultTypes[0].CILType)) { TypeDescriptor owt = TypeLowering.Instance.GetWireType(operandTypes[0]); TypeDescriptor rwt = TypeLowering.Instance.GetWireType(resultTypes[0]); if (!owt.Equals(rwt)) { yield break; } yield return(new IdXILMapping(taNop)); } else { yield break; } break; default: yield break; } }
public IXILMapping TryMapOne(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes, bool swap) { var fu = taSite.Host; XilinxMultiplier mul = fu as XilinxMultiplier; if (mul == null) { return(null); } if (instr.Name != InstructionCodes.Mul) { return(null); } if (mul.MultType != XilinxMultiplier.EMultiplierType.ParallelMultiplier) { return(null); } FixFormat fmta, fmtb, fmtr; fmta = GetFixFormat(operandTypes[0]); fmtb = GetFixFormat(operandTypes[1]); fmtr = GetFixFormat(resultTypes[0]); if (fmta == null || fmtb == null || fmtr == null) { return(null); } bool expectSigned = fmta.IsSigned || fmtb.IsSigned; if (expectSigned != fmtr.IsSigned) { return(null); } int expectedHigh = fmtr.IntWidth + fmta.FracWidth + fmtb.FracWidth - 1; int expectedLow = fmta.FracWidth + fmtb.FracWidth - fmtr.FracWidth; if (fmta.TotalWidth != mul.PortAWidth || fmtb.TotalWidth != mul.PortBWidth || expectedHigh != mul.OutputWidthHigh || expectedLow != mul.OutputWidthLow) { return(null); } return(new XILMapping(mul, swap)); }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var alt0 = TryMapOne(taSite, instr, operandTypes, resultTypes, false); var alt1 = TryMapOne(taSite, instr, new TypeDescriptor[] { operandTypes[1], operandTypes[0] }, resultTypes, true); if (alt0 != null) { yield return(alt0); } if (alt1 != null) { yield return(alt1); } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { StdLogicVector constSLV; if (!TryGetConstSLV(instr, resultTypes[0], out constSLV)) { yield break; } var fu = taSite.Host; ConstLoadingTransactionSite clts = new ConstLoadingTransactionSite(fu, constSLV, CreateSignalsForConstants); yield return(new ConstLoadingXILMapping(clts)); }
private void CreateCoStateValues() { foreach (var kvp in _coFSMs) { ITransactionSite target = kvp.Key; CoFSMInfo cfi = kvp.Value; string ename, fname; if (target.Name == null) { ename = "E_" + target.Host.Descriptor.Name + "_CoState"; fname = "m_" + target.Host.Descriptor.Name + "_CoState"; } else { ename = "E_" + target.Host.Descriptor.Name + "_" + target.Name + "_CoState"; fname = "m_" + target.Host.Descriptor.Name + "_" + target.Name + "_CoState"; } Type tState = CreateEnum(ename, cfi.TotalStates); TypeDescriptor tdState = (TypeDescriptor)tState; ComponentDescriptor owner = (ComponentDescriptor)_code.Owner; owner.AddChild(tdState, tdState.Name); Type tStateSignal = typeof(Signal <>).MakeGenericType(tState); FieldBuilder fbStateSignal = _tComponent.DefineField(fname, tStateSignal, FieldAttributes.Private); Array enumValues = tState.GetEnumValues(); object initVal; if (cfi.HasNeutralTA) { initVal = cfi.FirstNeutral.StateValue; } else { initVal = enumValues.GetValue(0); } var sdState = owner.CreateSignalInstance(fname, initVal); cfi.CoStateSignal = new SignalRef(sdState, SignalRef.EReferencedProperty.Instance); cfi.CoStateType = tStateSignal; cfi.NextCoState.PlaceHolder = new SignalRef(sdState, SignalRef.EReferencedProperty.Next); foreach (CoStateInfo csi in cfi.StateInfos) { csi.StateValue = enumValues.GetValue(csi.StateIndex); csi.StateExpr.PlaceHolder = LiteralReference.CreateConstant(csi.StateValue); } } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var far = instr.Operand as FixedArrayRef; if (far == null) { yield break; } var taMM = taSite as MemoryMapperTransactionSite; if (taMM == null) { yield break; } if (taMM.Array.ArrayObj != far.ArrayObj) { yield break; } switch (instr.Name) { case InstructionCodes.LdelemFixA: yield return(new LdelemFixAMapping(taMM)); break; case InstructionCodes.LdelemFixAFixI: yield return(new LdelemFixAFixIMapping(taMM, far.Indices)); break; case InstructionCodes.StelemFixA: yield return(new StelemFixAMapping(taMM)); break; case InstructionCodes.StelemFixAFixI: yield return(new StelemFixAFixIMapping(taMM, far.Indices)); break; default: yield break; } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { IFixedAbsTransactionSite fats = taSite as IFixedAbsTransactionSite; if (fats == null) { yield break; } if (instr.Name != InstructionCodes.Abs) { yield break; } var operandFormat = operandTypes[0].GetFixFormat(); if (operandFormat == null) { yield break; } var resultFormat = resultTypes[0].GetFixFormat(); if (resultFormat == null) { yield break; } if (operandFormat.FracWidth != resultFormat.FracWidth) { yield break; } if (operandFormat.TotalWidth != fats.Host.InputWidth) { yield break; } if (resultFormat.TotalWidth != fats.Host.OutputWidth) { yield break; } yield return(new AbsMapping(fats.Host)); }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; BCU bcu = fu as BCU; if (bcu != _host) { yield break; } switch (instr.Name) { case InstructionCodes.Goto: case InstructionCodes.BranchIfTrue: case InstructionCodes.BranchIfFalse: { var target = (BranchLabel)instr.Operand; switch (instr.Name) { case InstructionCodes.Goto: yield return(new GotoMapping(bcu, target)); yield break; case InstructionCodes.BranchIfTrue: yield return(new BranchIfMapping(bcu, target)); yield break; case InstructionCodes.BranchIfFalse: yield return(new BranchIfNotMapping(bcu, target)); yield break; default: throw new NotImplementedException(); } } default: yield break; } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { IXILMapping alt0, alt1 = null; alt0 = TryMapOne(taSite, instr, operandTypes, resultTypes, false); switch (instr.Name) { case InstructionCodes.Add: alt1 = TryMapOne(taSite, instr, new TypeDescriptor[] { operandTypes[1], operandTypes[0] }, resultTypes, true); break; } if (alt0 != null) { yield return(alt0); } if (alt1 != null) { yield return(alt1); } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var v = instr.Operand as FieldRef; if (v == null) { yield break; } var taLV = taSite as InlineFieldMapperTransactionSite; if (taLV == null) { yield break; } if (!taLV.Literal.Equals(v)) { yield break; } switch (instr.Name) { case InstructionCodes.LoadVar: yield return(new ReadXILMapping(taLV)); break; case InstructionCodes.StoreVar: yield return(new WriteXILMapping(taLV)); break; default: yield break; } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; if (instr.Name != InstructionCodes.Concat) { yield break; } int[] inWidths = operandTypes.Select(t => Marshal.SerializeForHW(t.GetSampleInstance()).Size).ToArray(); var key = new KeyClass(inWidths); var taCM = taSite as InlineConcatMapperTransactionSite; if (taCM == null) { yield break; } if (!taCM.ArgWidths.SequenceEqual(inWidths)) { yield break; } yield return(new ConcatMapping(taCM)); }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { if (!instr.Name.Equals(InstructionCodes.WrPort)) { yield break; } var pwSite = taSite as InlinePortWriteSite; if (pwSite == null) { yield break; } var tgPort = (ISignalOrPortDescriptor)instr.Operand; if (!tgPort.Equals(pwSite.TargetPort)) { yield break; } yield return(new InlinePortWriterXILMapping(pwSite)); }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; Concatenizer cc = fu as Concatenizer; if (cc == null) { yield break; } if (instr.Name != InstructionCodes.Concat) { yield break; } if (!operandTypes[0].CILType.Equals(typeof(StdLogicVector)) || !resultTypes[0].CILType.Equals(typeof(StdLogicVector))) { yield break; } if (!operandTypes.All(t => t.Equals(operandTypes[0]))) { yield break; } int wordWidth = (int)operandTypes[0].TypeParams[0]; if (cc.WordWidth != wordWidth || cc.NumWords != operandTypes.Length) { yield break; } yield return(new ConcatXILMapping(cc)); }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { if (!instr.Name.Equals(InstructionCodes.LoadVar) && !instr.Name.Equals(InstructionCodes.StoreVar)) { yield break; } var tgtVar = instr.Operand as Variable; if (tgtVar == null) { yield break; } var fu = taSite.Host; LocalStorageUnit lsu = fu as LocalStorageUnit; if (lsu == null) { yield break; } if (!lsu.MappedVariable.Equals(tgtVar)) { yield break; } if (instr.Name.Equals(InstructionCodes.LoadVar)) { yield return(new LocalStorageUnitReadMapping(lsu)); } else { yield return(new LocalStorageUnitWriteMapping(lsu)); } }
public IEnumerable <IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; MUX2 mux2 = fu as MUX2; if (mux2 == null) { yield break; } if (instr.Name != InstructionCodes.Select) { yield break; } int width = TypeLowering.Instance.GetWireWidth(operandTypes[1]); if (width != mux2.Width) { yield break; } yield return(new MUX2XILMapping(mux2.TASite)); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { IXILMapping alt0, alt1 = null; alt0 = TryMapOne(taSite, instr, operandTypes, resultTypes, false); switch (instr.Name) { case InstructionCodes.Add: alt1 = TryMapOne(taSite, instr, new TypeDescriptor[] { operandTypes[1], operandTypes[0] }, resultTypes, true); break; } if (alt0 != null) yield return alt0; if (alt1 != null) yield return alt1; }
public IXILMapping TryMapOne(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes, bool swap) { var fu = taSite.Host; var asub = fu as XilinxAdderSubtracter; if (asub == null) return null; bool iisAdd = instr.Name == InstructionCodes.Add; bool iisSub = instr.Name == InstructionCodes.Sub; if ((asub.AddMode == XilinxAdderSubtracter.EAddMode.Add && !iisAdd) || (asub.AddMode == XilinxAdderSubtracter.EAddMode.Subtract && !iisSub) || (!iisAdd && !iisSub)) return null; FixFormat fmta, fmtb, fmtr; fmta = GetFixFormat(operandTypes[0]); fmtb = GetFixFormat(operandTypes[1]); fmtr = GetFixFormat(resultTypes[0]); if (fmta == null || fmtb == null || fmtr == null) return null; bool expectSigned = fmta.IsSigned || fmtb.IsSigned; if (expectSigned != fmtr.IsSigned) return null; if (fmta.FracWidth != fmtb.FracWidth || fmtr.FracWidth != fmta.FracWidth) return null; if (fmta.TotalWidth != asub.Awidth || fmtb.TotalWidth != asub.Bwidth || fmtr.TotalWidth != asub.OutWidth) return null; return new XILMapping(asub, iisAdd, swap); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { StdLogicVector constSLV; if (!TryGetConstSLV(instr, resultTypes[0], out constSLV)) yield break; var fu = taSite.Host; ConstLoadingTransactionSite clts = new ConstLoadingTransactionSite(fu, constSLV, CreateSignalsForConstants); yield return new ConstLoadingXILMapping(clts); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; Slicer slicer = fu as Slicer; if (slicer == null) yield break; bool isSigned; int inputWidth, hiOffset, loOffset; if (!GetSliceParams(instr, operandTypes, resultTypes, out isSigned, out inputWidth, out hiOffset, out loOffset)) yield break; if (slicer.IsSigned != isSigned) yield break; if (slicer.InputWidth != inputWidth) yield break; if (hiOffset != slicer.HiOffset || loOffset != slicer.LoOffset) yield break; yield return new SlicerXILMapping(slicer); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; MUX2 mux2 = fu as MUX2; if (mux2 == null) yield break; if (instr.Name != InstructionCodes.Select) yield break; int width = TypeLowering.Instance.GetWireWidth(operandTypes[1]); if (width != mux2.Width) yield break; yield return new MUX2XILMapping(mux2.TASite); }
public IXILMapping TryMapOne(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; XilinxDivider divider = fu as XilinxDivider; if (divider == null) return null; if (instr.Name != InstructionCodes.Div && instr.Name != InstructionCodes.DivQF) return null; FixFormat fmtDividend = GetFixFormat(operandTypes[0]); FixFormat fmtDivisor = GetFixFormat(operandTypes[1]); FixFormat fmtQuotient = GetFixFormat(resultTypes[0]); FixFormat fmtFractional = null; if (instr.Name == InstructionCodes.DivQF) fmtFractional = GetFixFormat(resultTypes[1]); if (fmtDividend.IsSigned != fmtDivisor.IsSigned || fmtDividend.IsSigned != fmtQuotient.IsSigned) return null; if (fmtDividend.TotalWidth != fmtQuotient.TotalWidth) return null; int qFracWidth = fmtDividend.FracWidth - fmtDivisor.FracWidth; if (qFracWidth != fmtQuotient.FracWidth) return null; int fracWidth = 0; if (fmtFractional != null) fracWidth = fmtFractional.TotalWidth; if (divider.DividendAndQuotientWidth != fmtDividend.TotalWidth) return null; if (divider.DivisorWidth != fmtDivisor.TotalWidth) return null; if ((divider.OperandSign == XilinxDivider.ESignedness.Signed) != fmtDividend.IsSigned) return null; if (divider.FractionWidth != fracWidth) return null; return new DividerXILMapping(divider); }
public IXILMapping TryMapOne(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes, bool swap) { var fu = taSite.Host; XilinxMultiplier mul = fu as XilinxMultiplier; if (mul == null) return null; if (instr.Name != InstructionCodes.Mul) return null; if (mul.MultType != XilinxMultiplier.EMultiplierType.ParallelMultiplier) return null; FixFormat fmta, fmtb, fmtr; fmta = GetFixFormat(operandTypes[0]); fmtb = GetFixFormat(operandTypes[1]); fmtr = GetFixFormat(resultTypes[0]); if (fmta == null || fmtb == null || fmtr == null) return null; bool expectSigned = fmta.IsSigned || fmtb.IsSigned; if (expectSigned != fmtr.IsSigned) return null; int expectedHigh = fmtr.IntWidth + fmta.FracWidth + fmtb.FracWidth - 1; int expectedLow = fmta.FracWidth + fmtb.FracWidth - fmtr.FracWidth; if (fmta.TotalWidth != mul.PortAWidth || fmtb.TotalWidth != mul.PortBWidth || expectedHigh != mul.OutputWidthHigh || expectedLow != mul.OutputWidthLow) return null; return new XILMapping(mul, swap); }
public IXILMapping TryMapOne(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes, bool swap) { var fu = taSite.Host; FloatingPointCore fpu = (FloatingPointCore)fu; if (fpu == null) return null; if (operandTypes.Length != fpu.Arity) return null; if (fpu.Function == FloatingPointCore.EFunction.AddSubtract || fpu.Function == FloatingPointCore.EFunction.Compare || fpu.Function == FloatingPointCore.EFunction.Divide || fpu.Function == FloatingPointCore.EFunction.FloatToFixed || fpu.Function == FloatingPointCore.EFunction.FloatToFloat || fpu.Function == FloatingPointCore.EFunction.Multiply || fpu.Function == FloatingPointCore.EFunction.SquareRoot) { Type itype = null; switch (fpu.Precision) { case FloatingPointCore.EPrecision.Single: itype = typeof(float); break; case FloatingPointCore.EPrecision.Double: itype = typeof(double); break; default: return null; } foreach (TypeDescriptor otype in operandTypes) if (!otype.CILType.Equals(itype)) return null; } Func<ISignalSource<StdLogicVector>[], ISignalSink<StdLogicVector>[], IEnumerable<TAVerb>> realize = null; ISignalSource<StdLogicVector> defOp = SignalSource.Create(StdLogicVector._0s(fpu.OperandWidth)); ISignalSink<StdLogicVector> defR = SignalSink.Nil<StdLogicVector>(); switch (fpu.Function) { case FloatingPointCore.EFunction.AddSubtract: if (instr.Name.Equals(InstructionCodes.Add) && (fpu.AddSubSel == FloatingPointCore.EAddSub.Add || fpu.AddSubSel == FloatingPointCore.EAddSub.Both)) { realize = (os, rs) => fpu.TASite.Add(os[0], os[1], rs[0]); } else if (instr.Name.Equals(InstructionCodes.Sub) && (fpu.AddSubSel == FloatingPointCore.EAddSub.Subtract || fpu.AddSubSel == FloatingPointCore.EAddSub.Both)) { realize = (os, rs) => fpu.TASite.Sub(os[0], os[1], rs[0]); } else return null; break; case FloatingPointCore.EFunction.Compare: if (instr.Name.Equals(InstructionCodes.IsLt)) { realize = (os, rs) => fpu.TASite.IsLt(os[0], os[1], rs[0]); } else if (instr.Name.Equals(InstructionCodes.IsLte)) { realize = (os, rs) => fpu.TASite.IsLte(os[0], os[1], rs[0]); } else if (instr.Name.Equals(InstructionCodes.IsEq)) { realize = (os, rs) => fpu.TASite.IsEq(os[0], os[1], rs[0]); } else if (instr.Name.Equals(InstructionCodes.IsNEq)) { realize = (os, rs) => fpu.TASite.IsNEq(os[0], os[1], rs[0]); } else if (instr.Name.Equals(InstructionCodes.IsGte)) { realize = (os, rs) => fpu.TASite.IsGte(os[0], os[1], rs[0]); } else if (instr.Name.Equals(InstructionCodes.IsGt)) { realize = (os, rs) => fpu.TASite.IsGt(os[0], os[1], rs[0]); } else { return null; } break; case FloatingPointCore.EFunction.Divide: if (instr.Name.Equals(InstructionCodes.Div)) { realize = (os, rs) => fpu.TASite.Div(os[0], os[1], rs[0]); } else return null; break; case FloatingPointCore.EFunction.FixedToFloat: if (instr.Name.Equals(InstructionCodes.Convert)) { if (!operandTypes[0].CILType.Equals(typeof(SFix)) && !operandTypes[0].CILType.Equals(typeof(Signed))) return null; FixFormat ffmt = SFix.GetFormat(operandTypes[0]); if (ffmt.IntWidth != fpu.ExponentWidth || ffmt.FracWidth != fpu.FractionWidth) return null; switch (fpu.ResultPrecision) { case FloatingPointCore.EPrecision.Single: if (!resultTypes[0].CILType.Equals(typeof(float))) return null; break; case FloatingPointCore.EPrecision.Double: if (!resultTypes[0].CILType.Equals(typeof(double))) return null; break; default: return null; } realize = (os, rs) => fpu.TASite.Fix2Float(os[0], rs[0]); } else return null; break; case FloatingPointCore.EFunction.FloatToFixed: if (instr.Name.Equals(InstructionCodes.Convert)) { if (!resultTypes[0].CILType.Equals(typeof(SFix)) && !resultTypes[0].CILType.Equals(typeof(Signed))) return null; FixFormat ffmt = SFix.GetFormat(resultTypes[0]); if (ffmt.IntWidth != fpu.ResultExponentWidth || ffmt.FracWidth != fpu.ResultFractionWidth) return null; switch (fpu.Precision) { case FloatingPointCore.EPrecision.Single: if (!operandTypes[0].CILType.Equals(typeof(float))) return null; break; case FloatingPointCore.EPrecision.Double: if (!operandTypes[0].CILType.Equals(typeof(double))) return null; break; default: return null; } realize = (os, rs) => fpu.TASite.Float2Fix(os[0], rs[0]); } else return null; break; case FloatingPointCore.EFunction.FloatToFloat: if (instr.Name.Equals(InstructionCodes.Convert)) { switch (fpu.Precision) { case FloatingPointCore.EPrecision.Single: if (!operandTypes[0].CILType.Equals(typeof(float))) return null; break; case FloatingPointCore.EPrecision.Double: if (!operandTypes[0].CILType.Equals(typeof(double))) return null; break; default: return null; } switch (fpu.ResultPrecision) { case FloatingPointCore.EPrecision.Single: if (!resultTypes[0].CILType.Equals(typeof(float))) return null; break; case FloatingPointCore.EPrecision.Double: if (!resultTypes[0].CILType.Equals(typeof(double))) return null; break; default: return null; } realize = (os, rs) => fpu.TASite.Float2Float(os[0], rs[0]); } else return null; break; case FloatingPointCore.EFunction.Multiply: if (instr.Name.Equals(InstructionCodes.Mul)) { realize = (os, rs) => fpu.TASite.Mul(os[0], os[1], rs[0]); } else return null; break; case FloatingPointCore.EFunction.SquareRoot: if (instr.Name.Equals(InstructionCodes.Sqrt)) { realize = (os, rs) => fpu.TASite.Sqrt(os[0], rs[0]); } else return null; break; default: throw new NotImplementedException(); } return new XILMapping(fpu.TASite, realize, swap); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; Shifter shifter = fu as Shifter; if (shifter == null) yield break; if (instr.Name != InstructionCodes.LShift && instr.Name != InstructionCodes.RShift) yield break; int fmtData = GetFixSize(operandTypes[0]); int fmtShift = GetFixSize(operandTypes[1]); int fmtResult = GetFixSize(resultTypes[0]); if (fmtData < 0 || fmtShift < 0 || fmtResult < 0) yield break; if (fmtData != fmtResult) yield break; if (shifter.DataWidth != fmtData || shifter.ShiftWidth != fmtShift) yield break; switch (instr.Name) { case InstructionCodes.LShift: yield return new LShiftXILMapping(shifter); break; case InstructionCodes.RShift: yield return new RShiftXILMapping(shifter); break; default: throw new NotImplementedException(); } }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var scc = fu as SinCosLUTCore; if (scc == null) yield break; if (operandTypes.Length != 1 || resultTypes.Length != 2) yield break; var xType = TypeDescriptor.GetTypeOf(SFix.FromDouble(0.0, scc.XIntWidth, scc.XFracWidth)); var yType = TypeDescriptor.GetTypeOf(SFix.FromDouble(0.0, scc.YIntWidth, scc.YFracWidth)); if (!operandTypes[0].Equals(xType) || !resultTypes[0].Equals(yType) || !resultTypes[1].Equals(yType)) yield break; if (instr.Name != InstructionCodes.ScSinCos) yield break; yield return new Mapping(scc); }
public IXILMapping TryMapOne(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; XilinxDivider divider = fu as XilinxDivider; if (divider == null) { return(null); } if (instr.Name != InstructionCodes.Div && instr.Name != InstructionCodes.DivQF) { return(null); } FixFormat fmtDividend = GetFixFormat(operandTypes[0]); FixFormat fmtDivisor = GetFixFormat(operandTypes[1]); FixFormat fmtQuotient = GetFixFormat(resultTypes[0]); FixFormat fmtFractional = null; if (instr.Name == InstructionCodes.DivQF) { fmtFractional = GetFixFormat(resultTypes[1]); } if (fmtDividend.IsSigned != fmtDivisor.IsSigned || fmtDividend.IsSigned != fmtQuotient.IsSigned) { return(null); } if (fmtDividend.TotalWidth != fmtQuotient.TotalWidth) { return(null); } int qFracWidth = fmtDividend.FracWidth - fmtDivisor.FracWidth; if (qFracWidth != fmtQuotient.FracWidth) { return(null); } int fracWidth = 0; if (fmtFractional != null) { fracWidth = fmtFractional.TotalWidth; } if (divider.DividendAndQuotientWidth != fmtDividend.TotalWidth) { return(null); } if (divider.DivisorWidth != fmtDivisor.TotalWidth) { return(null); } if ((divider.OperandSign == XilinxDivider.ESignedness.Signed) != fmtDividend.IsSigned) { return(null); } if (divider.FractionWidth != fracWidth) { return(null); } return(new DividerXILMapping(divider)); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var fsas = fu as FloatSignAsSigned; if (fsas == null) yield break; if (instr.Name != InstructionCodes.Sign) yield break; int floatWidth; if (operandTypes[0].CILType.Equals(typeof(float))) floatWidth = 32; else if (operandTypes[0].CILType.Equals(typeof(double))) floatWidth = 64; else if (operandTypes[0].CILType.Equals(typeof(Signed)) || operandTypes[0].CILType.Equals(typeof(SFix))) floatWidth = operandTypes[0].GetFixFormat().TotalWidth; else yield break; if (floatWidth != fsas.FloatWidth) yield break; var fmt = resultTypes[0].GetFixFormat(); if (fmt == null || !fmt.IsSigned || fmt.IntWidth < 2) yield break; if (!fmt.Equals(fsas.OutFormat)) yield break; yield return new Mapping(fsas); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; //if (fu != _host) // yield break; var taBM = taSite as InlineBCUTransactionSite; if (taBM == null) yield break; switch (instr.Name) { case InstructionCodes.Goto: yield return new InlineBCUMapping(taBM, InstructionCodes.Goto, (BranchLabel)instr.Operand); break; case InstructionCodes.BranchIfTrue: yield return new InlineBCUMapping(taBM, InstructionCodes.BranchIfTrue, (BranchLabel)instr.Operand); break; case InstructionCodes.BranchIfFalse: yield return new InlineBCUMapping(taBM, InstructionCodes.BranchIfFalse, (BranchLabel)instr.Operand); break; default: yield break; } }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; if (instr.Name != InstructionCodes.Concat) yield break; int[] inWidths = operandTypes.Select(t => Marshal.SerializeForHW(t.GetSampleInstance()).Size).ToArray(); var key = new KeyClass(inWidths); var taCM = taSite as InlineConcatMapperTransactionSite; if (taCM == null) yield break; if (!taCM.ArgWidths.SequenceEqual(inWidths)) yield break; yield return new ConcatMapping(taCM); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var mappers = _mlookup.Get(instr.Name); return mappers.SelectMany(m => m.TryMap(taSite, instr, operandTypes, resultTypes)); }
/// <summary> /// Constructs an instance. /// </summary> /// <param name="taSite">transaction site to carry out the mapping</param> /// <param name="resourceKind">resource classification</param> public DefaultXILMapping(ITransactionSite taSite, EMappingKind resourceKind) { TASite = taSite; ResourceKind = resourceKind; }
/// <summary> /// Constructs a new instance. /// </summary> /// <param name="target">transaction site on which verb is operated</param> /// <param name="tmode">mode of verb</param> /// <param name="op">relict of an out-dated concept, please specify () => { }</param> /// <param name="during">process which describes the active register transfers within the scope of the created verb</param> public TAVerb(ITransactionSite target, ETVMode tmode, Action op, IProcess during) { Contract.Requires<ArgumentNullException>(target != null, "target"); Contract.Requires<ArgumentNullException>(op != null, "op"); Target = target; TMode = tmode; Op = op; During = during; }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var alt0 = TryMapOne(taSite, instr, operandTypes, resultTypes, false); var alt1 = TryMapOne(taSite, instr, new TypeDescriptor[] { operandTypes[1], operandTypes[0] }, resultTypes, true); if (alt0 != null) yield return alt0; if (alt1 != null) yield return alt1; }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var mapping = TryMapOne(taSite, instr, operandTypes, resultTypes); if (mapping != null) yield return mapping; }
/// <summary> /// Creates an instruction which writes to memory /// </summary> /// <param name="site">memory transaction site</param> public XILInstr WrMem(ITransactionSite site) { return(new XILInstr(InstructionCodes.WrMem, site)); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var far = instr.Operand as FixedArrayRef; if (far == null) yield break; var taMM = taSite as MemoryMapperTransactionSite; if (taMM == null) yield break; if (taMM.Array.ArrayObj != far.ArrayObj) yield break; switch (instr.Name) { case InstructionCodes.LdelemFixA: yield return new LdelemFixAMapping(taMM); break; case InstructionCodes.LdelemFixAFixI: yield return new LdelemFixAFixIMapping(taMM, far.Indices); break; case InstructionCodes.StelemFixA: yield return new StelemFixAMapping(taMM); break; case InstructionCodes.StelemFixAFixI: yield return new StelemFixAFixIMapping(taMM, far.Indices); break; default: yield break; } }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; //if (fu != _host) // yield break; var taNop = taSite as NopTASite; if (taNop == null) yield break; switch (instr.Name) { case InstructionCodes.Nop: case InstructionCodes.Barrier: if (instr.Operand is int) yield return new NopXILMapping(taNop, (int)instr.Operand); else yield return new NopXILMapping(taNop, 0); break; case InstructionCodes.Convert: if (TypeLowering.Instance.HasWireType(operandTypes[0]) && TypeLowering.Instance.HasWireType(resultTypes[0]) && !operandTypes[0].CILType.Equals(resultTypes[0].CILType)) { TypeDescriptor owt = TypeLowering.Instance.GetWireType(operandTypes[0]); TypeDescriptor rwt = TypeLowering.Instance.GetWireType(resultTypes[0]); if (!owt.Equals(rwt)) yield break; yield return new IdXILMapping(taNop); } else { yield break; } break; default: yield break; } }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var v = instr.Operand as FieldRef; if (v == null) yield break; var taLV = taSite as InlineFieldMapperTransactionSite; if (taLV == null) yield break; if (!taLV.Literal.Equals(v)) yield break; switch (instr.Name) { case InstructionCodes.LoadVar: yield return new ReadXILMapping(taLV); break; case InstructionCodes.StoreVar: yield return new WriteXILMapping(taLV); break; default: yield break; } }
private IXILMapping TryMapOne(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes, bool swap) { var fu = taSite.Host; ALU alu = fu as ALU; if (alu == null) return null; if (resultTypes.Length != 1) return null; TypeDescriptor rtype = resultTypes[0]; if (!rtype.IsComplete) return null; if (!CheckFixCompliance(instr, operandTypes, resultTypes)) return null; int rsize = TypeLowering.Instance.GetWireWidth(rtype); int[] osizes = operandTypes.Select(t => TypeLowering.Instance.GetWireWidth(t)).ToArray(); Func<ISignalSource<StdLogicVector>[], ISignalSink<StdLogicVector>[], IEnumerable<TAVerb>> realize; if (operandTypes.Length == 1) { realize = (os, rs) => alu.Transactor.Do(os[0], rs[0]); TypeDescriptor otype = operandTypes[0]; long osize = osizes[0]; switch (instr.Name) { case InstructionCodes.Neg: if (alu.FuncSel != ALU.EFunction.Neg) return null; if ((!otype.CILType.Equals(typeof(Signed)) || !rtype.CILType.Equals(typeof(Signed))) && (!otype.CILType.Equals(typeof(SFix)) || !rtype.CILType.Equals(typeof(SFix)))) return null; if (alu.AWidth != osize || alu.RWidth != rsize) return null; break; case InstructionCodes.Not: if (alu.FuncSel != ALU.EFunction.Not) return null; if (!otype.CILType.Equals(typeof(StdLogicVector)) || !rtype.CILType.Equals(typeof(StdLogicVector))) return null; if (alu.AWidth != osize || alu.RWidth != osize) return null; break; default: return null; } } else { realize = (os, rs) => alu.Transactor.Do(os[0], os[1], rs[0]); TypeDescriptor otype0 = operandTypes[0]; TypeDescriptor otype1 = operandTypes[1]; long osize0 = osizes[0]; long osize1 = osizes[1]; if (alu.AWidth != osize0 || alu.BWidth != osize1 || (alu.FuncSel != ALU.EFunction.Compare && alu.RWidth != rsize)) return null; bool isArith = false; switch (instr.Name) { case InstructionCodes.Add: case InstructionCodes.Sub: case InstructionCodes.Mul: isArith = true; goto case InstructionCodes.IsLt; case InstructionCodes.IsLt: case InstructionCodes.IsLte: case InstructionCodes.IsEq: case InstructionCodes.IsNEq: case InstructionCodes.IsGte: case InstructionCodes.IsGt: switch (alu.ArithMode) { case ALU.EArithMode.Signed: if ((!otype0.CILType.Equals(typeof(Signed)) || !otype1.CILType.Equals(typeof(Signed)) || (isArith && !rtype.CILType.Equals(typeof(Signed))) || (!isArith && !rtype.CILType.Equals(typeof(bool)) && !rtype.CILType.Equals(typeof(StdLogicVector)))) && (!otype0.CILType.Equals(typeof(SFix)) || !otype1.CILType.Equals(typeof(SFix)) || (isArith && !rtype.CILType.Equals(typeof(SFix))) || (!isArith && !rtype.CILType.Equals(typeof(bool)) && !rtype.CILType.Equals(typeof(StdLogicVector))))) return null; break; case ALU.EArithMode.Unsigned: if ((!(otype0.CILType.Equals(typeof(Unsigned)) || otype0.CILType.Equals(typeof(StdLogicVector))) || !(otype1.CILType.Equals(typeof(Unsigned)) || otype1.CILType.Equals(typeof(StdLogicVector))) || (isArith && !(rtype.CILType.Equals(typeof(Unsigned)) || rtype.CILType.Equals(typeof(StdLogicVector)))) || (!isArith && !rtype.CILType.Equals(typeof(bool)) && !rtype.CILType.Equals(typeof(StdLogicVector)))) && (!(otype0.CILType.Equals(typeof(UFix)) || otype0.CILType.Equals(typeof(StdLogicVector)) || otype0.CILType.Equals(typeof(StdLogic))) || !(otype1.CILType.Equals(typeof(UFix)) || otype1.CILType.Equals(typeof(StdLogicVector)) || otype1.CILType.Equals(typeof(StdLogic))) || (isArith && !rtype.CILType.Equals(typeof(UFix))) || (!isArith && !rtype.CILType.Equals(typeof(bool)) && !rtype.CILType.Equals(typeof(StdLogicVector))))) return null; break; default: throw new NotImplementedException(); } switch (alu.FuncSel) { case ALU.EFunction.Add: if (!instr.Name.Equals(InstructionCodes.Add)) return null; break; case ALU.EFunction.Sub: if (!instr.Name.Equals(InstructionCodes.Sub)) return null; break; case ALU.EFunction.Mul: if (!instr.Name.Equals(InstructionCodes.Mul)) return null; break; case ALU.EFunction.Compare: switch (instr.Name) { case InstructionCodes.IsLt: realize = (os, rs) => alu.Transactor.IsLt(os[0], os[1], rs[0]); break; case InstructionCodes.IsLte: realize = (os, rs) => alu.Transactor.IsLte(os[0], os[1], rs[0]); break; case InstructionCodes.IsEq: realize = (os, rs) => alu.Transactor.IsEq(os[0], os[1], rs[0]); break; case InstructionCodes.IsNEq: realize = (os, rs) => alu.Transactor.IsNEq(os[0], os[1], rs[0]); break; case InstructionCodes.IsGte: realize = (os, rs) => alu.Transactor.IsGte(os[0], os[1], rs[0]); break; case InstructionCodes.IsGt: realize = (os, rs) => alu.Transactor.IsGt(os[0], os[1], rs[0]); break; default: return null; } break; } break; case InstructionCodes.And: if (alu.FuncSel != ALU.EFunction.And) return null; break; case InstructionCodes.Or: if (alu.FuncSel != ALU.EFunction.Or) return null; break; } } return new ALUXILMapping(alu.Transactor, realize, swap); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; var fna = fu as FloatNegAbs; if (fna == null) yield break; if (operandTypes.Length != 1 || resultTypes.Length != 1) yield break; int totalWidth; if (operandTypes[0].CILType.Equals(typeof(float)) && resultTypes[0].CILType.Equals(typeof(float))) totalWidth = 32; else if (operandTypes[0].CILType.Equals(typeof(double)) && resultTypes[0].CILType.Equals(typeof(double))) totalWidth = 64; else yield break; if (fna.TotalWidth != totalWidth) yield break; switch (fna.Operation) { case FloatNegAbs.EOperation.Abs: if (instr.Name != InstructionCodes.Abs) yield break; break; case FloatNegAbs.EOperation.Neg: if (instr.Name != InstructionCodes.Neg) yield break; break; default: throw new NotImplementedException(); } yield return new Mapping(fna); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { IXILMapping alt0 = null, alt1 = null; alt0 = TryMapOne(taSite, instr, operandTypes, resultTypes, false); switch (instr.Name) { case InstructionCodes.Add: case InstructionCodes.Mul: case InstructionCodes.And: case InstructionCodes.Or: case InstructionCodes.IsEq: case InstructionCodes.IsNEq: // These operations are commutative => "a op b", "b op a" are both feasible alt1 = TryMapOne(taSite, instr, new TypeDescriptor[] { operandTypes[1], operandTypes[0] }, resultTypes, true); break; case InstructionCodes.IsGt: alt1 = TryMapOne(taSite, DefaultInstructionSet.Instance.IsLt(), new TypeDescriptor[] { operandTypes[1], operandTypes[0] }, resultTypes, true); break; case InstructionCodes.IsGte: alt1 = TryMapOne(taSite, DefaultInstructionSet.Instance.IsLte(), new TypeDescriptor[] { operandTypes[1], operandTypes[0] }, resultTypes, true); break; case InstructionCodes.IsLt: alt1 = TryMapOne(taSite, DefaultInstructionSet.Instance.IsGt(), new TypeDescriptor[] { operandTypes[1], operandTypes[0] }, resultTypes, true); break; case InstructionCodes.IsLte: alt1 = TryMapOne(taSite, DefaultInstructionSet.Instance.IsGte(), new TypeDescriptor[] { operandTypes[1], operandTypes[0] }, resultTypes, true); break; } if (alt0 != null) yield return alt0; if (alt1 != null) yield return alt1; }
public ALUXILMapping(ITransactionSite transactor, Func<ISignalSource<StdLogicVector>[], ISignalSink<StdLogicVector>[], IEnumerable<TAVerb>> realize, bool swap) { _taSite = transactor; _realize = realize; _swap = swap; }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; FixFPMod1 fpmod1 = fu as FixFPMod1; if (fpmod1 == null) yield break; if (instr.Name != InstructionCodes.Mod2 && instr.Name != InstructionCodes.Rempow2) yield break; if (instr.Name == InstructionCodes.Rempow2) { int n = (int)instr.Operand; if (n != 0) yield break; } FixFormat infmt = GetFixFormat(operandTypes[0]); FixFormat outfmt = GetFixFormat(resultTypes[0]); if (infmt == null || outfmt == null) yield break; if (infmt.IntWidth < 2 || outfmt.IntWidth < 2) yield break; if (infmt.FracWidth != outfmt.FracWidth) yield break; if (infmt.IntWidth != fpmod1.InIntWidth) yield break; if (infmt.FracWidth != fpmod1.FracWidth) yield break; if (outfmt.IntWidth != fpmod1.OutIntWidth) yield break; yield return new FPMod1XILMapping(fpmod1); }
private ReservationTable CreateReservationTable(ITransactionSite taSite) { return new ReservationTable(); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { IFixedAbsTransactionSite fats = taSite as IFixedAbsTransactionSite; if (fats == null) yield break; if (instr.Name != InstructionCodes.Abs) yield break; var operandFormat = operandTypes[0].GetFixFormat(); if (operandFormat == null) yield break; var resultFormat = resultTypes[0].GetFixFormat(); if (resultFormat == null) yield break; if (operandFormat.FracWidth != resultFormat.FracWidth) yield break; if (operandFormat.TotalWidth != fats.Host.InputWidth) yield break; if (resultFormat.TotalWidth != fats.Host.OutputWidth) yield break; yield return new AbsMapping(fats.Host); }
public IEnumerable<IXILMapping> TryMap(ITransactionSite taSite, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes) { var fu = taSite.Host; Concatenizer cc = fu as Concatenizer; if (cc == null) yield break; if (instr.Name != InstructionCodes.Concat) yield break; if (!operandTypes[0].CILType.Equals(typeof(StdLogicVector)) || !resultTypes[0].CILType.Equals(typeof(StdLogicVector))) yield break; if (!operandTypes.All(t => t.Equals(operandTypes[0]))) yield break; int wordWidth = (int)operandTypes[0].TypeParams[0]; if (cc.WordWidth != wordWidth || cc.NumWords != operandTypes.Length) yield break; yield return new ConcatXILMapping(cc); }