remove generated files

This commit is contained in:
2022-02-13 16:32:12 +01:00
parent c827f261ff
commit ffa5058caa
162 changed files with 12 additions and 92667 deletions

View File

@ -0,0 +1 @@
/*

View File

@ -1,2 +0,0 @@
/RDLRuntimeModule.java
/RDLStandaloneSetup.java

View File

@ -1,35 +0,0 @@
/**
* generated by Xtext 2.14.0
*/
package com.minres.rdl;
import com.google.inject.Binder;
import com.google.inject.name.Names;
import com.minres.rdl.converter.RdlTerminalConverters;
import org.eclipse.xtext.conversion.IValueConverterService;
import org.eclipse.xtext.scoping.IGlobalScopeProvider;
import org.eclipse.xtext.scoping.IScopeProvider;
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
import org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider;
import org.eclipse.xtext.scoping.impl.SimpleLocalScopeProvider;
/**
* Use this class to register components to be used at runtime / without the Equinox extension registry.
*/
@SuppressWarnings("all")
public class RDLRuntimeModule extends AbstractRDLRuntimeModule {
@Override
public Class<? extends IValueConverterService> bindIValueConverterService() {
return RdlTerminalConverters.class;
}
@Override
public void configureIScopeProviderDelegate(final Binder binder) {
binder.<IScopeProvider>bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(SimpleLocalScopeProvider.class);
}
@Override
public Class<? extends IGlobalScopeProvider> bindIGlobalScopeProvider() {
return ImportUriGlobalScopeProvider.class;
}
}

View File

@ -1,14 +0,0 @@
/**
* generated by Xtext 2.14.0
*/
package com.minres.rdl;
/**
* Initialization support for running Xtext languages without Equinox extension registry.
*/
@SuppressWarnings("all")
public class RDLStandaloneSetup extends RDLStandaloneSetupGenerated {
public static void doSetup() {
new RDLStandaloneSetup().createInjectorAndDoEMFRegistration();
}
}

View File

@ -1,347 +0,0 @@
package com.minres.rdl;
import com.google.common.base.Objects;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.ComponentDefinitionType;
import com.minres.rdl.rdl.ComponentInstance;
import com.minres.rdl.rdl.EnumDefinition;
import com.minres.rdl.rdl.ExplicitPropertyAssignment;
import com.minres.rdl.rdl.InstancePropertyRef;
import com.minres.rdl.rdl.Instantiation;
import com.minres.rdl.rdl.PropertyAssignment;
import com.minres.rdl.rdl.PropertyAssignmentRhs;
import com.minres.rdl.rdl.PropertyEnum;
import com.minres.rdl.rdl.RValue;
import com.minres.rdl.rdl.RValueConstant;
import com.minres.rdl.rdl.Range;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.Functions.Function2;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@SuppressWarnings("all")
public class RdlUtil {
public static IntegerWithRadix addressValue(final ComponentInstance instance) {
Object _address = instance.getAddress();
boolean _tripleNotEquals = (_address != null);
if (_tripleNotEquals) {
Object _address_1 = instance.getAddress();
return ((IntegerWithRadix) _address_1);
} else {
return new IntegerWithRadix(Integer.valueOf(0));
}
}
public long accessWidth(final ComponentDefinition definition) {
long size = 32L;
final Function1<PropertyAssignment, Boolean> _function = (PropertyAssignment pa) -> {
return Boolean.valueOf(((pa instanceof ExplicitPropertyAssignment) && Objects.equal(((ExplicitPropertyAssignment) pa).getName(), PropertyEnum.ACCESSWIDTH)));
};
final PropertyAssignment pa = IterableExtensions.<PropertyAssignment>findFirst(definition.getPropertyAssignments(), _function);
if ((pa != null)) {
String _effectiveValue = RdlUtil.effectiveValue(((ExplicitPropertyAssignment) pa).getRhs());
final IntegerWithRadix sz = new IntegerWithRadix(_effectiveValue);
size = sz.value;
}
return size;
}
public static long regWidth(final ComponentDefinition definition) {
long size = 32L;
final Function1<PropertyAssignment, Boolean> _function = (PropertyAssignment pa) -> {
return Boolean.valueOf(((pa instanceof ExplicitPropertyAssignment) && Objects.equal(((ExplicitPropertyAssignment) pa).getName(), PropertyEnum.REGWIDTH)));
};
final PropertyAssignment pa = IterableExtensions.<PropertyAssignment>findFirst(definition.getPropertyAssignments(), _function);
if ((pa != null)) {
String _effectiveValue = RdlUtil.effectiveValue(((ExplicitPropertyAssignment) pa).getRhs());
final IntegerWithRadix sz = new IntegerWithRadix(_effectiveValue);
size = sz.value;
}
return size;
}
public static long getSize(final Instantiation instantiation) {
final ComponentDefinition componentDef = RdlUtil.definingComponent(instantiation);
ComponentDefinitionType _type = componentDef.getType();
if (_type != null) {
switch (_type) {
case REG:
final Function1<PropertyAssignment, Boolean> _function = (PropertyAssignment pa) -> {
return Boolean.valueOf(((pa instanceof ExplicitPropertyAssignment) && Objects.equal(((ExplicitPropertyAssignment) pa).getName(), PropertyEnum.REGWIDTH)));
};
final PropertyAssignment pa = IterableExtensions.<PropertyAssignment>findFirst(componentDef.getPropertyAssignments(), _function);
if ((pa != null)) {
String _effectiveValue = RdlUtil.effectiveValue(((ExplicitPropertyAssignment) pa).getRhs());
final IntegerWithRadix sz = new IntegerWithRadix(_effectiveValue);
return sz.value;
}
return 32L;
case FIELD:
final Function1<PropertyAssignment, Boolean> _function_1 = (PropertyAssignment pa_1) -> {
return Boolean.valueOf(((pa_1 instanceof ExplicitPropertyAssignment) && Objects.equal(((ExplicitPropertyAssignment) pa_1).getName(), PropertyEnum.FIELDWIDTH)));
};
final PropertyAssignment pa_1 = IterableExtensions.<PropertyAssignment>findFirst(componentDef.getPropertyAssignments(), _function_1);
if ((pa_1 != null)) {
String _effectiveValue_1 = RdlUtil.effectiveValue(((ExplicitPropertyAssignment) pa_1).getRhs());
final IntegerWithRadix sz_1 = new IntegerWithRadix(_effectiveValue_1);
return sz_1.value;
}
return 1L;
default:
return 0L;
}
} else {
return 0L;
}
}
public static String effectiveName(final ComponentDefinition definition) {
String _name = definition.getName();
boolean _tripleNotEquals = (_name != null);
if (_tripleNotEquals) {
return definition.getName().replaceAll("\\s+", "_");
} else {
final Function1<PropertyAssignment, Boolean> _function = (PropertyAssignment pa) -> {
return Boolean.valueOf(((pa instanceof ExplicitPropertyAssignment) && Objects.equal(((ExplicitPropertyAssignment) pa).getName(), PropertyEnum.NAME)));
};
final PropertyAssignment pa = IterableExtensions.<PropertyAssignment>findFirst(definition.getPropertyAssignments(), _function);
if ((pa != null)) {
return RdlUtil.effectiveValue(((ExplicitPropertyAssignment) pa).getRhs()).replaceAll("\\s+", "_");
} else {
ComponentDefinitionType _type = definition.getType();
return ("unnamed_" + _type).replaceAll("\\s+", "_");
}
}
}
public static String effectiveValue(final PropertyAssignmentRhs rhs) {
String _xifexpression = null;
RValue _value = rhs.getValue();
boolean _tripleNotEquals = (_value != null);
if (_tripleNotEquals) {
_xifexpression = RdlUtil.effectiveValue(rhs.getValue());
} else {
String _xifexpression_1 = null;
InstancePropertyRef _instPropRef = rhs.getInstPropRef();
boolean _tripleNotEquals_1 = (_instPropRef != null);
if (_tripleNotEquals_1) {
_xifexpression_1 = RdlUtil.effectiveValue(rhs.getInstPropRef());
} else {
String _xifexpression_2 = null;
EnumDefinition _enumRef = rhs.getEnumRef();
boolean _tripleNotEquals_2 = (_enumRef != null);
if (_tripleNotEquals_2) {
_xifexpression_2 = rhs.getEnumRef().getName();
}
_xifexpression_1 = _xifexpression_2;
}
_xifexpression = _xifexpression_1;
}
return _xifexpression;
}
public static String effectiveValue(final RValue rvalue) {
String _xifexpression = null;
String _str = rvalue.getStr();
boolean _tripleNotEquals = (_str != null);
if (_tripleNotEquals) {
_xifexpression = rvalue.getStr();
} else {
String _xifexpression_1 = null;
RValueConstant _val = rvalue.getVal();
boolean _notEquals = (!Objects.equal(_val, RValueConstant.UNDEFINED));
if (_notEquals) {
_xifexpression_1 = rvalue.getVal().getLiteral();
} else {
String _xifexpression_2 = null;
Object _num = rvalue.getNum();
boolean _tripleNotEquals_1 = (_num != null);
if (_tripleNotEquals_1) {
String _xblockexpression = null;
{
Object _num_1 = rvalue.getNum();
final IntegerWithRadix num = ((IntegerWithRadix) _num_1);
_xblockexpression = num.toString();
}
_xifexpression_2 = _xblockexpression;
}
_xifexpression_1 = _xifexpression_2;
}
_xifexpression = _xifexpression_1;
}
return _xifexpression;
}
public static String effectiveValue(final InstancePropertyRef ref) {
throw new RuntimeException();
}
public static ComponentDefinition definingComponent(final Instantiation instantiation) {
ComponentDefinition _xifexpression = null;
ComponentDefinition _componentRef = instantiation.getComponentRef();
boolean _tripleNotEquals = (_componentRef != null);
if (_tripleNotEquals) {
_xifexpression = instantiation.getComponentRef();
} else {
_xifexpression = instantiation.getComponent();
}
return _xifexpression;
}
public static int instanceCount(final ComponentDefinition definition, final ComponentDefinitionType type) {
final Function1<Instantiation, Integer> _function = (Instantiation it) -> {
return Integer.valueOf(it.getComponentInstances().size());
};
final Function2<Integer, Integer, Integer> _function_1 = (Integer p1, Integer p2) -> {
return Integer.valueOf(((p1).intValue() + (p2).intValue()));
};
return (int) IterableExtensions.<Integer>reduce(IterableExtensions.<Instantiation, Integer>map(RdlUtil.instantiationsOfType(definition, type), _function), _function_1);
}
public static Iterable<Instantiation> instantiationsOfType(final ComponentDefinition definition, final ComponentDefinitionType type) {
final Function1<Instantiation, Boolean> _function = (Instantiation it) -> {
ComponentDefinitionType _type = RdlUtil.definingComponent(it).getType();
return Boolean.valueOf(Objects.equal(_type, type));
};
return IterableExtensions.<Instantiation>filter(definition.getInstantiations(), _function);
}
public static long byteSize(final Instantiation instantiation, final long start) {
final ComponentDefinition componentDefinition = RdlUtil.definingComponent(instantiation);
long componentSize = 0;
ComponentDefinitionType _type = RdlUtil.definingComponent(instantiation).getType();
boolean _equals = Objects.equal(_type, ComponentDefinitionType.REG);
if (_equals) {
long _regWidth = RdlUtil.regWidth(RdlUtil.definingComponent(instantiation));
long _divide = (_regWidth / 8);
componentSize = _divide;
} else {
EList<Instantiation> _instantiations = componentDefinition.getInstantiations();
for (final Instantiation subInstantiation : _instantiations) {
componentSize = RdlUtil.byteSize(subInstantiation, componentSize);
}
}
long lastTopAddress = start;
long topAddress = start;
EList<ComponentInstance> _componentInstances = instantiation.getComponentInstances();
for (final ComponentInstance componentInstance : _componentInstances) {
{
long _xifexpression = (long) 0;
Object _address = componentInstance.getAddress();
boolean _tripleNotEquals = (_address != null);
if (_tripleNotEquals) {
Object _address_1 = componentInstance.getAddress();
_xifexpression = (((IntegerWithRadix) _address_1).value + componentSize);
} else {
_xifexpression = (componentSize + lastTopAddress);
}
final long byteSize = _xifexpression;
topAddress = Math.max(topAddress, byteSize);
lastTopAddress = byteSize;
}
}
return topAddress;
}
public static long byteSize(final Instantiation instantiation) {
final ComponentDefinition componentDefinition = RdlUtil.definingComponent(instantiation);
long componentSize = 0;
ComponentDefinitionType _type = RdlUtil.definingComponent(instantiation).getType();
boolean _equals = Objects.equal(_type, ComponentDefinitionType.REG);
if (_equals) {
long _regWidth = RdlUtil.regWidth(RdlUtil.definingComponent(instantiation));
long _divide = (_regWidth / 8);
componentSize = _divide;
} else {
EList<Instantiation> _instantiations = componentDefinition.getInstantiations();
for (final Instantiation subInstantiation : _instantiations) {
componentSize = RdlUtil.byteSize(subInstantiation, componentSize);
}
}
return componentSize;
}
public static ComponentDefinition getComponentDefinition(final Instantiation instantiation) {
ComponentDefinition _xifexpression = null;
ComponentDefinition _component = instantiation.getComponent();
boolean _tripleNotEquals = (_component != null);
if (_tripleNotEquals) {
_xifexpression = instantiation.getComponent();
} else {
_xifexpression = instantiation.getComponentRef();
}
return _xifexpression;
}
public static long absSize(final Range range) {
Object _size = range.getSize();
boolean _tripleNotEquals = (_size != null);
if (_tripleNotEquals) {
Object _size_1 = range.getSize();
return ((IntegerWithRadix) _size_1).value;
} else {
Object _left = range.getLeft();
Object _right = range.getRight();
long _abs = Math.abs((((IntegerWithRadix) _left).value - ((IntegerWithRadix) _right).value));
return (_abs + 1);
}
}
public static boolean isFilledByField(final Instantiation instantiation) {
final int fieldCount = RdlUtil.instanceCountOfType(RdlUtil.getComponentDefinition(instantiation), ComponentDefinitionType.FIELD);
if ((fieldCount == 1)) {
final long instSize = RdlUtil.getSize(instantiation);
final Instantiation field = ((Instantiation[])Conversions.unwrapArray(RdlUtil.instantiationsOfType(instantiation.getComponent(), ComponentDefinitionType.FIELD), Instantiation.class))[0];
final ComponentInstance inst = field.getComponentInstances().get(0);
final Range range = inst.getRange();
if ((range == null)) {
long _size = RdlUtil.getSize(field);
return (instSize == _size);
}
Object _size_1 = range.getSize();
boolean _tripleNotEquals = (_size_1 != null);
if (_tripleNotEquals) {
Object _size_2 = range.getSize();
return (instSize == ((IntegerWithRadix) _size_2).value);
} else {
Object _left = range.getLeft();
final long left = ((IntegerWithRadix) _left).value;
Object _right = range.getRight();
final long right = ((IntegerWithRadix) _right).value;
long _xifexpression = (long) 0;
if ((left > right)) {
_xifexpression = ((left - right) + 1);
} else {
_xifexpression = ((right - left) + 1);
}
final long size = _xifexpression;
return (instSize == size);
}
}
return false;
}
public static int instanceCountOfType(final ComponentDefinition definition, final ComponentDefinitionType type) {
Integer _xblockexpression = null;
{
final Iterable<Instantiation> insts = RdlUtil.instantiationsOfType(definition, type);
Integer _xifexpression = null;
int _size = IterableExtensions.size(insts);
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
final Function1<Instantiation, Integer> _function = (Instantiation it) -> {
return Integer.valueOf(it.getComponentInstances().size());
};
final Function2<Integer, Integer, Integer> _function_1 = (Integer p1, Integer p2) -> {
return Integer.valueOf(((p1).intValue() + (p2).intValue()));
};
_xifexpression = IterableExtensions.<Integer>reduce(IterableExtensions.<Instantiation, Integer>map(insts, _function), _function_1);
} else {
_xifexpression = Integer.valueOf(0);
}
_xblockexpression = _xifexpression;
}
return (_xblockexpression).intValue();
}
}

