public void ObserveIfStatement(VHDLCompilerInterface compiler, IfStatement statement) { string condition = VHDLOperandGenerator.GetOperand(statement.Condition, compiler); List <string> statements = new List <string>(); List <string> elseStatements = new List <string>(); List <IfTemplateElsifStatement> elsifParts = new List <IfTemplateElsifStatement>(); foreach (var st in statement.Statements) { statements.Add(GetSequentialCode(compiler, st)); } foreach (var st in statement.ElseStatements) { elseStatements.Add(GetSequentialCode(compiler, st)); } foreach (var elsif in statement.ElsifParts) { elsifParts.Add(GetElsifObject(compiler, elsif)); } IfTemplate template = new IfTemplate(condition, statements, elsifParts, elseStatements); string resultCode = template.TransformText(); code = resultCode; }
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()); }
private IfTemplateElsifStatement GetElsifObject(VHDLCompilerInterface compiler, IfStatement.ElsifPart elsif) { string condition = VHDLOperandGenerator.GetOperand(elsif.Condition, compiler); List <string> statements = new List <string>(); foreach (var st in elsif.Statements) { statements.Add(GetSequentialCode(compiler, st)); } IfTemplateElsifStatement res = new IfTemplateElsifStatement(condition, statements); return(res); }
public void ObserveWhileStatement(VHDLCompilerInterface compiler, WhileStatement statement) { string Condition = VHDLOperandGenerator.GetOperand(statement.Condition, compiler); List <string> Statements = new List <string>(); foreach (var st in statement.Statements) { Statements.Add(GetSequentialCode(compiler, st)); } WhileTemplate template = new WhileTemplate(Condition, Statements); code = template.TransformText(); }
public void ObserveVariableAssignmentStatement(VHDLCompilerInterface compiler, VariableAssignment statement) { IVariableAssignmentTarget interpretedTarget = statement.Target; if (interpretedTarget is Expression) { string target = VHDLOperandGenerator.GetOperand(interpretedTarget as Expression, compiler, false); string targetType = VHDLExpressionTypeGenerator.GetExpressionType(interpretedTarget as Expression, compiler); string value = VHDLOperandGenerator.GetOperand(statement.Value, compiler); VariableAssignTemplate template = new VariableAssignTemplate(target, value, targetType); code = template.TransformText(); return; } }
public void ObserveSignalAssignmentStatement(VHDLCompilerInterface compiler, SignalAssignment statement) { ISignalAssignmentTarget interpretedTarget = statement.Target; if (interpretedTarget is Expression) { string target = VHDLOperandGenerator.GetOperand(interpretedTarget as Expression, compiler, false); if ((statement.Waveform.Count == 1) && (statement.Waveform[0].After == null)) { string value = VHDLOperandGenerator.GetOperand(statement.Waveform[0].Value, compiler); RegisterDutyCycleDelayEvent template = new RegisterDutyCycleDelayEvent(target, value); code = template.TransformText(); } else { List <string> events = new List <string>(); foreach (VHDL.WaveformElement wfe in statement.Waveform) { events.Add(GetScheduledEvent(compiler, wfe)); } if (statement.DelayMechanism == VHDL.DelayMechanism.TRANSPORT) { RegisterTransportDelayEvent template = new RegisterTransportDelayEvent(target, events); code = template.TransformText(); } else { RegisterInertialDelayEvent template; if (statement.DelayMechanism.PulseRejectionLimit == null) { template = new RegisterInertialDelayEvent(target, events); } else { string Rejection = VHDLOperandGenerator.GetOperand(statement.DelayMechanism.PulseRejectionLimit, compiler); template = new RegisterInertialDelayEvent(target, events, Rejection); } code = template.TransformText(); } } } }
public override void Observe(VHDLCompilerInterface compiler) { string typeName = compiler.TypeDictionary[mVariable.Type]; string variableName = mVariable.Identifier; VariableDeclarationTemplate template = null; if (mVariable.DefaultValue != null) { string defValue = VHDLOperandGenerator.GetOperand(mVariable.DefaultValue, compiler); template = new VariableDeclarationTemplate(typeName, variableName, defValue); } else { template = new VariableDeclarationTemplate(typeName, variableName); } compiler.ObjectDictionary.AddItem(mVariable, variableName); declarationText = template.TransformText(); }
public void ObserveReportStatement(VHDLCompilerInterface compiler, ReportStatement report) { string op = VHDLOperandGenerator.GetOperand(report.ReportExpression, compiler); code = GenReportStatement(op); }