public static string GetRealLiteralOperand(RealLiteral expression, VHDLCompilerInterface compiler) { string value = expression.RealValue.ToString(CultureInfo.InvariantCulture); NewStatementTemplate template = new NewStatementTemplate("VHDLFloatingPointValue", value); return(template.TransformText()); }
public static string GetPhysicalLiteralOperand(PhysicalLiteral expression, VHDLCompilerInterface compiler) { string unitName = string.Format("\"{0}\"", expression.Unit); Int64 val = (expression.Value as IntegerLiteral).IntegerValue; string physType = compiler.TypeDictionary[expression.GetPhysicalType()]; NewStatementTemplate template = new NewStatementTemplate(physType, val, unitName); return(template.TransformText()); }
public string GetScheduledEvent(VHDLCompilerInterface compiler, VHDL.WaveformElement wfe) { string value = VHDLOperandGenerator.GetOperand(wfe.Value, compiler); string after = VHDLOperandGenerator.GetOperand(wfe.After, compiler); NewStatementTemplate template = new NewStatementTemplate("ScheduledEvent", value, after); return(template.TransformText()); }
public static string GetOperand(Expression expression, VHDLCompilerInterface compiler, bool GenerateGetOperandFunction = true) { if (expression is Aggregate) { throw new NotImplementedException(); } if (expression is Abs) { throw new NotImplementedException(); } if (expression is Plus) { return(GetPlusOperand(expression as Plus, compiler)); } if (expression is Minus) { return(GetMinusOperand(expression as Minus, compiler)); } if (expression is Not) { return(GetNotOperand(expression as Not, compiler)); } if (expression is TypeConversion) { throw new NotImplementedException(); } if (expression is FunctionCall) { throw new NotImplementedException(); } if (expression is Aggregate) { throw new NotImplementedException(); } if (expression is QualifiedExpression) { throw new NotImplementedException(); } if (expression is QualifiedExpressionAllocator) { throw new NotImplementedException(); } if (expression is Parentheses) { return(GetParenthesesOperand(expression as Parentheses, compiler)); } if (expression is SubtypeIndicationAllocator) { throw new NotImplementedException(); } if (expression is Mod) { return(GetModOperand(expression as Mod, compiler)); } if (expression is Rem) { throw new NotImplementedException(); } if (expression is Divide) { return(GetDivideOperand(expression as Divide, compiler)); } if (expression is Multiply) { return(GetMultiplyOperand(expression as Multiply, compiler)); } if (expression is Pow) { throw new NotImplementedException(); } if (expression is Ror) { throw new NotImplementedException(); } if (expression is Sla) { throw new NotImplementedException(); } if (expression is Sll) { throw new NotImplementedException(); } if (expression is Rol) { throw new NotImplementedException(); } if (expression is Add) { return(GetPlusOperand(expression as Add, compiler)); } if (expression is Concatenate) { throw new NotImplementedException(); } if (expression is Subtract) { return(GetMinusOperand(expression as Subtract, compiler)); } if (expression is Nand) { throw new NotImplementedException(); } if (expression is Xnor) { throw new NotImplementedException(); } if (expression is Nor) { throw new NotImplementedException(); } if (expression is And) { throw new NotImplementedException(); } if (expression is Or) { throw new NotImplementedException(); } if (expression is Equals) { return(GetEqualsOperand(expression as Equals, compiler)); } if (expression is NotEquals) { return(GetNotEqualsOperand(expression as NotEquals, compiler)); } if (expression is GreaterThan) { return(GetGreaterThanOperand(expression as GreaterThan, compiler)); } if (expression is GreaterEquals) { return(GetGreaterEqualsOperand(expression as GreaterEquals, compiler)); } if (expression is LessEquals) { return(GetLessEqualsOperand(expression as LessEquals, compiler)); } if (expression is LessThan) { return(GetLessThanOperand(expression as LessThan, compiler)); } if (expression is SelectedName) { return(GetRecordOperand(expression as SelectedName, compiler, GenerateGetOperandFunction)); } if (expression is IntegerLiteral) { return(GetDecimalLiteralOperand(expression as IntegerLiteral, compiler)); } if (expression is RealLiteral) { return(GetRealLiteralOperand(expression as RealLiteral, compiler)); } if (expression is CharacterLiteral) { throw new NotImplementedException(); } if (expression is VHDL.type.EnumerationType.CharacterEnumerationLiteral) { VHDL.type.EnumerationType.CharacterEnumerationLiteral character_literal = expression as VHDL.type.EnumerationType.CharacterEnumerationLiteral; string exp_type = compiler.TypeDictionary[expression.Type]; string value = string.Format("{0}_Enum.item_{1}", exp_type, character_literal.getLiteral()); NewStatementTemplate template = new NewStatementTemplate(exp_type, value); return(template.TransformText()); } if (expression is PhysicalLiteral) { return(GetPhysicalLiteralOperand(expression as PhysicalLiteral, compiler)); } if (expression is VHDL.type.EnumerationType.IdentifierEnumerationLiteral) { return(GetIdentifierEnumerationLiteralOperand(expression as VHDL.type.EnumerationType.IdentifierEnumerationLiteral, compiler)); } if (expression is Name) { var refObj = ((expression as Name).Referenced as VhdlObject); if (refObj != null) { return(GetObjectOperand(refObj, compiler, GenerateGetOperandFunction)); } } throw new NotImplementedException(); }