View File

@ -1,4 +0,0 @@
/IDValueConverter.java
/NUMValueConverter.java
/RdlTerminalConverters.java
/STRValueConverter.java

View File

@ -1,22 +0,0 @@
package com.minres.rdl.converter;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
@SuppressWarnings("all")
public class IDValueConverter extends AbstractLexerBasedConverter<String> {
@Override
protected String toEscapedString(final String value) {
return value;
}
@Override
public String toValue(final String string, final INode node) {
boolean _startsWith = string.startsWith("\\");
if (_startsWith) {
return string.substring(1);
} else {
return string;
}
}
}

View File

@ -1,45 +0,0 @@
package com.minres.rdl.converter;
import com.minres.rdl.IntegerWithRadix;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.conversion.ValueConverterException;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.util.Strings;
import org.eclipse.xtext.xbase.lib.Exceptions;
@SuppressWarnings("all")
class NUMValueConverter extends AbstractLexerBasedConverter<IntegerWithRadix> {
@Override
protected String toEscapedString(final IntegerWithRadix value) {
return value.toString();
}
@Override
protected void assertValidValue(final IntegerWithRadix value) {
super.assertValidValue(value);
}
@Override
public IntegerWithRadix toValue(final String string, final INode node) throws ValueConverterException {
boolean _isEmpty = Strings.isEmpty(string);
if (_isEmpty) {
throw new ValueConverterException(
"Couldn\'t convert empty string to an integer value.", node, null);
}
try {
return new IntegerWithRadix(string);
} catch (final Throwable _t) {
if (_t instanceof NumberFormatException) {
final NumberFormatException e = (NumberFormatException)_t;
StringConcatenation _builder = new StringConcatenation();
_builder.append("Couldn\'t convert \'");
_builder.append(string);
_builder.append("\' to an integer value.");
throw new ValueConverterException(_builder.toString(), node, e);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
}

View File

@ -1,34 +0,0 @@
package com.minres.rdl.converter;
import com.google.inject.Inject;
import com.minres.rdl.IntegerWithRadix;
import org.eclipse.xtext.common.services.DefaultTerminalConverters;
import org.eclipse.xtext.conversion.IValueConverter;
import org.eclipse.xtext.conversion.ValueConverter;
@SuppressWarnings("all")
public class RdlTerminalConverters extends DefaultTerminalConverters {
@Inject
private NUMValueConverter numValueConverter;
@Inject
private STRValueConverter stringConverter;
@Inject
private IDValueConverter idConverter;
@ValueConverter(rule = "NUM")
public IValueConverter<IntegerWithRadix> getNumValueConverter() {
return this.numValueConverter;
}
@ValueConverter(rule = "STR")
public IValueConverter<String> getStrValueConverter() {
return this.stringConverter;
}
@ValueConverter(rule = "ID")
public IValueConverter<String> getIdValueConverter() {
return this.idConverter;
}
}

View File

@ -1,19 +0,0 @@
package com.minres.rdl.converter;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
@SuppressWarnings("all")
public class STRValueConverter extends AbstractLexerBasedConverter<String> {
@Override
protected String toEscapedString(final String value) {
return (("\"" + value) + "\"");
}
@Override
public String toValue(final String string, final INode node) {
int _length = string.length();
int _minus = (_length - 1);
return string.substring(1, _minus);
}
}

View File

@ -1 +0,0 @@
/RDLFormatter.java

View File

@ -1,32 +0,0 @@
/**
* generated by Xtext
*/
package com.minres.rdl.formatting;
import com.google.inject.Inject;
import com.minres.rdl.services.RDLGrammarAccess;
import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
import org.eclipse.xtext.formatting.impl.FormattingConfig;
import org.eclipse.xtext.xbase.lib.Extension;
/**
* This class contains custom formatting description.
*
* see : http://www.eclipse.org/Xtext/documentation.html#formatting
* on how and when to use it
*
* Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
*/
@SuppressWarnings("all")
public class RDLFormatter extends AbstractDeclarativeFormatter {
@Inject
@Extension
private RDLGrammarAccess _rDLGrammarAccess;
@Override
protected void configureFormatting(final FormattingConfig c) {
c.setLinewrap(0, 1, 2).before(this._rDLGrammarAccess.getSL_COMMENTRule());
c.setLinewrap(0, 1, 2).before(this._rDLGrammarAccess.getML_COMMENTRule());
c.setLinewrap(0, 1, 1).after(this._rDLGrammarAccess.getML_COMMENTRule());
}
}

View File

@ -1,81 +0,0 @@
/**
* generated by Xtext 2.14.0
*/
package com.minres.rdl.formatting2;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.EnumDefinition;
import com.minres.rdl.rdl.Include;
import com.minres.rdl.rdl.Instantiation;
import com.minres.rdl.rdl.PropertyAssignment;
import com.minres.rdl.rdl.PropertyDefault;
import com.minres.rdl.rdl.PropertyDefinition;
import com.minres.rdl.rdl.PropertyUsage;
import com.minres.rdl.rdl.Root;
import java.util.Arrays;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.formatting2.AbstractFormatter2;
import org.eclipse.xtext.formatting2.IFormattableDocument;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.xbase.lib.Extension;
@SuppressWarnings("all")
public class RDLFormatter extends AbstractFormatter2 {
protected void _format(final Root root, @Extension final IFormattableDocument document) {
EList<Include> _includes = root.getIncludes();
for (final Include include : _includes) {
document.<Include>format(include);
}
EList<ComponentDefinition> _componentDefinitions = root.getComponentDefinitions();
for (final ComponentDefinition componentDefinition : _componentDefinitions) {
document.<ComponentDefinition>format(componentDefinition);
}
EList<EnumDefinition> _enumDefinitions = root.getEnumDefinitions();
for (final EnumDefinition enumDefinition : _enumDefinitions) {
document.<EnumDefinition>format(enumDefinition);
}
EList<Instantiation> _instantiations = root.getInstantiations();
for (final Instantiation instantiation : _instantiations) {
document.<Instantiation>format(instantiation);
}
EList<PropertyAssignment> _propertyAssignments = root.getPropertyAssignments();
for (final PropertyAssignment propertyAssignment : _propertyAssignments) {
document.<PropertyAssignment>format(propertyAssignment);
}
EList<PropertyDefinition> _propertyDefinitions = root.getPropertyDefinitions();
for (final PropertyDefinition propertyDefinition : _propertyDefinitions) {
document.<PropertyDefinition>format(propertyDefinition);
}
}
protected void _format(final PropertyDefinition propertyDefinition, @Extension final IFormattableDocument document) {
document.<PropertyUsage>format(propertyDefinition.getUsage());
document.<PropertyDefault>format(propertyDefinition.getDefault());
}
public void format(final Object propertyDefinition, final IFormattableDocument document) {
if (propertyDefinition instanceof XtextResource) {
_format((XtextResource)propertyDefinition, document);
return;
} else if (propertyDefinition instanceof PropertyDefinition) {
_format((PropertyDefinition)propertyDefinition, document);
return;
} else if (propertyDefinition instanceof Root) {
_format((Root)propertyDefinition, document);
return;
} else if (propertyDefinition instanceof EObject) {
_format((EObject)propertyDefinition, document);
return;
} else if (propertyDefinition == null) {
_format((Void)null, document);
return;
} else if (propertyDefinition != null) {
_format(propertyDefinition, document);
return;
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(propertyDefinition, document).toString());
}
}
}

View File

@ -1,5 +0,0 @@
/AddrmapGenerator.java
/Main.java
/RDLGenerator.java
/RdlBaseGenerator.java
/RegfileGenerator.java

View File

@ -1,85 +0,0 @@
package com.minres.rdl.generator;
import com.minres.rdl.IntegerWithRadix;
import com.minres.rdl.RdlUtil;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.ComponentDefinitionType;
import com.minres.rdl.rdl.ComponentInstance;
import com.minres.rdl.rdl.Instantiation;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtend2.lib.StringConcatenation;
@SuppressWarnings("all")
public class AddrmapGenerator extends RdlBaseGenerator {
private final ComponentDefinition componentDefinition;
public AddrmapGenerator(final ComponentDefinition definition) {
this.componentDefinition = definition;
}
@Override
public boolean getOverwrite() {
return true;
}
@Override
public String generateHeader(final String namespace) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("#ifndef _");
String _upperCase = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase);
_builder.append("_MAP_H_");
_builder.newLineIfNotEmpty();
_builder.append("#define _");
String _upperCase_1 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_1);
_builder.append("_MAP_H_");
_builder.newLineIfNotEmpty();
_builder.append("// need double braces, see https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191");
_builder.newLine();
_builder.append("const std::array<scc::target_memory_map_entry<32>, ");
int _instanceCount = RdlUtil.instanceCount(this.componentDefinition, ComponentDefinitionType.REGFILE);
_builder.append(_instanceCount);
_builder.append("> ");
String _effectiveName = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName);
_builder.append("_map = {{");
_builder.newLineIfNotEmpty();
{
Iterable<Instantiation> _instantiationsOfType = RdlUtil.instantiationsOfType(this.componentDefinition, ComponentDefinitionType.REGFILE);
for(final Instantiation instantiation : _instantiationsOfType) {
{
EList<ComponentInstance> _componentInstances = instantiation.getComponentInstances();
for(final ComponentInstance instance : _componentInstances) {
_builder.append(" ");
_builder.append("{i_");
String _name = instance.getName();
_builder.append(_name, " ");
_builder.append(".socket, ");
IntegerWithRadix _addressValue = RdlUtil.addressValue(instance);
_builder.append(_addressValue, " ");
_builder.append(", 0x");
String _hexString = Long.toHexString(RdlUtil.byteSize(instantiation));
_builder.append(_hexString, " ");
_builder.append("},");
_builder.newLineIfNotEmpty();
}
}
}
}
_builder.append("}};");
_builder.newLine();
_builder.newLine();
_builder.append("#endif /* _");
String _upperCase_2 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_2);
_builder.append("_MAP_H_ */");
_builder.newLineIfNotEmpty();
return _builder.toString();
}
@Override
public String generateSource(final String namespace) {
return "";
}
}

