mirror of
				https://github.com/Minres/RDL-Editor.git
				synced 2025-11-04 04:31:37 +00:00 
			
		
		
		
	Fixed NPE in generator
This commit is contained in:
		@@ -0,0 +1,263 @@
 | 
			
		||||
package com.minres.rdl;
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Objects;
 | 
			
		||||
import com.minres.rdl.IntegerWithRadix;
 | 
			
		||||
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 org.eclipse.emf.common.util.EList;
 | 
			
		||||
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;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package com.minres.rdl.generator;
 | 
			
		||||
 | 
			
		||||
import com.minres.rdl.IntegerWithRadix;
 | 
			
		||||
import com.minres.rdl.RdlUtil;
 | 
			
		||||
import com.minres.rdl.generator.RdlBaseGenerator;
 | 
			
		||||
import com.minres.rdl.rdl.ComponentDefinition;
 | 
			
		||||
import com.minres.rdl.rdl.ComponentDefinitionType;
 | 
			
		||||
@@ -20,19 +21,28 @@ public class AddrmapGenerator extends RdlBaseGenerator {
 | 
			
		||||
  @Override
 | 
			
		||||
  public String generateHeader() {
 | 
			
		||||
    StringConcatenation _builder = new StringConcatenation();
 | 
			
		||||
    _builder.append("#ifndef _E300_PLAT_MAP_H_");
 | 
			
		||||
    _builder.newLine();
 | 
			
		||||
    _builder.append("#define _E300_PLAT_MAP_H_");
 | 
			
		||||
    _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.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<sysc::target_memory_map_entry<32>, ");
 | 
			
		||||
    int _instanceCount = this.instanceCount(this.componentDefinition, ComponentDefinitionType.REGFILE);
 | 
			
		||||
    int _instanceCount = RdlUtil.instanceCount(this.componentDefinition, ComponentDefinitionType.REGFILE);
 | 
			
		||||
    _builder.append(_instanceCount);
 | 
			
		||||
    _builder.append("> e300_plat_map = {{");
 | 
			
		||||
    _builder.append("> ");
 | 
			
		||||
    String _effectiveName = RdlUtil.effectiveName(this.componentDefinition);
 | 
			
		||||
    _builder.append(_effectiveName);
 | 
			
		||||
    _builder.append("_map = {{");
 | 
			
		||||
    _builder.newLineIfNotEmpty();
 | 
			
		||||
    {
 | 
			
		||||
      Iterable<Instantiation> _instantiationsOfType = this.instantiationsOfType(this.componentDefinition, ComponentDefinitionType.REGFILE);
 | 
			
		||||
      Iterable<Instantiation> _instantiationsOfType = RdlUtil.instantiationsOfType(this.componentDefinition, ComponentDefinitionType.REGFILE);
 | 
			
		||||
      for(final Instantiation instantiation : _instantiationsOfType) {
 | 
			
		||||
        {
 | 
			
		||||
          EList<ComponentInstance> _componentInstances = instantiation.getComponentInstances();
 | 
			
		||||
@@ -41,13 +51,12 @@ public class AddrmapGenerator extends RdlBaseGenerator {
 | 
			
		||||
            _builder.append("{&i_");
 | 
			
		||||
            String _name = instance.getName();
 | 
			
		||||
            _builder.append(_name, "    ");
 | 
			
		||||
            _builder.append(", ");
 | 
			
		||||
            IntegerWithRadix _addressValue = RdlUtil.addressValue(instance);
 | 
			
		||||
            _builder.append(_addressValue, "    ");
 | 
			
		||||
            _builder.append(", 0x");
 | 
			
		||||
            Object _address = instance.getAddress();
 | 
			
		||||
            String _hexString = Long.toHexString(((IntegerWithRadix) _address).value);
 | 
			
		||||
            String _hexString = Long.toHexString(RdlUtil.byteSize(instantiation));
 | 
			
		||||
            _builder.append(_hexString, "    ");
 | 
			
		||||
            _builder.append(", 0x");
 | 
			
		||||
            String _hexString_1 = Long.toHexString(this.byteSize(instantiation));
 | 
			
		||||
            _builder.append(_hexString_1, "    ");
 | 
			
		||||
            _builder.append("},");
 | 
			
		||||
            _builder.newLineIfNotEmpty();
 | 
			
		||||
          }
 | 
			
		||||
@@ -57,8 +66,11 @@ public class AddrmapGenerator extends RdlBaseGenerator {
 | 
			
		||||
    _builder.append("}};");
 | 
			
		||||
    _builder.newLine();
 | 
			
		||||
    _builder.newLine();
 | 
			
		||||
    _builder.append("#endif /* _E300_PLAT_MAP_H_ */");
 | 
			
		||||
    _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();
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@
 | 
			
		||||
 */
 | 
			
		||||
package com.minres.rdl.generator;
 | 
			
		||||
 | 
			
		||||
import com.minres.rdl.RdlUtil;
 | 
			
		||||
import com.minres.rdl.generator.AddrmapGenerator;
 | 
			
		||||
import com.minres.rdl.generator.RdlBaseGenerator;
 | 
			
		||||
import com.minres.rdl.generator.RegfileGenerator;
 | 
			
		||||
@@ -38,14 +39,14 @@ public class RDLGenerator extends AbstractGenerator {
 | 
			
		||||
      if ((gen != null)) {
 | 
			
		||||
        final String header = gen.generateHeader();
 | 
			
		||||
        if (((header != null) && (header.length() > 0))) {
 | 
			
		||||
          String _name = it.getName();
 | 
			
		||||
          String _plus = (_name + ".h");
 | 
			
		||||
          String _effectiveName = RdlUtil.effectiveName(it);
 | 
			
		||||
          String _plus = (_effectiveName + ".h");
 | 
			
		||||
          fsa.generateFile(_plus, this.outputConfig(fsa, "incl-out"), header);
 | 
			
		||||
        }
 | 
			
		||||
        final String source = gen.generateSource();
 | 
			
		||||
        if (((source != null) && (source.length() > 0))) {
 | 
			
		||||
          String _name_1 = it.getName();
 | 
			
		||||
          String _plus_1 = (_name_1 + ".cpp");
 | 
			
		||||
          String _effectiveName_1 = RdlUtil.effectiveName(it);
 | 
			
		||||
          String _plus_1 = (_effectiveName_1 + ".cpp");
 | 
			
		||||
          fsa.generateFile(_plus_1, this.outputConfig(fsa, "src-out"), source);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,256 +1,7 @@
 | 
			
		||||
package com.minres.rdl.generator;
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Objects;
 | 
			
		||||
import com.minres.rdl.IntegerWithRadix;
 | 
			
		||||
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 org.eclipse.emf.common.util.EList;
 | 
			
		||||
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 abstract class RdlBaseGenerator {
 | 
			
		||||
  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 = this.effectiveValue(((ExplicitPropertyAssignment) pa).getRhs());
 | 
			
		||||
      final IntegerWithRadix sz = new IntegerWithRadix(_effectiveValue);
 | 
			
		||||
      size = sz.value;
 | 
			
		||||
    }
 | 
			
		||||
    return size;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  public 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 = this.effectiveValue(((ExplicitPropertyAssignment) pa).getRhs());
 | 
			
		||||
      final IntegerWithRadix sz = new IntegerWithRadix(_effectiveValue);
 | 
			
		||||
      size = sz.value;
 | 
			
		||||
    }
 | 
			
		||||
    return size;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  public long getSize(final Instantiation instantiation) {
 | 
			
		||||
    final ComponentDefinition componentDef = this.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 = this.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 = this.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 String effectiveName(final ComponentDefinition definition) {
 | 
			
		||||
    String _xifexpression = null;
 | 
			
		||||
    String _name = definition.getName();
 | 
			
		||||
    boolean _tripleNotEquals = (_name != null);
 | 
			
		||||
    if (_tripleNotEquals) {
 | 
			
		||||
      _xifexpression = definition.getName();
 | 
			
		||||
    } else {
 | 
			
		||||
      String _xblockexpression = null;
 | 
			
		||||
      {
 | 
			
		||||
        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);
 | 
			
		||||
        _xblockexpression = this.effectiveValue(((ExplicitPropertyAssignment) pa).getRhs());
 | 
			
		||||
      }
 | 
			
		||||
      _xifexpression = _xblockexpression;
 | 
			
		||||
    }
 | 
			
		||||
    return _xifexpression;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  public String effectiveValue(final PropertyAssignmentRhs rhs) {
 | 
			
		||||
    String _xifexpression = null;
 | 
			
		||||
    RValue _value = rhs.getValue();
 | 
			
		||||
    boolean _tripleNotEquals = (_value != null);
 | 
			
		||||
    if (_tripleNotEquals) {
 | 
			
		||||
      _xifexpression = this.effectiveValue(rhs.getValue());
 | 
			
		||||
    } else {
 | 
			
		||||
      String _xifexpression_1 = null;
 | 
			
		||||
      InstancePropertyRef _instPropRef = rhs.getInstPropRef();
 | 
			
		||||
      boolean _tripleNotEquals_1 = (_instPropRef != null);
 | 
			
		||||
      if (_tripleNotEquals_1) {
 | 
			
		||||
        _xifexpression_1 = this.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 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 String effectiveValue(final InstancePropertyRef ref) {
 | 
			
		||||
    throw new RuntimeException();
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  public 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 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(this.instantiationsOfType(definition, type), _function), _function_1);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  public Iterable<Instantiation> instantiationsOfType(final ComponentDefinition definition, final ComponentDefinitionType type) {
 | 
			
		||||
    final Function1<Instantiation, Boolean> _function = (Instantiation it) -> {
 | 
			
		||||
      ComponentDefinitionType _type = this.definingComponent(it).getType();
 | 
			
		||||
      return Boolean.valueOf(Objects.equal(_type, type));
 | 
			
		||||
    };
 | 
			
		||||
    return IterableExtensions.<Instantiation>filter(definition.getInstantiations(), _function);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  public long byteSize(final Instantiation instantiation, final long start) {
 | 
			
		||||
    final ComponentDefinition componentDefinition = this.definingComponent(instantiation);
 | 
			
		||||
    long componentSize = 0;
 | 
			
		||||
    ComponentDefinitionType _type = this.definingComponent(instantiation).getType();
 | 
			
		||||
    boolean _equals = Objects.equal(_type, ComponentDefinitionType.REG);
 | 
			
		||||
    if (_equals) {
 | 
			
		||||
      long _regWidth = this.regWidth(this.definingComponent(instantiation));
 | 
			
		||||
      long _divide = (_regWidth / 8);
 | 
			
		||||
      componentSize = _divide;
 | 
			
		||||
    } else {
 | 
			
		||||
      EList<Instantiation> _instantiations = componentDefinition.getInstantiations();
 | 
			
		||||
      for (final Instantiation subInstantiation : _instantiations) {
 | 
			
		||||
        componentSize = this.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 long byteSize(final Instantiation instantiation) {
 | 
			
		||||
    final ComponentDefinition componentDefinition = this.definingComponent(instantiation);
 | 
			
		||||
    long componentSize = 0;
 | 
			
		||||
    ComponentDefinitionType _type = this.definingComponent(instantiation).getType();
 | 
			
		||||
    boolean _equals = Objects.equal(_type, ComponentDefinitionType.REG);
 | 
			
		||||
    if (_equals) {
 | 
			
		||||
      long _regWidth = this.regWidth(this.definingComponent(instantiation));
 | 
			
		||||
      long _divide = (_regWidth / 8);
 | 
			
		||||
      componentSize = _divide;
 | 
			
		||||
    } else {
 | 
			
		||||
      EList<Instantiation> _instantiations = componentDefinition.getInstantiations();
 | 
			
		||||
      for (final Instantiation subInstantiation : _instantiations) {
 | 
			
		||||
        componentSize = this.byteSize(subInstantiation, componentSize);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return componentSize;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  public abstract String generateHeader();
 | 
			
		||||
  
 | 
			
		||||
  public abstract String generateSource();
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ 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.generator.RdlBaseGenerator;
 | 
			
		||||
import com.minres.rdl.rdl.ComponentDefinition;
 | 
			
		||||
import com.minres.rdl.rdl.ComponentDefinitionType;
 | 
			
		||||
@@ -152,7 +153,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
          if (_equals) {
 | 
			
		||||
            _builder.append("    ");
 | 
			
		||||
            _builder.append("BEGIN_BF_DECL(");
 | 
			
		||||
            String _effectiveName = this.effectiveName(cdef);
 | 
			
		||||
            String _effectiveName = RdlUtil.effectiveName(cdef);
 | 
			
		||||
            _builder.append(_effectiveName, "    ");
 | 
			
		||||
            _builder.append("+\'_t\'», uint");
 | 
			
		||||
            _builder.append(cdef, "    ");
 | 
			
		||||
@@ -175,7 +176,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
        {
 | 
			
		||||
          if (((instantiation.getComponentRef() != null) && Objects.equal(instantiation.getComponentRef().getType(), ComponentDefinitionType.REG))) {
 | 
			
		||||
            _builder.append("    ");
 | 
			
		||||
            String _effectiveName_1 = this.effectiveName(instantiation.getComponentRef());
 | 
			
		||||
            String _effectiveName_1 = RdlUtil.effectiveName(instantiation.getComponentRef());
 | 
			
		||||
            _builder.append(_effectiveName_1, "    ");
 | 
			
		||||
            _builder.append("+\'_t\' ");
 | 
			
		||||
            final Function1<ComponentInstance, String> _function = (ComponentInstance it) -> {
 | 
			
		||||
@@ -202,7 +203,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
                  if (_greaterThan) {
 | 
			
		||||
                    _builder.append("    ");
 | 
			
		||||
                    _builder.append("uint");
 | 
			
		||||
                    long _size_1 = this.getSize(instantiation);
 | 
			
		||||
                    long _size_1 = RdlUtil.getSize(instantiation);
 | 
			
		||||
                    _builder.append(_size_1, "    ");
 | 
			
		||||
                    _builder.append("_t ");
 | 
			
		||||
                    final Function1<ComponentInstance, Boolean> _function_2 = (ComponentInstance it) -> {
 | 
			
		||||
@@ -228,7 +229,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
                  for(final ComponentInstance componentInstance : _filter) {
 | 
			
		||||
                    _builder.append("    ");
 | 
			
		||||
                    _builder.append("std::array<uint");
 | 
			
		||||
                    long _size_2 = this.getSize(instantiation);
 | 
			
		||||
                    long _size_2 = RdlUtil.getSize(instantiation);
 | 
			
		||||
                    _builder.append(_size_2, "    ");
 | 
			
		||||
                    _builder.append("_t, ");
 | 
			
		||||
                    long _absSize = this.absSize(componentInstance.getRange());
 | 
			
		||||
@@ -248,16 +249,16 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
              if (_not) {
 | 
			
		||||
                _builder.append("    ");
 | 
			
		||||
                _builder.append("BEGIN_BF_DECL(");
 | 
			
		||||
                String _effectiveName_2 = this.effectiveName(instantiation.getComponent());
 | 
			
		||||
                String _effectiveName_2 = RdlUtil.effectiveName(instantiation.getComponent());
 | 
			
		||||
                _builder.append(_effectiveName_2, "    ");
 | 
			
		||||
                _builder.append("_t, uint");
 | 
			
		||||
                long _size_3 = this.getSize(instantiation);
 | 
			
		||||
                long _size_3 = RdlUtil.getSize(instantiation);
 | 
			
		||||
                _builder.append(_size_3, "    ");
 | 
			
		||||
                _builder.append("_t);");
 | 
			
		||||
                _builder.newLineIfNotEmpty();
 | 
			
		||||
                _builder.append("    ");
 | 
			
		||||
                _builder.append("    ");
 | 
			
		||||
                String _genFieldDeclarations_1 = this.genFieldDeclarations(this.definingComponent(instantiation));
 | 
			
		||||
                String _genFieldDeclarations_1 = this.genFieldDeclarations(RdlUtil.definingComponent(instantiation));
 | 
			
		||||
                _builder.append(_genFieldDeclarations_1, "        ");
 | 
			
		||||
                _builder.newLineIfNotEmpty();
 | 
			
		||||
                _builder.append("    ");
 | 
			
		||||
@@ -283,7 +284,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
                  for(final ComponentInstance componentInstance_1 : _filter_1) {
 | 
			
		||||
                    _builder.append("    ");
 | 
			
		||||
                    _builder.append("std::array<");
 | 
			
		||||
                    String _effectiveName_3 = this.effectiveName(instantiation.getComponent());
 | 
			
		||||
                    String _effectiveName_3 = RdlUtil.effectiveName(instantiation.getComponent());
 | 
			
		||||
                    _builder.append(_effectiveName_3, "    ");
 | 
			
		||||
                    _builder.append("_t, ");
 | 
			
		||||
                    long _absSize_1 = this.absSize(componentInstance_1.getRange());
 | 
			
		||||
@@ -321,7 +322,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
                  if (_isFilledByField_2) {
 | 
			
		||||
                    _builder.append("    ");
 | 
			
		||||
                    _builder.append("sysc::sc_register<uint");
 | 
			
		||||
                    long _size_4 = this.getSize(instantiation_1);
 | 
			
		||||
                    long _size_4 = RdlUtil.getSize(instantiation_1);
 | 
			
		||||
                    _builder.append(_size_4, "    ");
 | 
			
		||||
                    _builder.append("_t> ");
 | 
			
		||||
                    String _name_4 = instance.getName();
 | 
			
		||||
@@ -336,7 +337,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
                  if (_not_1) {
 | 
			
		||||
                    _builder.append("    ");
 | 
			
		||||
                    _builder.append("sysc::sc_register<");
 | 
			
		||||
                    String _effectiveName_4 = this.effectiveName(instantiation_1.getComponent());
 | 
			
		||||
                    String _effectiveName_4 = RdlUtil.effectiveName(instantiation_1.getComponent());
 | 
			
		||||
                    _builder.append(_effectiveName_4, "    ");
 | 
			
		||||
                    _builder.append("_t> ");
 | 
			
		||||
                    String _name_5 = instance.getName();
 | 
			
		||||
@@ -356,7 +357,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
                  if (_isFilledByField_4) {
 | 
			
		||||
                    _builder.append("    ");
 | 
			
		||||
                    _builder.append("sysc::sc_register_indexed<uint");
 | 
			
		||||
                    long _size_5 = this.getSize(instantiation_1);
 | 
			
		||||
                    long _size_5 = RdlUtil.getSize(instantiation_1);
 | 
			
		||||
                    _builder.append(_size_5, "    ");
 | 
			
		||||
                    _builder.append("_t, ");
 | 
			
		||||
                    long _absSize_2 = this.absSize(instance.getRange());
 | 
			
		||||
@@ -374,7 +375,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
                  if (_not_2) {
 | 
			
		||||
                    _builder.append("    ");
 | 
			
		||||
                    _builder.append("sysc::sc_register_indexed<");
 | 
			
		||||
                    String _effectiveName_5 = this.effectiveName(instantiation_1.getComponent());
 | 
			
		||||
                    String _effectiveName_5 = RdlUtil.effectiveName(instantiation_1.getComponent());
 | 
			
		||||
                    _builder.append(_effectiveName_5, "    ");
 | 
			
		||||
                    _builder.append("_t, ");
 | 
			
		||||
                    long _absSize_3 = this.absSize(instance.getRange());
 | 
			
		||||
@@ -467,10 +468,9 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
            _builder.append("target.addResource(");
 | 
			
		||||
            String _name_14 = instance_2.getName();
 | 
			
		||||
            _builder.append(_name_14, "    ");
 | 
			
		||||
            _builder.append(", 0x");
 | 
			
		||||
            Object _address = instance_2.getAddress();
 | 
			
		||||
            String _hexString = Long.toHexString(((IntegerWithRadix) _address).value);
 | 
			
		||||
            _builder.append(_hexString, "    ");
 | 
			
		||||
            _builder.append(", ");
 | 
			
		||||
            IntegerWithRadix _addressValue = RdlUtil.addressValue(instance_2);
 | 
			
		||||
            _builder.append(_addressValue, "    ");
 | 
			
		||||
            _builder.append("UL);");
 | 
			
		||||
            _builder.newLineIfNotEmpty();
 | 
			
		||||
          }
 | 
			
		||||
@@ -505,12 +505,12 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
  public boolean isFilledByField(final Instantiation instantiation) {
 | 
			
		||||
    final int fieldCount = this.instanceCountOfType(instantiation.getComponent(), ComponentDefinitionType.FIELD);
 | 
			
		||||
    if ((fieldCount == 1)) {
 | 
			
		||||
      final long instSize = this.getSize(instantiation);
 | 
			
		||||
      final Instantiation field = ((Instantiation[])Conversions.unwrapArray(this.instantiationsOfType(instantiation.getComponent(), ComponentDefinitionType.FIELD), Instantiation.class))[0];
 | 
			
		||||
      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 = this.getSize(field);
 | 
			
		||||
        long _size = RdlUtil.getSize(field);
 | 
			
		||||
        return (instSize == _size);
 | 
			
		||||
      }
 | 
			
		||||
      Object _size_1 = range.getSize();
 | 
			
		||||
@@ -543,7 +543,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
 | 
			
		||||
    final Function2<Integer, Integer, Integer> _function_1 = (Integer p1, Integer p2) -> {
 | 
			
		||||
      return Integer.valueOf(((p1).intValue() + (p1).intValue()));
 | 
			
		||||
    };
 | 
			
		||||
    return (int) IterableExtensions.<Integer>reduce(IterableExtensions.<Instantiation, Integer>map(this.instantiationsOfType(definition, type), _function), _function_1);
 | 
			
		||||
    return (int) IterableExtensions.<Integer>reduce(IterableExtensions.<Instantiation, Integer>map(RdlUtil.instantiationsOfType(definition, type), _function), _function_1);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user