2017-09-12 12:48:21 +02:00
|
|
|
/**
|
2018-06-02 23:41:27 +02:00
|
|
|
* generated by Xtext 2.14.0
|
2017-09-12 12:48:21 +02:00
|
|
|
*/
|
|
|
|
package com.minres.rdl.tests;
|
|
|
|
|
|
|
|
import com.google.inject.Inject;
|
|
|
|
import com.minres.rdl.rdl.Root;
|
|
|
|
import com.minres.rdl.tests.RDLInjectorProvider;
|
2018-06-02 23:41:27 +02:00
|
|
|
import org.eclipse.emf.common.util.EList;
|
|
|
|
import org.eclipse.emf.ecore.resource.Resource;
|
2017-09-12 12:48:21 +02:00
|
|
|
import org.eclipse.xtend2.lib.StringConcatenation;
|
|
|
|
import org.eclipse.xtext.testing.InjectWith;
|
|
|
|
import org.eclipse.xtext.testing.XtextRunner;
|
|
|
|
import org.eclipse.xtext.testing.util.ParseHelper;
|
|
|
|
import org.eclipse.xtext.xbase.lib.Exceptions;
|
2018-06-02 23:41:27 +02:00
|
|
|
import org.eclipse.xtext.xbase.lib.IterableExtensions;
|
2017-09-12 12:48:21 +02:00
|
|
|
import org.junit.Assert;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
|
|
|
@RunWith(XtextRunner.class)
|
|
|
|
@InjectWith(RDLInjectorProvider.class)
|
|
|
|
@SuppressWarnings("all")
|
|
|
|
public class RDLParsingTest {
|
|
|
|
@Inject
|
|
|
|
private ParseHelper<Root> parseHelper;
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void loadModel() {
|
|
|
|
try {
|
|
|
|
StringConcatenation _builder = new StringConcatenation();
|
2018-06-02 23:41:27 +02:00
|
|
|
_builder.append("regfile uart_regs {");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("reg {");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("name=\"txdata\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("desc=\"Transmit data register\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field {} data[7:0];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field {} full[31:31];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("} txdata @0x00;");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("reg {");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("name=\"rxdata\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("desc=\"Receive data register\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field {} data[7:0];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field {} empty[31:31];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("}rxdata @0x04;");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("reg {");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("name=\"txctrl\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("desc=\"Transmit control register\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field {} txen[1];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field {} nstop[1];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field {} txcnt[18:16];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("}txctrl @0x08;");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("reg {");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("name=\"rxctrl\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("desc=\"Receive control register\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field {} rxen[1];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field {} rxcnt[18:16];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("}rxctrl @0x0C;");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("reg {");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("name=\"ie\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("desc=\"UART interrupt enable\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field{} txwm[1];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field{} rxwm[1];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("}ie @0x10;");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("reg {");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("name=\"ip\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("desc=\"UART Interrupt pending\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field{} txwm[1];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field{} rxwm[1];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("} ip @0x14;");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("reg {");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("name=\"div\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("desc=\"Baud rate divisor\";");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t\t");
|
|
|
|
_builder.append("field{} div[16];");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("\t");
|
|
|
|
_builder.append("} div @0x18;");
|
|
|
|
_builder.newLine();
|
|
|
|
_builder.append("};");
|
2017-09-12 12:48:21 +02:00
|
|
|
_builder.newLine();
|
|
|
|
final Root result = this.parseHelper.parse(_builder);
|
|
|
|
Assert.assertNotNull(result);
|
2018-06-02 23:41:27 +02:00
|
|
|
final EList<Resource.Diagnostic> errors = result.eResource().getErrors();
|
|
|
|
StringConcatenation _builder_1 = new StringConcatenation();
|
|
|
|
_builder_1.append("Unexpected errors: ");
|
|
|
|
String _join = IterableExtensions.join(errors, ", ");
|
|
|
|
_builder_1.append(_join);
|
|
|
|
Assert.assertTrue(_builder_1.toString(), errors.isEmpty());
|
2017-09-12 12:48:21 +02:00
|
|
|
} catch (Throwable _e) {
|
|
|
|
throw Exceptions.sneakyThrow(_e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|