private static TypeDescriptor[] ReduceTypes(TypeDescriptor[] types) { Contract.Requires<ArgumentException>(types != null); return types .Select(t => TypeLowering.Instance.GetHardwareType(t)) .ToArray(); }
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 IXILMapping TryAllocate(Component host, XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes, IProject targetProject) { if (instr.Name != InstructionCodes.Concat) return null; int[] inWidths = operandTypes.Select(t => Marshal.SerializeForHW(t.GetSampleInstance()).Size).ToArray(); var key = new KeyClass(inWidths); InlineConcatMapperTransactionSite taSite = new InlineConcatMapperTransactionSite(this, host, inWidths); return new ConcatMapping(taSite); }
private TypeDescriptor GetNativeResultType(XILSInstr i, TypeDescriptor[] otypes) { Contract.Requires<ArgumentNullException>(i != null); Contract.Requires<ArgumentNullException>(otypes != null); Contract.Requires<ArgumentException>(i.OperandTypes.Length == otypes.Length); var exprs = otypes .Select(t => new LiteralReference(new Variable(t))) .ToArray(); Expression rexpr; var oldMode = DesignContext.Instance.FixPoint.ArithSizingMode; DesignContext.Instance.FixPoint.ArithSizingMode = EArithSizingMode.VHDLCompliant; switch (i.Name) { case InstructionCodes.Add: rexpr = exprs[0] + exprs[1]; break; case InstructionCodes.Sub: rexpr = exprs[0] - exprs[1]; break; case InstructionCodes.Mul: rexpr = exprs[0] * exprs[1]; break; case InstructionCodes.Div: rexpr = exprs[0] / exprs[1]; break; case InstructionCodes.Neg: rexpr = -exprs[0]; break; default: throw new NotImplementedException(); } var result = rexpr.ResultType; DesignContext.Instance.FixPoint.ArithSizingMode = oldMode; return result; }