View File

@ -1,216 +0,0 @@
package com.minres.rdl.generator;
import com.minres.rdl.IntegerWithRadix;
import com.minres.rdl.RdlUtil;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.ComponentDefinitionType;
import com.minres.rdl.rdl.ComponentInstance;
import com.minres.rdl.rdl.Instantiation;
import java.util.Date;
import java.util.LinkedHashSet;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
@SuppressWarnings("all")
public class FwAddrmapGenerator extends RdlBaseGenerator {
private final ComponentDefinition componentDefinition;
public FwAddrmapGenerator(final ComponentDefinition definition) {
this.componentDefinition = definition;
}
private final LinkedHashSet<Object> nameMap = CollectionLiterals.<Object>newLinkedHashSet();
@Override
public boolean getOverwrite() {
return true;
}
@Override
public String generateHeader(final String namespace) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("////////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.append("// Copyright (C) 2020-2022, MINRES Technologies GmbH");
_builder.newLine();
_builder.append("// All rights reserved.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// Redistribution and use in source and binary forms, with or without");
_builder.newLine();
_builder.append("// modification, are permitted provided that the following conditions are met:");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// 1. Redistributions of source code must retain the above copyright notice,");
_builder.newLine();
_builder.append("// this list of conditions and the following disclaimer.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// 2. Redistributions in binary form must reproduce the above copyright notice,");
_builder.newLine();
_builder.append("// this list of conditions and the following disclaimer in the documentation");
_builder.newLine();
_builder.append("// and/or other materials provided with the distribution.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// 3. Neither the name of the copyright holder nor the names of its contributors");
_builder.newLine();
_builder.append("// may be used to endorse or promote products derived from this software");
_builder.newLine();
_builder.append("// without specific prior written permission.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"");
_builder.newLine();
_builder.append("// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE");
_builder.newLine();
_builder.append("// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE");
_builder.newLine();
_builder.append("// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE");
_builder.newLine();
_builder.append("// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR");
_builder.newLine();
_builder.append("// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF");
_builder.newLine();
_builder.append("// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS");
_builder.newLine();
_builder.append("// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN");
_builder.newLine();
_builder.append("// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)");
_builder.newLine();
_builder.append("// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE");
_builder.newLine();
_builder.append("// POSSIBILITY OF SUCH DAMAGE.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// Created on: ");
Date _date = new Date();
_builder.append(_date);
_builder.newLineIfNotEmpty();
_builder.append("// * ");
String _name = this.componentDefinition.getName();
_builder.append(_name);
_builder.append(".h Author: <RDL Generator>");
_builder.newLineIfNotEmpty();
_builder.append("//");
_builder.newLine();
_builder.append("////////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.newLine();
_builder.append("#ifndef _");
String _upperCase = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase);
_builder.append("_MAP_H_");
_builder.newLineIfNotEmpty();
_builder.append("#define _");
String _upperCase_1 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_1);
_builder.append("_MAP_H_");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
Iterable<Instantiation> _instantiationsOfType = RdlUtil.instantiationsOfType(this.componentDefinition, ComponentDefinitionType.REGFILE);
for(final Instantiation instantiation : _instantiationsOfType) {
{
if (((instantiation.getComponent() != null) && (!this.nameMap.contains(instantiation.getComponent().getName())))) {
_builder.append("#include \"");
String _name_1 = instantiation.getComponent().getName();
_builder.append(_name_1);
_builder.append(".h\"");
String _xifexpression = null;
boolean _add = this.nameMap.add(instantiation.getComponent().getName());
if (_add) {
_xifexpression = "";
} else {
_xifexpression = "";
}
_builder.append(_xifexpression);
_builder.newLineIfNotEmpty();
}
}
{
if (((instantiation.getComponentRef() != null) && (!this.nameMap.contains(instantiation.getComponentRef().getName())))) {
_builder.append("#include \"");
String _name_2 = instantiation.getComponentRef().getName();
_builder.append(_name_2);
_builder.append(".h\"");
String _xifexpression_1 = null;
boolean _add_1 = this.nameMap.add(instantiation.getComponentRef().getName());
if (_add_1) {
_xifexpression_1 = "";
} else {
_xifexpression_1 = "";
}
_builder.append(_xifexpression_1);
_builder.newLineIfNotEmpty();
}
}
}
}
_builder.newLine();
_builder.newLine();
{
Iterable<Instantiation> _instantiationsOfType_1 = RdlUtil.instantiationsOfType(this.componentDefinition, ComponentDefinitionType.REGFILE);
for(final Instantiation instantiation_1 : _instantiationsOfType_1) {
{
EList<ComponentInstance> _componentInstances = instantiation_1.getComponentInstances();
for(final ComponentInstance instance : _componentInstances) {
{
ComponentDefinition _component = instantiation_1.getComponent();
boolean _tripleNotEquals = (_component != null);
if (_tripleNotEquals) {
_builder.append("using ");
String _name_3 = instance.getName();
_builder.append(_name_3);
_builder.append(" = ");
String _name_4 = instantiation_1.getComponent().getName();
_builder.append(_name_4);
_builder.append("<");
IntegerWithRadix _addressValue = RdlUtil.addressValue(instance);
_builder.append(_addressValue);
_builder.append("ULL>;");
_builder.newLineIfNotEmpty();
}
}
{
ComponentDefinition _componentRef = instantiation_1.getComponentRef();
boolean _tripleNotEquals_1 = (_componentRef != null);
if (_tripleNotEquals_1) {
_builder.append("using ");
String _name_5 = instance.getName();
_builder.append(_name_5);
_builder.append(" = ");
String _name_6 = instantiation_1.getComponentRef().getName();
_builder.append(_name_6);
_builder.append("<");
IntegerWithRadix _addressValue_1 = RdlUtil.addressValue(instance);
_builder.append(_addressValue_1);
_builder.append("ULL>;");
_builder.newLineIfNotEmpty();
}
}
}
}
}
}
_builder.newLine();
_builder.append("#endif /* _");
String _upperCase_2 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_2);
_builder.append("_MAP_H_ */");
_builder.newLineIfNotEmpty();
return _builder.toString();
}
@Override
public String generateSource(final String namespace) {
return "";
}
}

View File

