private InstructionDependency[] Convert(InstructionDependency[] preds, TypeDescriptor from, TypeDescriptor to) { if (from.Equals(to)) { // nothing to do return(preds); } else if (IsSFix(from) && IsUFix(to)) { var fromFmt = SFix.GetFormat(from); var toFmt = UFix.GetFormat(to); int interIW = toFmt.IntWidth + 1; int interFW = toFmt.FracWidth; if (interIW != fromFmt.IntWidth || interFW != fromFmt.FracWidth) { var interType = SFix.MakeType(interIW, interFW); Emit(DefaultInstructionSet.Instance.Convert().CreateStk(preds, 1, from, interType)); Emit(DefaultInstructionSet.Instance.Convert().CreateStk(1, interType, to)); } else { Emit(DefaultInstructionSet.Instance.Convert().CreateStk(preds, 1, from, to)); } return(new InstructionDependency[0]); } else if (IsUFix(from) && IsSFix(to)) { var fromFmt = UFix.GetFormat(from); var toFmt = SFix.GetFormat(to); int interIW = toFmt.IntWidth - 1; int interFW = toFmt.FracWidth; if (interIW != fromFmt.IntWidth || interFW != fromFmt.FracWidth) { var interType = UFix.MakeType(interIW, interFW); Emit(DefaultInstructionSet.Instance.Convert().CreateStk(preds, 1, from, interType)); Emit(DefaultInstructionSet.Instance.Convert().CreateStk(1, interType, to)); } else { Emit(DefaultInstructionSet.Instance.Convert().CreateStk(preds, 1, from, to)); } return(new InstructionDependency[0]); } else if (IsSLV(from)) { int wfrom = TypeLowering.Instance.GetWireWidth(from); int wto = TypeLowering.Instance.GetWireWidth(to); if (wfrom == wto) { Emit(DefaultInstructionSet.Instance.Convert().CreateStk(preds, 1, from, to)); } else { var interType = StdLogicVector.MakeType(wto); Emit(DefaultInstructionSet.Instance.Convert().CreateStk(preds, 1, from, interType)); Convert(interType, to); } return(new InstructionDependency[0]); } else if (IsSLV(to)) { int wfrom = TypeLowering.Instance.GetWireWidth(from); int wto = TypeLowering.Instance.GetWireWidth(to); if (wfrom == wto) { Emit(DefaultInstructionSet.Instance.Convert().CreateStk(preds, 1, from, to)); } else { var interType = StdLogicVector.MakeType(wfrom); Emit(DefaultInstructionSet.Instance.Convert().CreateStk(preds, 1, from, interType)); Convert(interType, to); } return(new InstructionDependency[0]); } else { Emit(DefaultInstructionSet.Instance.Convert().CreateStk(preds, 1, from, to)); return(new InstructionDependency[0]); } }