mirror of
https://github.com/Minres/RDL-Editor.git
synced 2025-07-01 13:33:27 +02:00
Fixed code generation to use sc_register_indexed for register arrays
This commit is contained in:
@ -1,8 +1,17 @@
|
||||
package com.minres.rdl.generator;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.minres.rdl.IntegerWithRadix;
|
||||
import com.minres.rdl.generator.RdlBaseGenerator;
|
||||
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;
|
||||
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 AddrmapGenerator extends RdlBaseGenerator {
|
||||
@ -21,17 +30,34 @@ public class AddrmapGenerator extends RdlBaseGenerator {
|
||||
_builder.newLine();
|
||||
_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>, 3> e300_plat_map = {{");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("{&i_gpio, 0x10012000, 0x1000},");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("{&i_uart, 0x10013000, 0x1000},");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("{&i_spi, 0x10014000, 0x1000}");
|
||||
_builder.newLine();
|
||||
_builder.append("const std::array<sysc::target_memory_map_entry<32>, ");
|
||||
int _instanceCount = this.instanceCount(this.componentDefinition, ComponentDefinitionType.REGFILE);
|
||||
_builder.append(_instanceCount);
|
||||
_builder.append("> e300_plat_map = {{");
|
||||
_builder.newLineIfNotEmpty();
|
||||
{
|
||||
Iterable<Instantiation> _instantiationsOfType = this.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(", 0x");
|
||||
Object _address = instance.getAddress();
|
||||
String _hexString = Long.toHexString(((IntegerWithRadix) _address).value);
|
||||
_builder.append(_hexString, " ");
|
||||
_builder.append(", 0x");
|
||||
String _hexString_1 = Long.toHexString(this.occupiedSize(instantiation));
|
||||
_builder.append(_hexString_1, " ");
|
||||
_builder.append("},");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_builder.append("}};");
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
@ -44,4 +70,26 @@ public class AddrmapGenerator extends RdlBaseGenerator {
|
||||
public String generateSource() {
|
||||
return "";
|
||||
}
|
||||
|
||||
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 occupiedSize(final Instantiation instantiation) {
|
||||
return 4096;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,7 @@ import com.minres.rdl.RDLStandaloneSetup;
|
||||
import com.minres.rdl.generator.Options;
|
||||
import java.lang.reflect.MalformedParametersException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
@ -18,6 +16,7 @@ import org.eclipse.emf.mwe.utils.ProjectMapping;
|
||||
import org.eclipse.emf.mwe.utils.StandaloneSetup;
|
||||
import org.eclipse.xtext.generator.GeneratorContext;
|
||||
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;
|
||||
@ -26,17 +25,15 @@ 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.CollectionLiterals;
|
||||
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.Pair;
|
||||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class Main {
|
||||
private final String USAGE_STR = "RDL2code [-h] [-v] [-I <RDL include dir] [-i <include output dir>] [-s <source output dir>] [-g <generated files output dir>] <input file> <input file>";
|
||||
private final String USAGE_STR = "RDL2code [-h] [-v] [-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();
|
||||
@ -94,9 +91,7 @@ public class Main {
|
||||
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("i", Options.Separator.BLANK, Options.Multiplicity.ZERO_OR_ONE);
|
||||
opt.getSet().addOption("s", Options.Separator.BLANK, Options.Multiplicity.ZERO_OR_ONE);
|
||||
opt.getSet().addOption("g", 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);
|
||||
@ -126,31 +121,21 @@ public class Main {
|
||||
new StandaloneSetup().addProjectMapping(projectMapping);
|
||||
}
|
||||
this.fileAccess.setOutputPath("src-gen/");
|
||||
Pair<String, Boolean> _mappedTo = Pair.<String, Boolean>of("incl-out", Boolean.valueOf(false));
|
||||
Pair<String, Boolean> _mappedTo_1 = Pair.<String, Boolean>of("src-out", Boolean.valueOf(false));
|
||||
Pair<String, Boolean> _mappedTo_2 = Pair.<String, Boolean>of("gen-out", Boolean.valueOf(true));
|
||||
final BiConsumer<String, Boolean> _function = (String p1, Boolean p2) -> {
|
||||
boolean _isSet_3 = opt.getSet().isSet(p1.substring(0, 1));
|
||||
if (_isSet_3) {
|
||||
String _resultValue = opt.getSet().getOption(p1.substring(0, 1)).getResultValue(0);
|
||||
String _plus = (_resultValue + "/");
|
||||
this.fileAccess.setOutputPath(p1, _plus);
|
||||
} else {
|
||||
this.fileAccess.setOutputPath(p1, "src-gen/");
|
||||
}
|
||||
OutputConfiguration _get = this.fileAccess.getOutputConfigurations().get(p1);
|
||||
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((p2).booleanValue());
|
||||
_get.setOverrideExistingResources(true);
|
||||
}
|
||||
};
|
||||
Collections.<String, Boolean>unmodifiableMap(CollectionLiterals.<String, Boolean>newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2)).forEach(_function);
|
||||
final Consumer<String> _function_1 = (String string) -> {
|
||||
}
|
||||
final Consumer<String> _function = (String string) -> {
|
||||
try {
|
||||
if (verbose) {
|
||||
InputOutput.<String>println(("Reading " + string));
|
||||
InputOutput.<String>println(("Processing " + string));
|
||||
}
|
||||
ResourceSet _get = this.resourceSetProvider.get();
|
||||
final XtextResourceSet resourceSet = ((XtextResourceSet) _get);
|
||||
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);
|
||||
@ -160,38 +145,36 @@ public class Main {
|
||||
URI _uRI = resource.getURI();
|
||||
String _plus = ("Error validating " + _uRI);
|
||||
System.err.println(_plus);
|
||||
final Consumer<Issue> _function_2 = (Issue it) -> {
|
||||
final Consumer<Issue> _function_1 = (Issue it) -> {
|
||||
System.err.println(it);
|
||||
};
|
||||
issues.forEach(_function_2);
|
||||
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);
|
||||
}
|
||||
GeneratorContext _generatorContext = new GeneratorContext();
|
||||
final Procedure1<GeneratorContext> _function_3 = (GeneratorContext it) -> {
|
||||
final Procedure1<GeneratorContext> _function_2 = (GeneratorContext it) -> {
|
||||
it.setCancelIndicator(CancelIndicator.NullImpl);
|
||||
};
|
||||
final GeneratorContext context = ObjectExtensions.<GeneratorContext>operator_doubleArrow(_generatorContext, _function_3);
|
||||
final GeneratorContext context = ObjectExtensions.<GeneratorContext>operator_doubleArrow(_generatorContext, _function_2);
|
||||
this.generator.generate(resource, this.fileAccess, context);
|
||||
if (verbose) {
|
||||
InputOutput.<String>print((("Code generation for " + string) + " finished, "));
|
||||
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);
|
||||
String _plus_3 = (_plus_2 + ", ");
|
||||
InputOutput.<String>print(_plus_3);
|
||||
InputOutput.<String>println(_plus_2);
|
||||
}
|
||||
} catch (final Throwable _t) {
|
||||
if (_t instanceof Exception) {
|
||||
final Exception e = (Exception)_t;
|
||||
URI _uRI_3 = this.fileAccess.getURI("");
|
||||
String _plus_4 = ("includes are in " + _uRI_3);
|
||||
String _plus_5 = (_plus_4 + ", ");
|
||||
InputOutput.<String>print(_plus_5);
|
||||
String _plus_3 = ("includes are in " + _uRI_3);
|
||||
InputOutput.<String>println(_plus_3);
|
||||
} else {
|
||||
throw Exceptions.sneakyThrow(_t);
|
||||
}
|
||||
@ -199,17 +182,15 @@ public class Main {
|
||||
try {
|
||||
if (verbose) {
|
||||
URI _uRI_4 = this.fileAccess.getURI("", "src-out");
|
||||
String _plus_6 = ("sources are in " + _uRI_4);
|
||||
String _plus_7 = (_plus_6 + ", ");
|
||||
InputOutput.<String>println(_plus_7);
|
||||
String _plus_4 = ("sources are in " + _uRI_4);
|
||||
InputOutput.<String>println(_plus_4);
|
||||
}
|
||||
} catch (final Throwable _t_1) {
|
||||
if (_t_1 instanceof Exception) {
|
||||
final Exception e_1 = (Exception)_t_1;
|
||||
URI _uRI_5 = this.fileAccess.getURI("");
|
||||
String _plus_8 = ("sources are in " + _uRI_5);
|
||||
String _plus_9 = (_plus_8 + ", ");
|
||||
InputOutput.<String>println(_plus_9);
|
||||
String _plus_5 = ("sources are in " + _uRI_5);
|
||||
InputOutput.<String>println(_plus_5);
|
||||
} else {
|
||||
throw Exceptions.sneakyThrow(_t_1);
|
||||
}
|
||||
@ -218,6 +199,6 @@ public class Main {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
};
|
||||
opt.getSet().getData().forEach(_function_1);
|
||||
opt.getSet().getData().forEach(_function);
|
||||
}
|
||||
}
|
||||
|
@ -197,14 +197,39 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
long _size = this.getSize(instantiation);
|
||||
_builder.append(_size, " ");
|
||||
_builder.append("_t ");
|
||||
final Function1<ComponentInstance, String> _function_1 = (ComponentInstance it) -> {
|
||||
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(ListExtensions.<ComponentInstance, String>map(instantiation.getComponentInstances(), _function_1), ", ");
|
||||
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();
|
||||
{
|
||||
final Function1<ComponentInstance, Boolean> _function_3 = (ComponentInstance it) -> {
|
||||
Range _range = it.getRange();
|
||||
return Boolean.valueOf((_range != null));
|
||||
};
|
||||
Iterable<ComponentInstance> _filter = IterableExtensions.<ComponentInstance>filter(instantiation.getComponentInstances(), _function_3);
|
||||
for(final ComponentInstance componentInstance : _filter) {
|
||||
_builder.append(" ");
|
||||
_builder.append("std::array<uint");
|
||||
long _size_1 = this.getSize(instantiation);
|
||||
_builder.append(_size_1, " ");
|
||||
_builder.append("_t, ");
|
||||
long _absSize = this.absSize(componentInstance.getRange());
|
||||
_builder.append(_absSize, " ");
|
||||
_builder.append("> r_");
|
||||
String _name_2 = componentInstance.getName();
|
||||
_builder.append(_name_2, " ");
|
||||
_builder.append(";");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
@ -216,8 +241,8 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
String _effectiveName_2 = this.effectiveName(instantiation.getComponent());
|
||||
_builder.append(_effectiveName_2, " ");
|
||||
_builder.append("_t, uint");
|
||||
long _size_1 = this.getSize(instantiation);
|
||||
_builder.append(_size_1, " ");
|
||||
long _size_2 = this.getSize(instantiation);
|
||||
_builder.append(_size_2, " ");
|
||||
_builder.append("_t);");
|
||||
_builder.newLineIfNotEmpty();
|
||||
_builder.append(" ");
|
||||
@ -227,14 +252,39 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
_builder.newLineIfNotEmpty();
|
||||
_builder.append(" ");
|
||||
_builder.append("END_BF_DECL() ");
|
||||
final Function1<ComponentInstance, String> _function_2 = (ComponentInstance it) -> {
|
||||
String _name_2 = it.getName();
|
||||
return ("r_" + _name_2);
|
||||
final Function1<ComponentInstance, Boolean> _function_4 = (ComponentInstance it) -> {
|
||||
Range _range = it.getRange();
|
||||
return Boolean.valueOf((_range == null));
|
||||
};
|
||||
String _join_2 = IterableExtensions.join(ListExtensions.<ComponentInstance, String>map(instantiation.getComponentInstances(), _function_2), ", ");
|
||||
final Function1<ComponentInstance, String> _function_5 = (ComponentInstance it) -> {
|
||||
String _name_3 = it.getName();
|
||||
return ("r_" + _name_3);
|
||||
};
|
||||
String _join_2 = IterableExtensions.join(IterableExtensions.<ComponentInstance, String>map(IterableExtensions.<ComponentInstance>filter(instantiation.getComponentInstances(), _function_4), _function_5), ", ");
|
||||
_builder.append(_join_2, " ");
|
||||
_builder.append(";");
|
||||
_builder.newLineIfNotEmpty();
|
||||
{
|
||||
final Function1<ComponentInstance, Boolean> _function_6 = (ComponentInstance it) -> {
|
||||
Range _range = it.getRange();
|
||||
return Boolean.valueOf((_range != null));
|
||||
};
|
||||
Iterable<ComponentInstance> _filter_1 = IterableExtensions.<ComponentInstance>filter(instantiation.getComponentInstances(), _function_6);
|
||||
for(final ComponentInstance componentInstance_1 : _filter_1) {
|
||||
_builder.append(" ");
|
||||
_builder.append("std::array<");
|
||||
String _effectiveName_3 = this.effectiveName(instantiation.getComponent());
|
||||
_builder.append(_effectiveName_3, " ");
|
||||
_builder.append("_t, ");
|
||||
long _absSize_1 = this.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_builder.append(" ");
|
||||
@ -253,32 +303,79 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
EList<ComponentInstance> _componentInstances = instantiation_1.getComponentInstances();
|
||||
for(final ComponentInstance instance : _componentInstances) {
|
||||
{
|
||||
boolean _isFilledByField_2 = this.isFilledByField(instantiation_1);
|
||||
if (_isFilledByField_2) {
|
||||
_builder.append(" ");
|
||||
_builder.append("sysc::sc_register<uint");
|
||||
long _size_2 = this.getSize(instantiation_1);
|
||||
_builder.append(_size_2, " ");
|
||||
_builder.append("_t> ");
|
||||
String _name_2 = instance.getName();
|
||||
_builder.append(_name_2, " ");
|
||||
_builder.append(";");
|
||||
_builder.newLineIfNotEmpty();
|
||||
Range _range = instance.getRange();
|
||||
boolean _tripleEquals = (_range == null);
|
||||
if (_tripleEquals) {
|
||||
{
|
||||
boolean _isFilledByField_2 = this.isFilledByField(instantiation_1);
|
||||
if (_isFilledByField_2) {
|
||||
_builder.append(" ");
|
||||
_builder.append("sysc::sc_register<uint");
|
||||
long _size_3 = this.getSize(instantiation_1);
|
||||
_builder.append(_size_3, " ");
|
||||
_builder.append("_t> ");
|
||||
String _name_4 = instance.getName();
|
||||
_builder.append(_name_4, " ");
|
||||
_builder.append(";");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
{
|
||||
boolean _isFilledByField_3 = this.isFilledByField(instantiation_1);
|
||||
boolean _not_1 = (!_isFilledByField_3);
|
||||
if (_not_1) {
|
||||
_builder.append(" ");
|
||||
_builder.append("sysc::sc_register<");
|
||||
String _effectiveName_4 = this.effectiveName(instantiation_1.getComponent());
|
||||
_builder.append(_effectiveName_4, " ");
|
||||
_builder.append("_t> ");
|
||||
String _name_5 = instance.getName();
|
||||
_builder.append(_name_5, " ");
|
||||
_builder.append(";");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
boolean _isFilledByField_3 = this.isFilledByField(instantiation_1);
|
||||
boolean _not_1 = (!_isFilledByField_3);
|
||||
if (_not_1) {
|
||||
_builder.append(" ");
|
||||
_builder.append("sysc::sc_register<typename ");
|
||||
String _effectiveName_3 = this.effectiveName(instantiation_1.getComponent());
|
||||
_builder.append(_effectiveName_3, " ");
|
||||
_builder.append("_t::StorageType> ");
|
||||
String _name_3 = instance.getName();
|
||||
_builder.append(_name_3, " ");
|
||||
_builder.append(";");
|
||||
_builder.newLineIfNotEmpty();
|
||||
Range _range_1 = instance.getRange();
|
||||
boolean _tripleNotEquals = (_range_1 != null);
|
||||
if (_tripleNotEquals) {
|
||||
{
|
||||
boolean _isFilledByField_4 = this.isFilledByField(instantiation_1);
|
||||
if (_isFilledByField_4) {
|
||||
_builder.append(" ");
|
||||
_builder.append("sysc::sc_register_indexed<");
|
||||
long _size_4 = this.getSize(instantiation_1);
|
||||
_builder.append(_size_4, " ");
|
||||
_builder.append("_t, ");
|
||||
long _absSize_2 = this.absSize(instance.getRange());
|
||||
_builder.append(_absSize_2, " ");
|
||||
_builder.append("> ");
|
||||
String _name_6 = instance.getName();
|
||||
_builder.append(_name_6, " ");
|
||||
_builder.append(";");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
{
|
||||
boolean _isFilledByField_5 = this.isFilledByField(instantiation_1);
|
||||
boolean _not_2 = (!_isFilledByField_5);
|
||||
if (_not_2) {
|
||||
_builder.append(" ");
|
||||
_builder.append("sysc::sc_register_indexed<");
|
||||
String _effectiveName_5 = this.effectiveName(instantiation_1.getComponent());
|
||||
_builder.append(_effectiveName_5, " ");
|
||||
_builder.append("_t, ");
|
||||
long _absSize_3 = this.absSize(instance.getRange());
|
||||
_builder.append(_absSize_3, " ");
|
||||
_builder.append("> ");
|
||||
String _name_7 = instance.getName();
|
||||
_builder.append(_name_7, " ");
|
||||
_builder.append(";");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,8 +387,8 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
_builder.append("public:");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
String _name_4 = this.componentDefinition.getName();
|
||||
_builder.append(_name_4, " ");
|
||||
String _name_8 = this.componentDefinition.getName();
|
||||
_builder.append(_name_8, " ");
|
||||
_builder.append("(sc_core::sc_module_name nm);");
|
||||
_builder.newLineIfNotEmpty();
|
||||
_builder.newLine();
|
||||
@ -313,11 +410,11 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
_builder.newLine();
|
||||
_builder.newLine();
|
||||
_builder.append("inline sysc::");
|
||||
String _name_5 = this.componentDefinition.getName();
|
||||
_builder.append(_name_5);
|
||||
String _name_9 = this.componentDefinition.getName();
|
||||
_builder.append(_name_9);
|
||||
_builder.append("::");
|
||||
String _name_6 = this.componentDefinition.getName();
|
||||
_builder.append(_name_6);
|
||||
String _name_10 = this.componentDefinition.getName();
|
||||
_builder.append(_name_10);
|
||||
_builder.append("(sc_core::sc_module_name nm)");
|
||||
_builder.newLineIfNotEmpty();
|
||||
_builder.append(": sc_core::sc_module(nm)");
|
||||
@ -329,11 +426,11 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
EList<ComponentInstance> _componentInstances_1 = instantiation_2.getComponentInstances();
|
||||
for(final ComponentInstance instance_1 : _componentInstances_1) {
|
||||
_builder.append(", NAMED(");
|
||||
String _name_7 = instance_1.getName();
|
||||
_builder.append(_name_7);
|
||||
String _name_11 = instance_1.getName();
|
||||
_builder.append(_name_11);
|
||||
_builder.append(", r_");
|
||||
String _name_8 = instance_1.getName();
|
||||
_builder.append(_name_8);
|
||||
String _name_12 = instance_1.getName();
|
||||
_builder.append(_name_12);
|
||||
_builder.append(", 0, *this)");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
@ -348,8 +445,8 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
_builder.append("template<unsigned BUSWIDTH>");
|
||||
_builder.newLine();
|
||||
_builder.append("inline void sysc::");
|
||||
String _name_9 = this.componentDefinition.getName();
|
||||
_builder.append(_name_9);
|
||||
String _name_13 = this.componentDefinition.getName();
|
||||
_builder.append(_name_13);
|
||||
_builder.append("::registerResources(sysc::tlm_target<BUSWIDTH>& target) {");
|
||||
_builder.newLineIfNotEmpty();
|
||||
{
|
||||
@ -360,18 +457,12 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
for(final ComponentInstance instance_2 : _componentInstances_2) {
|
||||
_builder.append(" ");
|
||||
_builder.append("target.addResource(");
|
||||
String _name_10 = instance_2.getName();
|
||||
_builder.append(_name_10, " ");
|
||||
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("UL, 0x");
|
||||
long _size_3 = this.getSize(instantiation_3);
|
||||
long _plus = (_size_3 + 7);
|
||||
long _divide = (_plus / 8);
|
||||
String _hexString_1 = Long.toHexString(_divide);
|
||||
_builder.append(_hexString_1, " ");
|
||||
_builder.append("UL);");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
@ -389,6 +480,20 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
||||
return _builder.toString();
|
||||
}
|
||||
|
||||
public 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 boolean isFilledByField(final Instantiation instantiation) {
|
||||
final int fieldCount = this.instanceCountOfType(instantiation.getComponent(), ComponentDefinitionType.FIELD);
|
||||
if ((fieldCount == 1)) {
|
||||
|
Reference in New Issue
Block a user