@ -1,437 +0,0 @@
package com.minres.rdl.generator;
import com.google.common.base.Objects;
import com.minres.rdl.IntegerWithRadix;
import com.minres.rdl.RdlUtil;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.ComponentDefinitionType;
import com.minres.rdl.rdl.ComponentInstance;
import com.minres.rdl.rdl.Instantiation;
import com.minres.rdl.rdl.Range;
import java.util.Date;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ListExtensions;
@SuppressWarnings("all")
public class FwRegfileGenerator extends RdlBaseGenerator {
private final ComponentDefinition componentDefinition;
public FwRegfileGenerator(final ComponentDefinition definition) {
this.componentDefinition = definition;
}
@Override
public boolean getOverwrite() {
return true;
}
@Override
public String generateHeader(final String namespace) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("////////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.append("// Copyright (C) 2020-2022, MINRES Technologies GmbH");
_builder.newLine();
_builder.append("// All rights reserved.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// Redistribution and use in source and binary forms, with or without");
_builder.newLine();
_builder.append("// modification, are permitted provided that the following conditions are met:");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// 1. Redistributions of source code must retain the above copyright notice,");
_builder.newLine();
_builder.append("// this list of conditions and the following disclaimer.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// 2. Redistributions in binary form must reproduce the above copyright notice,");
_builder.newLine();
_builder.append("// this list of conditions and the following disclaimer in the documentation");
_builder.newLine();
_builder.append("// and/or other materials provided with the distribution.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// 3. Neither the name of the copyright holder nor the names of its contributors");
_builder.newLine();
_builder.append("// may be used to endorse or promote products derived from this software");
_builder.newLine();
_builder.append("// without specific prior written permission.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"");
_builder.newLine();
_builder.append("// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE");
_builder.newLine();
_builder.append("// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE");
_builder.newLine();
_builder.append("// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE");
_builder.newLine();
_builder.append("// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR");
_builder.newLine();
_builder.append("// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF");
_builder.newLine();
_builder.append("// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS");
_builder.newLine();
_builder.append("// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN");
_builder.newLine();
_builder.append("// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)");
_builder.newLine();
_builder.append("// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE");
_builder.newLine();
_builder.append("// POSSIBILITY OF SUCH DAMAGE.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// Created on: ");
Date _date = new Date();
_builder.append(_date);
_builder.newLineIfNotEmpty();
_builder.append("// * ");
String _name = this.componentDefinition.getName();
_builder.append(_name);
_builder.append(".h Author: <RDL Generator>");
_builder.newLineIfNotEmpty();
_builder.append("//");
_builder.newLine();
_builder.append("////////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.newLine();
_builder.append("#ifndef _");
String _upperCase = this.componentDefinition.getName().toUpperCase();
_builder.append(_upperCase);
_builder.append("_H_");
_builder.newLineIfNotEmpty();
_builder.append("#define _");
String _upperCase_1 = this.componentDefinition.getName().toUpperCase();
_builder.append(_upperCase_1);
_builder.append("_H_");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("#include <util/bit_field.h>");
_builder.newLine();
_builder.append("#include <nonstd/span.hpp>");
_builder.newLine();
_builder.append("#include <cstdint>");
_builder.newLine();
_builder.newLine();
_builder.append("template<size_t BASE_ADDR>");
_builder.newLine();
_builder.append("struct ");
String _name_1 = this.componentDefinition.getName();
_builder.append(_name_1);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
EList<ComponentDefinition> _componentDefinitions = this.componentDefinition.getComponentDefinitions();
for(final ComponentDefinition cdef : _componentDefinitions) {
{
ComponentDefinitionType _type = cdef.getType();
boolean _equals = Objects.equal(_type, ComponentDefinitionType.REG);
if (_equals) {
_builder.append(" ");
_builder.append("BEGIN_BF_DECL(");
String _effectiveName = RdlUtil.effectiveName(cdef);
_builder.append(_effectiveName, " ");
_builder.append("+\'_t\'», uint");
_builder.append(cdef, " ");
_builder.append("_t);");
_builder.newLineIfNotEmpty();
_builder.append(" ");
String _genFieldDeclarations = this.genFieldDeclarations(cdef);
_builder.append(_genFieldDeclarations, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("END_BF_DECL();");
_builder.newLine();
}
}
}
}
{
EList<Instantiation> _instantiations = this.componentDefinition.getInstantiations();
for(final Instantiation instantiation : _instantiations) {
{
if (((instantiation.getComponentRef() != null) && Objects.equal(instantiation.getComponentRef().getType(), ComponentDefinitionType.REG))) {
_builder.append(" ");
String _effectiveName_1 = RdlUtil.effectiveName(instantiation.getComponentRef());
_builder.append(_effectiveName_1, " ");
_builder.append("+\'_t\' ");
final Function1<ComponentInstance, String> _function = (ComponentInstance it) -> {
return it.getName();
};
String _join = IterableExtensions.join(ListExtensions.<ComponentInstance, String>map(instantiation.getComponentInstances(), _function), ", ");
_builder.append(_join, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
{
if (((instantiation.getComponent() != null) && Objects.equal(instantiation.getComponent().getType(), ComponentDefinitionType.REG))) {
{
boolean _isFilledByField = RdlUtil.isFilledByField(instantiation);
boolean _not = (!_isFilledByField);
if (_not) {
_builder.append(" ");
_builder.append("BEGIN_BF_DECL(");
String _effectiveName_2 = RdlUtil.effectiveName(instantiation.getComponent());
_builder.append(_effectiveName_2, " ");
_builder.append("_t, uint");
long _size = RdlUtil.getSize(instantiation);
_builder.append(_size, " ");
_builder.append("_t);");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append(" ");
String _genFieldDeclarations_1 = this.genFieldDeclarations(RdlUtil.definingComponent(instantiation));
_builder.append(_genFieldDeclarations_1, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("END_BF_DECL() ");
final Function1<ComponentInstance, Boolean> _function_1 = (ComponentInstance it) -> {
Range _range = it.getRange();
return Boolean.valueOf((_range == null));
};
final Function1<ComponentInstance, String> _function_2 = (ComponentInstance it) -> {
String _name_2 = it.getName();
return ("r_" + _name_2);
};
String _join_1 = IterableExtensions.join(IterableExtensions.<ComponentInstance, String>map(IterableExtensions.<ComponentInstance>filter(instantiation.getComponentInstances(), _function_1), _function_2), ", ");
_builder.append(_join_1, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
}
}
}
}
}
}
_builder.append(" ");
_builder.append("// register access");
_builder.newLine();
{
EList<Instantiation> _instantiations_1 = this.componentDefinition.getInstantiations();
for(final Instantiation instantiation_1 : _instantiations_1) {
{
EList<ComponentInstance> _componentInstances = instantiation_1.getComponentInstances();
for(final ComponentInstance instance : _componentInstances) {
{
Range _range = instance.getRange();
boolean _tripleEquals = (_range == null);
if (_tripleEquals) {
{
boolean _isFilledByField_1 = RdlUtil.isFilledByField(instantiation_1);
if (_isFilledByField_1) {
_builder.append(" ");
_builder.append("static inline uint");
long _size_1 = RdlUtil.getSize(instantiation_1);
_builder.append(_size_1, " ");
_builder.append("_t& ");
String _name_2 = instance.getName();
_builder.append(_name_2, " ");
_builder.append("(){");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append(" ");
_builder.append("return *reinterpret_cast<");
String _name_3 = instance.getName();
_builder.append(_name_3, " ");
_builder.append("_t*>(BASE_ADDR+");
IntegerWithRadix _addressValue = RdlUtil.addressValue(instance);
_builder.append(_addressValue, " ");
_builder.append("UL);");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
}
}
{
boolean _isFilledByField_2 = RdlUtil.isFilledByField(instantiation_1);
boolean _not_1 = (!_isFilledByField_2);
if (_not_1) {
_builder.append(" ");
_builder.append("static inline ");
String _name_4 = instance.getName();
_builder.append(_name_4, " ");
_builder.append("_t& ");
String _name_5 = instance.getName();
_builder.append(_name_5, " ");
_builder.append("(){");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append(" ");
_builder.append("return *reinterpret_cast<");
String _name_6 = instance.getName();
_builder.append(_name_6, " ");
_builder.append("_t*>(BASE_ADDR+");
IntegerWithRadix _addressValue_1 = RdlUtil.addressValue(instance);
_builder.append(_addressValue_1, " ");
_builder.append("UL);");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
}
}
}
}
{
Range _range_1 = instance.getRange();
boolean _tripleNotEquals = (_range_1 != null);
if (_tripleNotEquals) {
{
boolean _isFilledByField_3 = RdlUtil.isFilledByField(instantiation_1);
if (_isFilledByField_3) {
_builder.append(" ");
_builder.append("static inline nonstd::span<uint");
long _size_2 = RdlUtil.getSize(instantiation_1);
_builder.append(_size_2, " ");
_builder.append("_t, ");
long _absSize = RdlUtil.absSize(instance.getRange());
_builder.append(_absSize, " ");
_builder.append(">& ");
String _name_7 = instance.getName();
_builder.append(_name_7, " ");
_builder.append("(){");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append(" ");
_builder.append("return *reinterpret_cast<nonstd::span<uint");
long _size_3 = RdlUtil.getSize(instantiation_1);
_builder.append(_size_3, " ");
_builder.append("_t, ");
long _absSize_1 = RdlUtil.absSize(instance.getRange());
_builder.append(_absSize_1, " ");
_builder.append(">*>(BASE_ADDR+");
IntegerWithRadix _addressValue_2 = RdlUtil.addressValue(instance);
_builder.append(_addressValue_2, " ");
_builder.append("UL);");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
}
}
{
boolean _isFilledByField_4 = RdlUtil.isFilledByField(instantiation_1);
boolean _not_2 = (!_isFilledByField_4);
if (_not_2) {
_builder.append(" ");
_builder.append("static inline nonstd::span<");
String _name_8 = instance.getName();
_builder.append(_name_8, " ");
_builder.append("_t, ");
long _absSize_2 = RdlUtil.absSize(instance.getRange());
_builder.append(_absSize_2, " ");
_builder.append(">& ");
String _name_9 = instance.getName();
_builder.append(_name_9, " ");
_builder.append("(){");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append(" ");
_builder.append("return *reinterpret_cast<nonstd::span<");
String _name_10 = instance.getName();
_builder.append(_name_10, " ");
_builder.append("_t, ");
long _absSize_3 = RdlUtil.absSize(instance.getRange());
_builder.append(_absSize_3, " ");
_builder.append(">*>(BASE_ADDR+");
IntegerWithRadix _addressValue_3 = RdlUtil.addressValue(instance);
_builder.append(_addressValue_3, " ");
_builder.append("UL);");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
}
}
}
}
}
}
}
}
_builder.append("};");
_builder.newLine();
_builder.newLine();
_builder.append("#endif // _");
String _upperCase_2 = this.componentDefinition.getName().toUpperCase();
_builder.append(_upperCase_2);
_builder.append("_H_");
_builder.newLineIfNotEmpty();
return _builder.toString();
}
@Override
public String generateSource(final String namespace) {
return "";
}
public String genFieldDeclarations(final ComponentDefinition componentDef) {
String _xblockexpression = null;
{
long i = 0L;
String res = "";
EList<Instantiation> _instantiations = componentDef.getInstantiations();
for (final Instantiation inst : _instantiations) {
EList<ComponentInstance> _componentInstances = inst.getComponentInstances();
for (final ComponentInstance compInst : _componentInstances) {
Object _size = compInst.getRange().getSize();
boolean _tripleNotEquals = (_size != null);
if (_tripleNotEquals) {
String _res = res;
StringConcatenation _builder = new StringConcatenation();
_builder.append("BF_FIELD(");
String _name = compInst.getName();
_builder.append(_name);
_builder.append(", ");
_builder.append(i);
_builder.append(", ");
Object _size_1 = compInst.getRange().getSize();
_builder.append(((IntegerWithRadix) _size_1).value);
_builder.append(");");
_builder.newLineIfNotEmpty();
res = (_res + _builder);
long _i = i;
Object _size_2 = compInst.getRange().getSize();
i = (_i + ((IntegerWithRadix) _size_2).value);
} else {
Object _left = compInst.getRange().getLeft();
final long start = ((IntegerWithRadix) _left).value;
Object _right = compInst.getRange().getRight();
final long end = ((IntegerWithRadix) _right).value;
String _res_1 = res;
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("BF_FIELD(");
String _name_1 = compInst.getName();
_builder_1.append(_name_1);
_builder_1.append(", ");
_builder_1.append(end);
_builder_1.append(", ");
_builder_1.append(((start - end) + 1));
_builder_1.append(");");
_builder_1.newLineIfNotEmpty();
res = (_res_1 + _builder_1);
long _max = Math.max(start, end);
long _plus = (_max + 1);
i = _plus;
}
}
}
_xblockexpression = res;
}
return _xblockexpression;
}
}

View File

@ -1,207 +0,0 @@
package com.minres.rdl.generator;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provider;
import com.minres.rdl.RDLStandaloneSetup;
import java.lang.reflect.MalformedParametersException;
import java.text.ParseException;
import java.util.List;
import java.util.function.Consumer;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.mwe.utils.ProjectMapping;
import org.eclipse.emf.mwe.utils.StandaloneSetup;
import org.eclipse.xtext.generator.GeneratorDelegate;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.generator.OutputConfiguration;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.util.CancelIndicator;
import org.eclipse.xtext.validation.CheckMode;
import org.eclipse.xtext.validation.IResourceValidator;
import org.eclipse.xtext.validation.Issue;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.InputOutput;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
@SuppressWarnings("all")
public class Main {
private final String USAGE_STR = "RDL2code [-h] [-v] [-f] [-n <namespace>] [-I <RDL include dir] [-o <output dir>] <input file> <input file>";
public static void main(final String[] args) {
boolean _isEmpty = ((List<String>)Conversions.doWrapArray(args)).isEmpty();
if (_isEmpty) {
System.err.println("Aborting: no path to RDL file provided!");
return;
}
final Injector injector = new RDLStandaloneSetup().createInjectorAndDoEMFRegistration();
final Main main = injector.<Main>getInstance(Main.class);
try {
main.run(args);
} catch (final Throwable _t) {
if (_t instanceof MalformedParametersException) {
final MalformedParametersException e = (MalformedParametersException)_t;
String _message = e.getMessage();
String _plus = ("Command line error " + _message);
InputOutput.<String>print(_plus);
System.exit(1);
} else if (_t instanceof IllegalArgumentException) {
final IllegalArgumentException e_1 = (IllegalArgumentException)_t;
String _message_1 = e_1.getMessage();
String _plus_1 = ("generation error " + _message_1);
InputOutput.<String>print(_plus_1);
e_1.printStackTrace();
System.exit(2);
} else if (_t instanceof ParseException) {
final ParseException e_2 = (ParseException)_t;
String _message_2 = e_2.getMessage();
String _plus_2 = ("parse problem " + _message_2);
String _plus_3 = (_plus_2 + " (");
int _errorOffset = e_2.getErrorOffset();
String _plus_4 = (_plus_3 + Integer.valueOf(_errorOffset));
String _plus_5 = (_plus_4 + ")");
InputOutput.<String>print(_plus_5);
System.exit(3);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
@Inject
private Provider<ResourceSet> resourceSetProvider;
@Inject
private IResourceValidator validator;
@Inject
private GeneratorDelegate generator;
@Inject
private JavaIoFileSystemAccess fileAccess;
public void run(final String[] args) {
final Options opt = new Options(args, 0, Integer.MAX_VALUE);
opt.getSet().addOption("h", Options.Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("v", Options.Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("f", Options.Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("n", Options.Separator.BLANK, Options.Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("o", Options.Separator.BLANK, Options.Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("I", Options.Separator.BLANK, Options.Multiplicity.ZERO_OR_ONE);
boolean _check = opt.check(false, false);
boolean _not = (!_check);
if (_not) {
System.err.println(("Usage is: " + this.USAGE_STR));
String _checkErrors = opt.getCheckErrors();
throw new MalformedParametersException(_checkErrors);
}
boolean _isSet = opt.getSet().isSet("h");
if (_isSet) {
InputOutput.<String>println(("Usage: " + this.USAGE_STR));
return;
}
boolean _xifexpression = false;
boolean _isSet_1 = opt.getSet().isSet("v");
if (_isSet_1) {
_xifexpression = true;
} else {
_xifexpression = false;
}
final boolean verbose = _xifexpression;
boolean _isSet_2 = opt.getSet().isSet("I");
if (_isSet_2) {
final ProjectMapping projectMapping = new ProjectMapping();
projectMapping.setProjectName("RDL Repository");
projectMapping.setPath(opt.getSet().getOption("I").getResultValue(0));
new StandaloneSetup().addProjectMapping(projectMapping);
}
this.fileAccess.setOutputPath("src-gen/");
boolean _isSet_3 = opt.getSet().isSet("o");
if (_isSet_3) {
this.fileAccess.setOutputPath(opt.getSet().getOption("o").getResultValue(0));
OutputConfiguration _get = this.fileAccess.getOutputConfigurations().get(IFileSystemAccess.DEFAULT_OUTPUT);
if (_get!=null) {
_get.setOverrideExistingResources(true);
}
}
final Consumer<String> _function = (String string) -> {
try {
if (verbose) {
InputOutput.<String>println(("Processing " + string));
}
ResourceSet _get_1 = this.resourceSetProvider.get();
final XtextResourceSet resourceSet = ((XtextResourceSet) _get_1);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
final Resource resource = resourceSet.getResource(URI.createFileURI(string), true);
final List<Issue> issues = this.validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);
boolean _isEmpty = issues.isEmpty();
boolean _not_1 = (!_isEmpty);
if (_not_1) {
URI _uRI = resource.getURI();
String _plus = ("Error validating " + _uRI);
System.err.println(_plus);
final Consumer<Issue> _function_1 = (Issue it) -> {
System.err.println(it);
};
issues.forEach(_function_1);
URI _uRI_1 = resource.getURI();
String _plus_1 = ("error validating " + _uRI_1);
int _size = issues.size();
throw new ParseException(_plus_1, _size);
}
RdlGeneratorContext _rdlGeneratorContext = new RdlGeneratorContext();
final Procedure1<RdlGeneratorContext> _function_2 = (RdlGeneratorContext it) -> {
it.setCancelIndicator(CancelIndicator.NullImpl);
};
final RdlGeneratorContext context = ObjectExtensions.<RdlGeneratorContext>operator_doubleArrow(_rdlGeneratorContext, _function_2);
context.forceOverwrite = opt.getSet().isSet("f");
boolean _isSet_4 = opt.getSet().isSet("n");
if (_isSet_4) {
context.namespace = opt.getSet().getOption("n").getResultValue(0);
}
this.generator.generate(resource, this.fileAccess, context);
if (verbose) {
InputOutput.<String>println((("Code generation for " + string) + " finished"));
}
try {
if (verbose) {
URI _uRI_2 = this.fileAccess.getURI("", "incl-out");
String _plus_2 = ("includes are in " + _uRI_2);
InputOutput.<String>println(_plus_2);
}
} catch (final Throwable _t) {
if (_t instanceof Exception) {
URI _uRI_3 = this.fileAccess.getURI("");
String _plus_3 = ("includes are in " + _uRI_3);
InputOutput.<String>println(_plus_3);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
try {
if (verbose) {
URI _uRI_2 = this.fileAccess.getURI("", "src-out");
String _plus_2 = ("sources are in " + _uRI_2);
InputOutput.<String>println(_plus_2);
}
} catch (final Throwable _t) {
if (_t instanceof Exception) {
URI _uRI_3 = this.fileAccess.getURI("");
String _plus_3 = ("sources are in " + _uRI_3);
InputOutput.<String>println(_plus_3);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
opt.getSet().getData().forEach(_function);
}
}

View File

@ -1,310 +0,0 @@
package com.minres.rdl.generator;
import com.google.common.base.Objects;
import com.minres.rdl.RdlUtil;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.ComponentDefinitionType;
import com.minres.rdl.rdl.Instantiation;
import java.util.Iterator;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.IteratorExtensions;
@SuppressWarnings("all")
public class ModuleGenerator extends RdlBaseGenerator {
private final ComponentDefinition componentDefinition;
public ModuleGenerator(final ComponentDefinition definition) {
this.componentDefinition = definition;
}
@Override
public boolean getOverwrite() {
return false;
}
@Override
public String generateHeader(final String namespace) {
String _xblockexpression = null;
{
ComponentDefinitionType _type = this.componentDefinition.getType();
boolean _notEquals = (!Objects.equal(_type, ComponentDefinitionType.REGFILE));
if (_notEquals) {
return "";
}
final Function1<Notifier, Boolean> _function = (Notifier it) -> {
return Boolean.valueOf((it instanceof ComponentDefinition));
};
final Function1<Notifier, ComponentDefinition> _function_1 = (Notifier it) -> {
return ((ComponentDefinition) it);
};
final Function1<ComponentDefinition, Boolean> _function_2 = (ComponentDefinition it) -> {
ComponentDefinitionType _type_1 = it.getType();
return Boolean.valueOf(Objects.equal(_type_1, ComponentDefinitionType.ADDRMAP));
};
final Function1<ComponentDefinition, Boolean> _function_3 = (ComponentDefinition def) -> {
final Function1<Instantiation, Boolean> _function_4 = (Instantiation it) -> {
ComponentDefinition _componentRef = it.getComponentRef();
return Boolean.valueOf(Objects.equal(_componentRef, this.componentDefinition));
};
int _size = IterableExtensions.size(IterableExtensions.<Instantiation>filter(def.getInstantiations(), _function_4));
return Boolean.valueOf((_size > 0));
};
final Iterator<ComponentDefinition> addrMaps = IteratorExtensions.<ComponentDefinition>filter(IteratorExtensions.<ComponentDefinition>filter(IteratorExtensions.<Notifier, ComponentDefinition>map(IteratorExtensions.<Notifier>filter(this.componentDefinition.eResource().getResourceSet().getAllContents(), _function), _function_1), _function_2), _function_3);
int _size = IteratorExtensions.size(addrMaps);
boolean _equals = (_size == 0);
if (_equals) {
return "";
}
StringConcatenation _builder = new StringConcatenation();
_builder.append("#ifndef _");
String _upperCase = namespace.toUpperCase();
_builder.append(_upperCase);
_builder.append("_");
String _upperCase_1 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_1);
_builder.append("_H_");
_builder.newLineIfNotEmpty();
_builder.append("#define _");
String _upperCase_2 = namespace.toUpperCase();
_builder.append(_upperCase_2);
_builder.append("_");
String _upperCase_3 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_3);
_builder.append("_H_");
_builder.newLineIfNotEmpty();
_builder.append("#include <scc/tlm_target.h>");
_builder.newLine();
_builder.newLine();
_builder.append("namespace ");
_builder.append(namespace);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("namespace gen {");
_builder.newLine();
_builder.append("class ");
String _effectiveName = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName);
_builder.append("_regs;");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("class ");
String _effectiveName_1 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_1);
_builder.append(" : public sc_core::sc_module, public scc::tlm_target<> {");
_builder.newLineIfNotEmpty();
_builder.append("public:");
_builder.newLine();
_builder.append(" ");
_builder.append("sc_core::sc_in<sc_core::sc_time> clk_i{\"clk_i\"};");
_builder.newLine();
_builder.append(" ");
_builder.append("sc_core::sc_in<bool> rst_i{\"rst_i\"};");
_builder.newLine();
_builder.append(" ");
String _effectiveName_2 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_2, " ");
_builder.append("(sc_core::sc_module_name nm);");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("virtual ~");
String _effectiveName_3 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_3, " ");
_builder.append("() override;");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("protected:");
_builder.newLine();
_builder.append(" ");
_builder.append("void clock_cb();");
_builder.newLine();
_builder.append(" ");
_builder.append("void reset_cb();");
_builder.newLine();
_builder.append(" ");
_builder.append("sc_core::sc_time clk;");
_builder.newLine();
_builder.append(" ");
_builder.append("std::unique_ptr<gen::");
String _effectiveName_4 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_4, " ");
_builder.append("_regs> regs;");
_builder.newLineIfNotEmpty();
_builder.append("};");
_builder.newLine();
_builder.newLine();
_builder.append("} /* namespace ");
_builder.append(namespace);
_builder.append(" */");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("#endif /* _");
String _upperCase_4 = namespace.toUpperCase();
_builder.append(_upperCase_4);
_builder.append("_");
String _upperCase_5 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_5);
_builder.append("_H_ */");
_builder.newLineIfNotEmpty();
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
@Override
public String generateSource(final String namespace) {
String _xblockexpression = null;
{
ComponentDefinitionType _type = this.componentDefinition.getType();
boolean _notEquals = (!Objects.equal(_type, ComponentDefinitionType.REGFILE));
if (_notEquals) {
return "";
}
final Function1<Notifier, Boolean> _function = (Notifier it) -> {
return Boolean.valueOf((it instanceof ComponentDefinition));
};
final Function1<Notifier, ComponentDefinition> _function_1 = (Notifier it) -> {
return ((ComponentDefinition) it);
};
final Function1<ComponentDefinition, Boolean> _function_2 = (ComponentDefinition it) -> {
ComponentDefinitionType _type_1 = it.getType();
return Boolean.valueOf(Objects.equal(_type_1, ComponentDefinitionType.ADDRMAP));
};
final Function1<ComponentDefinition, Boolean> _function_3 = (ComponentDefinition def) -> {
final Function1<Instantiation, Boolean> _function_4 = (Instantiation it) -> {
ComponentDefinition _componentRef = it.getComponentRef();
return Boolean.valueOf(Objects.equal(_componentRef, this.componentDefinition));
};
int _size = IterableExtensions.size(IterableExtensions.<Instantiation>filter(def.getInstantiations(), _function_4));
return Boolean.valueOf((_size > 0));
};
final Iterator<ComponentDefinition> addrMaps = IteratorExtensions.<ComponentDefinition>filter(IteratorExtensions.<ComponentDefinition>filter(IteratorExtensions.<Notifier, ComponentDefinition>map(IteratorExtensions.<Notifier>filter(this.componentDefinition.eResource().getResourceSet().getAllContents(), _function), _function_1), _function_2), _function_3);
int _size = IteratorExtensions.size(addrMaps);
boolean _equals = (_size == 0);
if (_equals) {
return "";
}
StringConcatenation _builder = new StringConcatenation();
_builder.append("/*");
_builder.newLine();
_builder.append(" ");
_builder.append("* Copyright (c) 2019 -2022 MINRES Technologies GmbH");
_builder.newLine();
_builder.append(" ");
_builder.append("*");
_builder.newLine();
_builder.append(" ");
_builder.append("* SPDX-License-Identifier: Apache-2.0");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.newLine();
_builder.append("#include \"");
String _effectiveName = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName);
_builder.append(".h\"");
_builder.newLineIfNotEmpty();
_builder.append("#include \"gen/");
String _effectiveName_1 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_1);
_builder.append(".h\"");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("#include <scc/utilities.h>");
_builder.newLine();
_builder.newLine();
_builder.append("namespace ");
_builder.append(namespace);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("SC_HAS_PROCESS(");
String _effectiveName_2 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_2);
_builder.append(");// NOLINT");
_builder.newLineIfNotEmpty();
_builder.newLine();
String _effectiveName_3 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_3);
_builder.append("::");
String _effectiveName_4 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_4);
_builder.append("(sc_core::sc_module_name nm)");
_builder.newLineIfNotEmpty();
_builder.append(": sc_core::sc_module(nm)");
_builder.newLine();
_builder.append(", scc::tlm_target<>(clk)");
_builder.newLine();
_builder.append(", NAMEDD(regs, gen::");
String _effectiveName_5 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_5);
_builder.append("_regs) {");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("regs->registerResources(*this);");
_builder.newLine();
_builder.append(" ");
_builder.append("SC_METHOD(clock_cb);");
_builder.newLine();
_builder.append(" ");
_builder.append("sensitive << clk_i;");
_builder.newLine();
_builder.append(" ");
_builder.append("SC_METHOD(reset_cb);");
_builder.newLine();
_builder.append(" ");
_builder.append("sensitive << rst_i;");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
String _effectiveName_6 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_6);
_builder.append("::~");
String _effectiveName_7 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_7);
_builder.append("() {} // NOLINT");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("void ");
String _effectiveName_8 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_8);
_builder.append("::clock_cb() { this->clk = clk_i.read(); }");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("void ");
String _effectiveName_9 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_9);
_builder.append("::reset_cb() {");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("if (rst_i.read()) {");
_builder.newLine();
_builder.append(" ");
_builder.append("regs->reset_start();");
_builder.newLine();
_builder.append(" ");
_builder.append("} else {");
_builder.newLine();
_builder.append(" ");
_builder.append("regs->reset_stop();");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("} /* namespace ");
_builder.append(namespace);
_builder.append(" */");
_builder.newLineIfNotEmpty();
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
}

View File

@ -1,124 +0,0 @@
/**
* generated by Xtext 2.12.0
*/
package com.minres.rdl.generator;
import com.minres.rdl.RdlUtil;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.ComponentDefinitionType;
import java.util.Collections;
import java.util.Map;
import java.util.function.BiConsumer;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.generator.AbstractGenerator;
import org.eclipse.xtext.generator.IFileSystemAccess2;
import org.eclipse.xtext.generator.IGeneratorContext;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IteratorExtensions;
import org.eclipse.xtext.xbase.lib.Pair;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
/**
* Generates code from your model files on save.
*
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
*/
@SuppressWarnings("all")
public class RDLGenerator extends AbstractGenerator {
@Override
public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) {
boolean _xifexpression = false;
if ((context instanceof RdlGeneratorContext)) {
_xifexpression = ((RdlGeneratorContext)context).forceOverwrite;
} else {
_xifexpression = false;
}
final boolean force = _xifexpression;
String _xifexpression_1 = null;
if ((context instanceof RdlGeneratorContext)) {
_xifexpression_1 = ((RdlGeneratorContext)context).namespace;
} else {
_xifexpression_1 = "sysc";
}
final String namespace = _xifexpression_1;
final Function1<Notifier, Boolean> _function = (Notifier it) -> {
return Boolean.valueOf((it instanceof ComponentDefinition));
};
final Function1<Notifier, ComponentDefinition> _function_1 = (Notifier it) -> {
return ((ComponentDefinition) it);
};
final Procedure1<ComponentDefinition> _function_2 = (ComponentDefinition it) -> {
final Map<String, RdlBaseGenerator> genMap = this.fileGenerator(it);
if ((genMap != null)) {
final BiConsumer<String, RdlBaseGenerator> _function_3 = (String p1, RdlBaseGenerator gen) -> {
final String header = gen.generateHeader(namespace);
String _effectiveName = RdlUtil.effectiveName(it);
String _plus = ((p1 + "/") + _effectiveName);
final String inclFileName = (_plus + ".h");
final String inclCfg = this.outputConfig(fsa, "incl-out");
if (((((force || (!fsa.isFile(inclFileName, inclCfg))) || gen.getOverwrite()) && (header != null)) && (header.length() > 0))) {
fsa.generateFile(inclFileName, inclCfg, header);
}
final String source = gen.generateSource(namespace);
String _effectiveName_1 = RdlUtil.effectiveName(it);
String _plus_1 = ((p1 + "/") + _effectiveName_1);
final String srcFileName = (_plus_1 + ".cpp");
final String srcCfg = this.outputConfig(fsa, "src-out");
if (((((force || (!fsa.isFile(srcFileName, srcCfg))) || gen.getOverwrite()) && (source != null)) && (source.length() > 0))) {
fsa.generateFile(srcFileName, srcCfg, source);
}
};
genMap.forEach(_function_3);
}
};
IteratorExtensions.<ComponentDefinition>forEach(IteratorExtensions.<Notifier, ComponentDefinition>map(IteratorExtensions.<Notifier>filter(resource.getResourceSet().getAllContents(), _function), _function_1), _function_2);
}
public Map<String, RdlBaseGenerator> fileGenerator(final ComponentDefinition definition) {
Map<String, RdlBaseGenerator> _switchResult = null;
ComponentDefinitionType _type = definition.getType();
if (_type != null) {
switch (_type) {
case REGFILE:
RegfileGenerator _regfileGenerator = new RegfileGenerator(definition);
Pair<String, RegfileGenerator> _mappedTo = Pair.<String, RegfileGenerator>of("gen", _regfileGenerator);
FwRegfileGenerator _fwRegfileGenerator = new FwRegfileGenerator(definition);
Pair<String, FwRegfileGenerator> _mappedTo_1 = Pair.<String, FwRegfileGenerator>of("fw", _fwRegfileGenerator);
ModuleGenerator _moduleGenerator = new ModuleGenerator(definition);
Pair<String, ModuleGenerator> _mappedTo_2 = Pair.<String, ModuleGenerator>of(".", _moduleGenerator);
_switchResult = Collections.<String, RdlBaseGenerator>unmodifiableMap(CollectionLiterals.<String, RdlBaseGenerator>newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2));
break;
case ADDRMAP:
AddrmapGenerator _addrmapGenerator = new AddrmapGenerator(definition);
Pair<String, AddrmapGenerator> _mappedTo_3 = Pair.<String, AddrmapGenerator>of("gen", _addrmapGenerator);
FwAddrmapGenerator _fwAddrmapGenerator = new FwAddrmapGenerator(definition);
Pair<String, FwAddrmapGenerator> _mappedTo_4 = Pair.<String, FwAddrmapGenerator>of("fw", _fwAddrmapGenerator);
_switchResult = Collections.<String, RdlBaseGenerator>unmodifiableMap(CollectionLiterals.<String, RdlBaseGenerator>newHashMap(_mappedTo_3, _mappedTo_4));
break;
default:
_switchResult = null;
break;
}
} else {
_switchResult = null;
}
return _switchResult;
}
public String outputConfig(final IFileSystemAccess2 fsa, final String string) {
String output_config = string;
try {
fsa.getURI("", output_config);
} catch (final Throwable _t) {
if (_t instanceof Exception) {
output_config = "DEFAULT_OUTPUT";
} else {
throw Exceptions.sneakyThrow(_t);
}
}
return output_config;
}
}

View File

@ -1,10 +0,0 @@
package com.minres.rdl.generator;
@SuppressWarnings("all")
public abstract class RdlBaseGenerator {
public abstract String generateHeader(final String namespace);
public abstract String generateSource(final String namespace);
public abstract boolean getOverwrite();
}

View File

@ -1,10 +0,0 @@
package com.minres.rdl.generator;
import org.eclipse.xtext.generator.GeneratorContext;
@SuppressWarnings("all")
public class RdlGeneratorContext extends GeneratorContext {
public boolean forceOverwrite = false;
public String namespace = "scc";
}

View File

@ -1,729 +0,0 @@
package com.minres.rdl.generator;
import com.google.common.base.Objects;
import com.minres.rdl.IntegerWithRadix;
import com.minres.rdl.RdlUtil;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.ComponentDefinitionType;
import com.minres.rdl.rdl.ComponentInstance;
import com.minres.rdl.rdl.Instantiation;
import com.minres.rdl.rdl.Range;
import java.util.Date;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@SuppressWarnings("all")
public class RegfileGenerator extends RdlBaseGenerator {
private final ComponentDefinition componentDefinition;
public RegfileGenerator(final ComponentDefinition definition) {
this.componentDefinition = definition;
}
@Override
public boolean getOverwrite() {
return true;
}
@Override
public String generateHeader(final String namespace) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("////////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.append("// Copyright (C) 2017-2022, MINRES Technologies GmbH");
_builder.newLine();
_builder.append("// All rights reserved.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// Redistribution and use in source and binary forms, with or without");
_builder.newLine();
_builder.append("// modification, are permitted provided that the following conditions are met:");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// 1. Redistributions of source code must retain the above copyright notice,");
_builder.newLine();
_builder.append("// this list of conditions and the following disclaimer.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// 2. Redistributions in binary form must reproduce the above copyright notice,");
_builder.newLine();
_builder.append("// this list of conditions and the following disclaimer in the documentation");
_builder.newLine();
_builder.append("// and/or other materials provided with the distribution.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// 3. Neither the name of the copyright holder nor the names of its contributors");
_builder.newLine();
_builder.append("// may be used to endorse or promote products derived from this software");
_builder.newLine();
_builder.append("// without specific prior written permission.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"");
_builder.newLine();
_builder.append("// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE");
_builder.newLine();
_builder.append("// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE");
_builder.newLine();
_builder.append("// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE");
_builder.newLine();
_builder.append("// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR");
_builder.newLine();
_builder.append("// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF");
_builder.newLine();
_builder.append("// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS");
_builder.newLine();
_builder.append("// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN");
_builder.newLine();
_builder.append("// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)");
_builder.newLine();
_builder.append("// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE");
_builder.newLine();
_builder.append("// POSSIBILITY OF SUCH DAMAGE.");
_builder.newLine();
_builder.append("//");
_builder.newLine();
_builder.append("// Created on: ");
Date _date = new Date();
_builder.append(_date);
_builder.newLineIfNotEmpty();
_builder.append("// * ");
String _effectiveName = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName);
_builder.append(".h Author: <RDL Generator>");
_builder.newLineIfNotEmpty();
_builder.append("//");
_builder.newLine();
_builder.append("////////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.newLine();
_builder.append("#ifndef _");
String _upperCase = namespace.toUpperCase();
_builder.append(_upperCase);
_builder.append("_GEN_");
String _upperCase_1 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_1);
_builder.append("_H_");
_builder.newLineIfNotEmpty();
_builder.append("#define _");
String _upperCase_2 = namespace.toUpperCase();
_builder.append(_upperCase_2);
_builder.append("_GEN_");
String _upperCase_3 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_3);
_builder.append("_H_");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("#include <scc/utilities.h>");
_builder.newLine();
_builder.append("#include <util/bit_field.h>");
_builder.newLine();
_builder.append("#include <scc/register.h>");
_builder.newLine();
_builder.append("#include <scc/tlm_target.h>");
_builder.newLine();
{
EList<Instantiation> _instantiations = this.componentDefinition.getInstantiations();
for(final Instantiation instantiation : _instantiations) {
{
ComponentDefinitionType _type = RdlUtil.getComponentDefinition(instantiation).getType();
boolean _equals = Objects.equal(_type, ComponentDefinitionType.REGFILE);
if (_equals) {
_builder.append("#include \"");
String _effectiveName_1 = RdlUtil.effectiveName(RdlUtil.getComponentDefinition(instantiation));
_builder.append(_effectiveName_1);
_builder.append(".h\"");
_builder.newLineIfNotEmpty();
}
}
}
}
_builder.newLine();
_builder.append("namespace ");
_builder.append(namespace);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("namespace gen {");
_builder.newLine();
_builder.newLine();
_builder.append("class ");
String _effectiveName_2 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_2);
_builder.append("_regs :");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("public sc_core::sc_module,");
_builder.newLine();
_builder.append(" ");
_builder.append("public scc::resetable");
_builder.newLine();
_builder.append("{");
_builder.newLine();
_builder.append("public:");
_builder.newLine();
_builder.append(" ");
_builder.append("//////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.append(" ");
_builder.append("// storage declarations");
_builder.newLine();
_builder.append(" ");
_builder.append("//////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
{
EList<ComponentDefinition> _componentDefinitions = this.componentDefinition.getComponentDefinitions();
for(final ComponentDefinition cdef : _componentDefinitions) {
{
ComponentDefinitionType _type_1 = cdef.getType();
boolean _equals_1 = Objects.equal(_type_1, ComponentDefinitionType.REG);
if (_equals_1) {
_builder.append(" ");
_builder.append("BEGIN_BF_DECL(");
String _effectiveName_3 = RdlUtil.effectiveName(cdef);
_builder.append(_effectiveName_3, " ");
_builder.append("+\'_t\'», uint");
_builder.append(cdef, " ");
_builder.append("_t);");
_builder.newLineIfNotEmpty();
_builder.append(" ");
String _genFieldDeclarations = this.genFieldDeclarations(cdef);
_builder.append(_genFieldDeclarations, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("END_BF_DECL();");
_builder.newLine();
}
}
}
}
{
EList<Instantiation> _instantiations_1 = this.componentDefinition.getInstantiations();
for(final Instantiation instantiation_1 : _instantiations_1) {
{
ComponentDefinitionType _type_2 = RdlUtil.getComponentDefinition(instantiation_1).getType();
boolean _equals_2 = Objects.equal(_type_2, ComponentDefinitionType.REGFILE);
if (_equals_2) {
{
EList<ComponentInstance> _componentInstances = instantiation_1.getComponentInstances();
for(final ComponentInstance instance : _componentInstances) {
_builder.append(" ");
String _effectiveName_4 = RdlUtil.effectiveName(RdlUtil.getComponentDefinition(instantiation_1));
_builder.append(_effectiveName_4, " ");
_builder.append("_regs i_");
String _name = instance.getName();
_builder.append(_name, " ");
_builder.append("{\"");
String _name_1 = instance.getName();
_builder.append(_name_1, " ");
_builder.append("\"};");
_builder.newLineIfNotEmpty();
}
}
} else {
ComponentDefinitionType _type_3 = RdlUtil.getComponentDefinition(instantiation_1).getType();
boolean _equals_3 = Objects.equal(_type_3, ComponentDefinitionType.REG);
if (_equals_3) {
{
boolean _isFilledByField = RdlUtil.isFilledByField(instantiation_1);
if (_isFilledByField) {
{
final Function1<ComponentInstance, Boolean> _function = (ComponentInstance it) -> {
Range _range = it.getRange();
return Boolean.valueOf((_range == null));
};
int _size = IterableExtensions.size(IterableExtensions.<ComponentInstance>filter(instantiation_1.getComponentInstances(), _function));
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
_builder.append(" ");
_builder.append("uint");
long _size_1 = RdlUtil.getSize(instantiation_1);
_builder.append(_size_1, " ");
_builder.append("_t ");
final Function1<ComponentInstance, Boolean> _function_1 = (ComponentInstance it) -> {
Range _range = it.getRange();
return Boolean.valueOf((_range == null));
};
final Function1<ComponentInstance, String> _function_2 = (ComponentInstance it) -> {
String _name_2 = it.getName();
return ("r_" + _name_2);
};
String _join = IterableExtensions.join(IterableExtensions.<ComponentInstance, String>map(IterableExtensions.<ComponentInstance>filter(instantiation_1.getComponentInstances(), _function_1), _function_2), ", ");
_builder.append(_join, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
{
final Function1<ComponentInstance, Boolean> _function_3 = (ComponentInstance it) -> {
Range _range = it.getRange();
return Boolean.valueOf((_range != null));
};
Iterable<ComponentInstance> _filter = IterableExtensions.<ComponentInstance>filter(instantiation_1.getComponentInstances(), _function_3);
for(final ComponentInstance componentInstance : _filter) {
_builder.append(" ");
_builder.append("std::array<uint");
long _size_2 = RdlUtil.getSize(instantiation_1);
_builder.append(_size_2, " ");
_builder.append("_t, ");
long _absSize = RdlUtil.absSize(componentInstance.getRange());
_builder.append(_absSize, " ");
_builder.append("> r_");
String _name_2 = componentInstance.getName();
_builder.append(_name_2, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
} else {
int _size_3 = RdlUtil.getComponentDefinition(instantiation_1).getInstantiations().size();
boolean _equals_4 = (_size_3 == 0);
if (_equals_4) {
{
final Function1<ComponentInstance, Boolean> _function_4 = (ComponentInstance it) -> {
Range _range = it.getRange();
return Boolean.valueOf((_range == null));
};
int _size_4 = IterableExtensions.size(IterableExtensions.<ComponentInstance>filter(instantiation_1.getComponentInstances(), _function_4));
boolean _greaterThan_1 = (_size_4 > 0);
if (_greaterThan_1) {
_builder.append(" ");
_builder.append("uint");
long _size_5 = RdlUtil.getSize(instantiation_1);
_builder.append(_size_5, " ");
_builder.append("_t ");
final Function1<ComponentInstance, Boolean> _function_5 = (ComponentInstance it) -> {
Range _range = it.getRange();
return Boolean.valueOf((_range == null));
};
final Function1<ComponentInstance, String> _function_6 = (ComponentInstance it) -> {
String _name_3 = it.getName();
return ("r_" + _name_3);
};
String _join_1 = IterableExtensions.join(IterableExtensions.<ComponentInstance, String>map(IterableExtensions.<ComponentInstance>filter(instantiation_1.getComponentInstances(), _function_5), _function_6), ", ");
_builder.append(_join_1, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
{
final Function1<ComponentInstance, Boolean> _function_7 = (ComponentInstance it) -> {
Range _range = it.getRange();
return Boolean.valueOf((_range != null));
};
Iterable<ComponentInstance> _filter_1 = IterableExtensions.<ComponentInstance>filter(instantiation_1.getComponentInstances(), _function_7);
for(final ComponentInstance componentInstance_1 : _filter_1) {
_builder.append(" ");
_builder.append("std::array<uint");
long _size_6 = RdlUtil.getSize(instantiation_1);
_builder.append(_size_6, " ");
_builder.append("_t, ");
long _absSize_1 = RdlUtil.absSize(componentInstance_1.getRange());
_builder.append(_absSize_1, " ");
_builder.append("> r_");
String _name_3 = componentInstance_1.getName();
_builder.append(_name_3, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
} else {
_builder.append(" ");
_builder.append("BEGIN_BF_DECL(");
String _effectiveName_5 = RdlUtil.effectiveName(instantiation_1.getComponent());
_builder.append(_effectiveName_5, " ");
_builder.append("_t, uint");
long _size_7 = RdlUtil.getSize(instantiation_1);
_builder.append(_size_7, " ");
_builder.append("_t);");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append(" ");
String _genFieldDeclarations_1 = this.genFieldDeclarations(RdlUtil.definingComponent(instantiation_1));
_builder.append(_genFieldDeclarations_1, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("END_BF_DECL() ");
final Function1<ComponentInstance, Boolean> _function_8 = (ComponentInstance it) -> {
Range _range = it.getRange();
return Boolean.valueOf((_range == null));
};
final Function1<ComponentInstance, String> _function_9 = (ComponentInstance it) -> {
String _name_4 = it.getName();
return ("r_" + _name_4);
};
String _join_2 = IterableExtensions.join(IterableExtensions.<ComponentInstance, String>map(IterableExtensions.<ComponentInstance>filter(instantiation_1.getComponentInstances(), _function_8), _function_9), ", ");
_builder.append(_join_2, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
{
final Function1<ComponentInstance, Boolean> _function_10 = (ComponentInstance it) -> {
Range _range = it.getRange();
return Boolean.valueOf((_range != null));
};
Iterable<ComponentInstance> _filter_2 = IterableExtensions.<ComponentInstance>filter(instantiation_1.getComponentInstances(), _function_10);
for(final ComponentInstance componentInstance_2 : _filter_2) {
_builder.append(" ");
_builder.append("std::array<");
String _effectiveName_6 = RdlUtil.effectiveName(instantiation_1.getComponent());
_builder.append(_effectiveName_6, " ");
_builder.append("_t, ");
long _absSize_2 = RdlUtil.absSize(componentInstance_2.getRange());
_builder.append(_absSize_2, " ");
_builder.append("> r_");
String _name_4 = componentInstance_2.getName();
_builder.append(_name_4, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
}
}
}
}
}
}
}
}
_builder.append(" ");
_builder.append("//////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.append(" ");
_builder.append("// register declarations");
_builder.newLine();
_builder.append(" ");
_builder.append("//////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
{
EList<Instantiation> _instantiations_2 = this.componentDefinition.getInstantiations();
for(final Instantiation instantiation_2 : _instantiations_2) {
{
EList<ComponentInstance> _componentInstances_1 = instantiation_2.getComponentInstances();
for(final ComponentInstance instance_1 : _componentInstances_1) {
{
ComponentDefinitionType _type_4 = RdlUtil.getComponentDefinition(instantiation_2).getType();
boolean _equals_5 = Objects.equal(_type_4, ComponentDefinitionType.REGFILE);
if (_equals_5) {
_builder.append(" ");
_builder.append("// scc::sc_register_file<");
String _effectiveName_7 = RdlUtil.effectiveName(RdlUtil.getComponentDefinition(instantiation_2));
_builder.append(_effectiveName_7, " ");
_builder.append("_regs> ");
String _name_5 = instance_1.getName();
_builder.append(_name_5, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
} else {
ComponentDefinitionType _type_5 = RdlUtil.getComponentDefinition(instantiation_2).getType();
boolean _equals_6 = Objects.equal(_type_5, ComponentDefinitionType.REG);
if (_equals_6) {
{
Range _range = instance_1.getRange();
boolean _tripleEquals = (_range == null);
if (_tripleEquals) {
{
int _size_8 = RdlUtil.getComponentDefinition(instantiation_2).getInstantiations().size();
boolean _equals_7 = (_size_8 == 0);
if (_equals_7) {
_builder.append(" ");
_builder.append("scc::sc_register<uint");
long _size_9 = RdlUtil.getSize(instantiation_2);
_builder.append(_size_9, " ");
_builder.append("_t> ");
String _name_6 = instance_1.getName();
_builder.append(_name_6, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
} else {
boolean _isFilledByField_1 = RdlUtil.isFilledByField(instantiation_2);
if (_isFilledByField_1) {
_builder.append(" ");
_builder.append("scc::sc_register<uint");
long _size_10 = RdlUtil.getSize(instantiation_2);
_builder.append(_size_10, " ");
_builder.append("_t> ");
String _name_7 = instance_1.getName();
_builder.append(_name_7, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
} else {
_builder.append(" ");
_builder.append("scc::sc_register<");
String _effectiveName_8 = RdlUtil.effectiveName(RdlUtil.getComponentDefinition(instantiation_2));
_builder.append(_effectiveName_8, " ");
_builder.append("_t> ");
String _name_8 = instance_1.getName();
_builder.append(_name_8, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
}
} else {
{
int _size_11 = RdlUtil.getComponentDefinition(instantiation_2).getInstantiations().size();
boolean _equals_8 = (_size_11 == 0);
if (_equals_8) {
_builder.append(" ");
_builder.append("scc::sc_register_indexed<uint");
long _size_12 = RdlUtil.getSize(instantiation_2);
_builder.append(_size_12, " ");
_builder.append("_t, ");
long _absSize_3 = RdlUtil.absSize(instance_1.getRange());
_builder.append(_absSize_3, " ");
_builder.append("> ");
String _name_9 = instance_1.getName();
_builder.append(_name_9, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
} else {
boolean _isFilledByField_2 = RdlUtil.isFilledByField(instantiation_2);
if (_isFilledByField_2) {
_builder.append(" ");
_builder.append("scc::sc_register_indexed<uint");
long _size_13 = RdlUtil.getSize(instantiation_2);
_builder.append(_size_13, " ");
_builder.append("_t, ");
long _absSize_4 = RdlUtil.absSize(instance_1.getRange());
_builder.append(_absSize_4, " ");
_builder.append("> ");
String _name_10 = instance_1.getName();
_builder.append(_name_10, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
} else {
_builder.append(" ");
_builder.append("scc::sc_register_indexed<");
String _effectiveName_9 = RdlUtil.effectiveName(instantiation_2.getComponent());
_builder.append(_effectiveName_9, " ");
_builder.append("_t, ");
long _absSize_5 = RdlUtil.absSize(instance_1.getRange());
_builder.append(_absSize_5, " ");
_builder.append("> ");
String _name_11 = instance_1.getName();
_builder.append(_name_11, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
}
}
}
}
}
}
}
}
}
}
_builder.append(" ");
_builder.newLine();
_builder.append(" ");
String _effectiveName_10 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_10, " ");
_builder.append("_regs(sc_core::sc_module_name nm);");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append(" ");
_builder.append("template<unsigned BUSWIDTH=32>");
_builder.newLine();
_builder.append(" ");
_builder.append("void registerResources(scc::tlm_target<BUSWIDTH>& target, uint64_t offset=0);");
_builder.newLine();
_builder.append("};");
_builder.newLine();
_builder.append("} // namespace gen");
_builder.newLine();
_builder.append("} // namespace ");
_builder.append(namespace);
_builder.newLineIfNotEmpty();
_builder.append("//////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.append("// member functions");
_builder.newLine();
_builder.append("//////////////////////////////////////////////////////////////////////////////");
_builder.newLine();
_builder.newLine();
_builder.append("inline ");
_builder.append(namespace);
_builder.append("::gen::");
String _effectiveName_11 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_11);
_builder.append("_regs::");
String _effectiveName_12 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_12);
_builder.append("_regs(sc_core::sc_module_name nm)");
_builder.newLineIfNotEmpty();
_builder.append(": sc_core::sc_module(nm)");
_builder.newLine();
{
EList<Instantiation> _instantiations_3 = this.componentDefinition.getInstantiations();
for(final Instantiation instantiation_3 : _instantiations_3) {
{
EList<ComponentInstance> _componentInstances_2 = instantiation_3.getComponentInstances();
for(final ComponentInstance instance_2 : _componentInstances_2) {
{
ComponentDefinitionType _type_6 = RdlUtil.getComponentDefinition(instantiation_3).getType();
boolean _equals_9 = Objects.equal(_type_6, ComponentDefinitionType.REGFILE);
if (_equals_9) {
_builder.append("// , NAMED(");
String _name_12 = instance_2.getName();
_builder.append(_name_12);
_builder.append(", i_");
String _name_13 = instance_2.getName();
_builder.append(_name_13);
_builder.append(", 0, *this)");
_builder.newLineIfNotEmpty();
} else {
ComponentDefinitionType _type_7 = RdlUtil.getComponentDefinition(instantiation_3).getType();
boolean _equals_10 = Objects.equal(_type_7, ComponentDefinitionType.REG);
if (_equals_10) {
_builder.append(", NAMED(");
String _name_14 = instance_2.getName();
_builder.append(_name_14);
_builder.append(", r_");
String _name_15 = instance_2.getName();
_builder.append(_name_15);
_builder.append(", 0, *this)");
_builder.newLineIfNotEmpty();
}
}
}
}
}
}
}
_builder.append("{");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("template<unsigned BUSWIDTH>");
_builder.newLine();
_builder.append("inline void ");
_builder.append(namespace);
_builder.append("::gen::");
String _effectiveName_13 = RdlUtil.effectiveName(this.componentDefinition);
_builder.append(_effectiveName_13);
_builder.append("_regs::registerResources(scc::tlm_target<BUSWIDTH>& target, uint64_t offset) {");
_builder.newLineIfNotEmpty();
{
EList<Instantiation> _instantiations_4 = this.componentDefinition.getInstantiations();
for(final Instantiation instantiation_4 : _instantiations_4) {
{
EList<ComponentInstance> _componentInstances_3 = instantiation_4.getComponentInstances();
for(final ComponentInstance instance_3 : _componentInstances_3) {
{
ComponentDefinitionType _type_8 = RdlUtil.getComponentDefinition(instantiation_4).getType();
boolean _equals_11 = Objects.equal(_type_8, ComponentDefinitionType.REGFILE);
if (_equals_11) {
_builder.append(" ");
_builder.append("i_");
String _name_16 = instance_3.getName();
_builder.append(_name_16, " ");
_builder.append(".registerResources(target, ");
IntegerWithRadix _addressValue = RdlUtil.addressValue(instance_3);
_builder.append(_addressValue, " ");
_builder.append("UL+offset);");
_builder.newLineIfNotEmpty();
} else {
ComponentDefinitionType _type_9 = RdlUtil.getComponentDefinition(instantiation_4).getType();
boolean _equals_12 = Objects.equal(_type_9, ComponentDefinitionType.REG);
if (_equals_12) {
_builder.append(" ");
_builder.append("target.addResource(");
String _name_17 = instance_3.getName();
_builder.append(_name_17, " ");
_builder.append(", ");
IntegerWithRadix _addressValue_1 = RdlUtil.addressValue(instance_3);
_builder.append(_addressValue_1, " ");
_builder.append("UL);");
_builder.newLineIfNotEmpty();
}
}
}
}
}
}
}
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("#endif // _");
String _upperCase_4 = namespace.toUpperCase();
_builder.append(_upperCase_4);
_builder.append("_GEN_");
String _upperCase_5 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
_builder.append(_upperCase_5);
_builder.append("_H_");
_builder.newLineIfNotEmpty();
return _builder.toString();
}
@Override
public String generateSource(final String namespace) {
return "";
}
public String genFieldDeclarations(final ComponentDefinition componentDef) {
String _xblockexpression = null;
{
long i = 0L;
String res = "";
EList<Instantiation> _instantiations = componentDef.getInstantiations();
for (final Instantiation inst : _instantiations) {
EList<ComponentInstance> _componentInstances = inst.getComponentInstances();
for (final ComponentInstance compInst : _componentInstances) {
Object _size = compInst.getRange().getSize();
boolean _tripleNotEquals = (_size != null);
if (_tripleNotEquals) {
String _res = res;
StringConcatenation _builder = new StringConcatenation();
_builder.append("BF_FIELD(");
String _name = compInst.getName();
_builder.append(_name);
_builder.append(", ");
_builder.append(i);
_builder.append(", ");
Object _size_1 = compInst.getRange().getSize();
_builder.append(((IntegerWithRadix) _size_1).value);
_builder.append(");");
_builder.newLineIfNotEmpty();
res = (_res + _builder);
long _i = i;
Object _size_2 = compInst.getRange().getSize();
i = (_i + ((IntegerWithRadix) _size_2).value);
} else {
Object _left = compInst.getRange().getLeft();
final long start = ((IntegerWithRadix) _left).value;
Object _right = compInst.getRange().getRight();
final long end = ((IntegerWithRadix) _right).value;
String _res_1 = res;
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("BF_FIELD(");
String _name_1 = compInst.getName();
_builder_1.append(_name_1);
_builder_1.append(", ");
_builder_1.append(end);
_builder_1.append(", ");
_builder_1.append(((start - end) + 1));
_builder_1.append(");");
_builder_1.newLineIfNotEmpty();
res = (_res_1 + _builder_1);
long _max = Math.max(start, end);
long _plus = (_max + 1);
i = _plus;
}
}
}
_xblockexpression = res;
}
return _xblockexpression;
}
}

View File

@ -1 +0,0 @@
/RDLSyntaxErrorMessageProvider.java

View File

@ -1,67 +0,0 @@
package com.minres.rdl.messages;
import com.google.inject.Inject;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.GrammarUtil;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.nodemodel.SyntaxErrorMessage;
import org.eclipse.xtext.parser.antlr.ISyntaxErrorMessageProvider;
import org.eclipse.xtext.parser.antlr.SyntaxErrorMessageProvider;
import org.eclipse.xtext.xbase.lib.InputOutput;
@SuppressWarnings("all")
public class RDLSyntaxErrorMessageProvider extends SyntaxErrorMessageProvider {
public static final String USED_RESERVED_KEYWORD = "USED_RESERVED_KEYWORD";
@Inject
private IGrammarAccess grammarAccess;
/**
* Customized error message for reserved keywords
*/
@Override
public SyntaxErrorMessage getSyntaxErrorMessage(final ISyntaxErrorMessageProvider.IParserErrorContext context) {
SyntaxErrorMessage _xblockexpression = null;
{
InputOutput.println();
RecognitionException _recognitionException = null;
if (context!=null) {
_recognitionException=context.getRecognitionException();
}
if (_recognitionException!=null) {
_recognitionException.getClass();
}
RecognitionException _recognitionException_1 = null;
if (context!=null) {
_recognitionException_1=context.getRecognitionException();
}
Token _ken = null;
if (_recognitionException_1!=null) {
_ken=_recognitionException_1.token;
}
String _text = null;
if (_ken!=null) {
_text=_ken.getText();
}
final String unexpectedText = _text;
boolean _contains = GrammarUtil.getAllKeywords(this.grammarAccess.getGrammar()).contains(unexpectedText);
if (_contains) {
InputOutput.<String>println(context.getDefaultMessage());
StringConcatenation _builder = new StringConcatenation();
_builder.append("\"");
_builder.append(unexpectedText);
_builder.append("\" is a reserved keyword which is not allowed as Identifier.");
_builder.newLineIfNotEmpty();
_builder.append("Please choose another word or alternatively confuse your co-workers by escaping it with the caret (^) character like this: \"^");
_builder.append(unexpectedText);
_builder.append("\".");
return new SyntaxErrorMessage(_builder.toString(),
RDLSyntaxErrorMessageProvider.USED_RESERVED_KEYWORD);
}
_xblockexpression = super.getSyntaxErrorMessage(context);
}
return _xblockexpression;
}
}

View File

@ -1 +0,0 @@
/RDLScopeProvider.java

View File

@ -1,58 +0,0 @@
/**
* generated by Xtext 2.12.0
*/
package com.minres.rdl.scoping;
import com.google.common.collect.Iterables;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.Include;
import com.minres.rdl.rdl.Root;
import java.util.Arrays;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.scoping.Scopes;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
/**
* This class contains custom scoping description.
*
* see : http://www.eclipse.org/Xtext/documentation.html#scoping
* on how and when to use it
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping
* on how and when to use it.
*/
@SuppressWarnings("all")
public class RDLScopeProvider extends AbstractRDLScopeProvider {
protected IScope _getScopeWithComponentDefinition(final ComponentDefinition componentDef) {
return Scopes.scopeFor(componentDef.getComponentDefinitions(), this.getScopeWithComponentDefinition(componentDef.eContainer()));
}
protected IScope _getScopeWithComponentDefinition(final Root root) {
EList<ComponentDefinition> compDefs = root.getComponentDefinitions();
EList<Include> _includes = root.getIncludes();
for (final Include incl : _includes) {
{
Resource resource = EcoreUtil2.getResource(root.eResource(), incl.getImportURI());
EObject _head = IterableExtensions.<EObject>head(resource.getContents());
final Root r = ((Root) _head);
EList<ComponentDefinition> _componentDefinitions = r.getComponentDefinitions();
Iterables.<ComponentDefinition>addAll(compDefs, _componentDefinitions);
}
}
return Scopes.scopeFor(compDefs);
}
public IScope getScopeWithComponentDefinition(final EObject componentDef) {
if (componentDef instanceof ComponentDefinition) {
return _getScopeWithComponentDefinition((ComponentDefinition)componentDef);
} else if (componentDef instanceof Root) {
return _getScopeWithComponentDefinition((Root)componentDef);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(componentDef).toString());
}
}
}

View File

@ -1 +0,0 @@
/RDLValidator.java

View File

@ -1,13 +0,0 @@
/**
* generated by Xtext 2.14.0
*/
package com.minres.rdl.validation;
/**
* This class contains custom validation rules.
*
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
*/
@SuppressWarnings("all")
public class RDLValidator extends AbstractRDLValidator {
}