mirror of
https://github.com/Minres/RDL-Editor.git
synced 2024-12-22 07:28:02 +01:00
Fixed NPE in generator
This commit is contained in:
parent
aee194f777
commit
c2ff8f1f67
@ -0,0 +1,157 @@
|
|||||||
|
package com.minres.rdl
|
||||||
|
|
||||||
|
import com.minres.rdl.rdl.ComponentInstance
|
||||||
|
import com.minres.rdl.rdl.ComponentDefinition
|
||||||
|
import com.minres.rdl.rdl.ExplicitPropertyAssignment
|
||||||
|
import com.minres.rdl.rdl.PropertyAssignment
|
||||||
|
import com.minres.rdl.rdl.Instantiation
|
||||||
|
import com.minres.rdl.rdl.ComponentDefinitionType
|
||||||
|
import com.minres.rdl.rdl.PropertyEnum
|
||||||
|
import com.minres.rdl.rdl.PropertyAssignmentRhs
|
||||||
|
import com.minres.rdl.rdl.RValue
|
||||||
|
import com.minres.rdl.rdl.RValueConstant
|
||||||
|
import com.minres.rdl.rdl.InstancePropertyRef
|
||||||
|
|
||||||
|
class RdlUtil {
|
||||||
|
|
||||||
|
static def IntegerWithRadix addressValue(ComponentInstance instance) {
|
||||||
|
if (instance.address !== null)
|
||||||
|
return instance.address as IntegerWithRadix
|
||||||
|
else
|
||||||
|
return new IntegerWithRadix(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
def long accessWidth(ComponentDefinition definition){
|
||||||
|
var size = 32L
|
||||||
|
val pa = definition.propertyAssignments.findFirst[PropertyAssignment pa |
|
||||||
|
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.ACCESSWIDTH
|
||||||
|
]
|
||||||
|
if(pa !== null){
|
||||||
|
val sz = new IntegerWithRadix((pa as ExplicitPropertyAssignment).rhs.effectiveValue)
|
||||||
|
size=sz.value
|
||||||
|
}
|
||||||
|
return size
|
||||||
|
}
|
||||||
|
|
||||||
|
static def long regWidth(ComponentDefinition definition){
|
||||||
|
var size = 32L
|
||||||
|
val pa = definition.propertyAssignments.findFirst[PropertyAssignment pa |
|
||||||
|
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.REGWIDTH
|
||||||
|
]
|
||||||
|
if(pa !== null){
|
||||||
|
val sz = new IntegerWithRadix((pa as ExplicitPropertyAssignment).rhs.effectiveValue)
|
||||||
|
size=sz.value
|
||||||
|
}
|
||||||
|
return size
|
||||||
|
}
|
||||||
|
|
||||||
|
static def long getSize(Instantiation instantiation){
|
||||||
|
val componentDef= instantiation.definingComponent
|
||||||
|
switch (componentDef.type) {
|
||||||
|
case ComponentDefinitionType.REG: {
|
||||||
|
val pa = componentDef.propertyAssignments.findFirst[PropertyAssignment pa |
|
||||||
|
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.REGWIDTH
|
||||||
|
]
|
||||||
|
if(pa !== null){
|
||||||
|
val sz = new IntegerWithRadix((pa as ExplicitPropertyAssignment).rhs.effectiveValue)
|
||||||
|
return sz.value
|
||||||
|
}
|
||||||
|
return 32L
|
||||||
|
}
|
||||||
|
case ComponentDefinitionType.FIELD:{
|
||||||
|
val pa = componentDef.propertyAssignments.findFirst[PropertyAssignment pa |
|
||||||
|
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.FIELDWIDTH
|
||||||
|
]
|
||||||
|
if(pa !== null){
|
||||||
|
val sz = new IntegerWithRadix((pa as ExplicitPropertyAssignment).rhs.effectiveValue)
|
||||||
|
return sz.value
|
||||||
|
}
|
||||||
|
return 1L
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static def String effectiveName(ComponentDefinition definition){
|
||||||
|
if(definition.name!==null){
|
||||||
|
return definition.name.replaceAll('\\s+', '_')
|
||||||
|
} else{
|
||||||
|
val pa = definition.propertyAssignments.findFirst[PropertyAssignment pa |
|
||||||
|
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.NAME
|
||||||
|
]
|
||||||
|
if(pa !== null)
|
||||||
|
return (pa as ExplicitPropertyAssignment).rhs.effectiveValue.replaceAll('\\s+', '_')
|
||||||
|
else
|
||||||
|
return ('unnamed_'+definition.type).replaceAll('\\s+', '_')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static def String effectiveValue(PropertyAssignmentRhs rhs){
|
||||||
|
if(rhs.value!== null)
|
||||||
|
rhs.value.effectiveValue
|
||||||
|
else if(rhs.instPropRef!==null)
|
||||||
|
rhs.instPropRef.effectiveValue
|
||||||
|
else if(rhs.enumRef!==null)
|
||||||
|
rhs.enumRef.name
|
||||||
|
}
|
||||||
|
|
||||||
|
static def String effectiveValue(RValue rvalue){
|
||||||
|
if(rvalue.str!==null){
|
||||||
|
rvalue.str
|
||||||
|
} else if(rvalue.^val!=RValueConstant.UNDEFINED)
|
||||||
|
rvalue.^val.literal
|
||||||
|
else if(rvalue.num!==null){
|
||||||
|
val num = rvalue.num as IntegerWithRadix
|
||||||
|
num.toString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static def String effectiveValue(InstancePropertyRef ref){
|
||||||
|
throw new RuntimeException()
|
||||||
|
}
|
||||||
|
|
||||||
|
static def ComponentDefinition definingComponent(Instantiation instantiation){
|
||||||
|
if(instantiation.componentRef!==null) instantiation.componentRef else instantiation.component
|
||||||
|
}
|
||||||
|
|
||||||
|
static def int instanceCount(ComponentDefinition definition, ComponentDefinitionType type){
|
||||||
|
definition.instantiationsOfType(type).map[it.componentInstances.size].reduce[p1, p2| p1+p2]
|
||||||
|
}
|
||||||
|
|
||||||
|
static def instantiationsOfType(ComponentDefinition definition, ComponentDefinitionType type){
|
||||||
|
definition.instantiations.filter[it.definingComponent.type == type]
|
||||||
|
}
|
||||||
|
|
||||||
|
static def long byteSize(Instantiation instantiation, long start){
|
||||||
|
val componentDefinition = instantiation.definingComponent
|
||||||
|
var long componentSize=0;
|
||||||
|
if(instantiation.definingComponent.type == ComponentDefinitionType.REG){
|
||||||
|
componentSize=instantiation.definingComponent.regWidth/8
|
||||||
|
} else
|
||||||
|
for(subInstantiation: componentDefinition.instantiations)
|
||||||
|
componentSize = subInstantiation.byteSize(componentSize)
|
||||||
|
|
||||||
|
var long lastTopAddress = start
|
||||||
|
var long topAddress=start
|
||||||
|
for(componentInstance: instantiation.componentInstances ){
|
||||||
|
val byteSize = if(componentInstance.address !== null) (componentInstance.address as IntegerWithRadix).value+componentSize else componentSize + lastTopAddress
|
||||||
|
topAddress = Math.max(topAddress, byteSize)
|
||||||
|
lastTopAddress = byteSize
|
||||||
|
}
|
||||||
|
return topAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
static def long byteSize(Instantiation instantiation){
|
||||||
|
val componentDefinition = instantiation.definingComponent
|
||||||
|
var long componentSize=0;
|
||||||
|
if(instantiation.definingComponent.type == ComponentDefinitionType.REG){
|
||||||
|
componentSize=instantiation.definingComponent.regWidth/8
|
||||||
|
} else
|
||||||
|
for(subInstantiation: componentDefinition.instantiations)
|
||||||
|
componentSize = subInstantiation.byteSize(componentSize)
|
||||||
|
return componentSize
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,10 @@ import com.minres.rdl.generator.RdlBaseGenerator
|
|||||||
import com.minres.rdl.rdl.ComponentDefinition
|
import com.minres.rdl.rdl.ComponentDefinition
|
||||||
import com.minres.rdl.IntegerWithRadix
|
import com.minres.rdl.IntegerWithRadix
|
||||||
import com.minres.rdl.rdl.ComponentDefinitionType
|
import com.minres.rdl.rdl.ComponentDefinitionType
|
||||||
|
import com.minres.rdl.rdl.ComponentInstance
|
||||||
|
import com.minres.rdl.rdl.Instantiation
|
||||||
|
|
||||||
|
import static extension com.minres.rdl.RdlUtil.*
|
||||||
|
|
||||||
class AddrmapGenerator extends RdlBaseGenerator {
|
class AddrmapGenerator extends RdlBaseGenerator {
|
||||||
|
|
||||||
@ -14,18 +18,18 @@ class AddrmapGenerator extends RdlBaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override generateHeader() {'''
|
override generateHeader() {'''
|
||||||
#ifndef _E300_PLAT_MAP_H_
|
#ifndef _«componentDefinition.effectiveName.toUpperCase»_MAP_H_
|
||||||
#define _E300_PLAT_MAP_H_
|
#define _«componentDefinition.effectiveName.toUpperCase»_MAP_H_
|
||||||
// need double braces, see https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191
|
// need double braces, see https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191
|
||||||
const std::array<sysc::target_memory_map_entry<32>, «componentDefinition.instanceCount(ComponentDefinitionType.REGFILE)»> e300_plat_map = {{
|
const std::array<sysc::target_memory_map_entry<32>, «componentDefinition.instanceCount(ComponentDefinitionType.REGFILE)»> «componentDefinition.effectiveName»_map = {{
|
||||||
«FOR instantiation : componentDefinition.instantiationsOfType(ComponentDefinitionType.REGFILE)»
|
«FOR instantiation : componentDefinition.instantiationsOfType(ComponentDefinitionType.REGFILE)»
|
||||||
«FOR instance : instantiation.componentInstances»
|
«FOR instance : instantiation.componentInstances»
|
||||||
{&i_«instance.name», 0x«Long.toHexString((instance.address as IntegerWithRadix).value)», 0x«Long.toHexString(instantiation.byteSize)»},
|
{&i_«instance.name», «instance.addressValue», 0x«Long.toHexString(instantiation.byteSize)»},
|
||||||
«ENDFOR»
|
«ENDFOR»
|
||||||
«ENDFOR»
|
«ENDFOR»
|
||||||
}};
|
}};
|
||||||
|
|
||||||
#endif /* _E300_PLAT_MAP_H_ */
|
#endif /* _«componentDefinition.effectiveName.toUpperCase»_MAP_H_ */
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import org.eclipse.emf.ecore.resource.Resource
|
|||||||
import org.eclipse.xtext.generator.AbstractGenerator
|
import org.eclipse.xtext.generator.AbstractGenerator
|
||||||
import org.eclipse.xtext.generator.IFileSystemAccess2
|
import org.eclipse.xtext.generator.IFileSystemAccess2
|
||||||
import org.eclipse.xtext.generator.IGeneratorContext
|
import org.eclipse.xtext.generator.IGeneratorContext
|
||||||
|
import static extension com.minres.rdl.RdlUtil.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates code from your model files on save.
|
* Generates code from your model files on save.
|
||||||
@ -22,9 +23,9 @@ class RDLGenerator extends AbstractGenerator {
|
|||||||
val gen = it.fileGenerator
|
val gen = it.fileGenerator
|
||||||
if(gen!==null){
|
if(gen!==null){
|
||||||
val header = gen.generateHeader
|
val header = gen.generateHeader
|
||||||
if(header!==null && header.length>0) fsa.generateFile(it.name+'.h', fsa.outputConfig('incl-out'), header)
|
if(header!==null && header.length>0) fsa.generateFile(it.effectiveName+'.h', fsa.outputConfig('incl-out'), header)
|
||||||
val source = gen.generateSource
|
val source = gen.generateSource
|
||||||
if(source!==null && source.length>0) fsa.generateFile(it.name+'.cpp', fsa.outputConfig('src-out'), source)
|
if(source!==null && source.length>0) fsa.generateFile(it.effectiveName+'.cpp', fsa.outputConfig('src-out'), source)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -14,137 +14,6 @@ import com.minres.rdl.rdl.ComponentDefinitionType
|
|||||||
|
|
||||||
abstract class RdlBaseGenerator {
|
abstract class RdlBaseGenerator {
|
||||||
|
|
||||||
def long accessWidth(ComponentDefinition definition){
|
|
||||||
var size = 32L
|
|
||||||
val pa = definition.propertyAssignments.findFirst[PropertyAssignment pa |
|
|
||||||
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.ACCESSWIDTH
|
|
||||||
]
|
|
||||||
if(pa !== null){
|
|
||||||
val sz = new IntegerWithRadix((pa as ExplicitPropertyAssignment).rhs.effectiveValue)
|
|
||||||
size=sz.value
|
|
||||||
}
|
|
||||||
return size
|
|
||||||
}
|
|
||||||
|
|
||||||
def long regWidth(ComponentDefinition definition){
|
|
||||||
var size = 32L
|
|
||||||
val pa = definition.propertyAssignments.findFirst[PropertyAssignment pa |
|
|
||||||
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.REGWIDTH
|
|
||||||
]
|
|
||||||
if(pa !== null){
|
|
||||||
val sz = new IntegerWithRadix((pa as ExplicitPropertyAssignment).rhs.effectiveValue)
|
|
||||||
size=sz.value
|
|
||||||
}
|
|
||||||
return size
|
|
||||||
}
|
|
||||||
|
|
||||||
def long getSize(Instantiation instantiation){
|
|
||||||
val componentDef= instantiation.definingComponent
|
|
||||||
switch (componentDef.type) {
|
|
||||||
case ComponentDefinitionType.REG: {
|
|
||||||
val pa = componentDef.propertyAssignments.findFirst[PropertyAssignment pa |
|
|
||||||
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.REGWIDTH
|
|
||||||
]
|
|
||||||
if(pa !== null){
|
|
||||||
val sz = new IntegerWithRadix((pa as ExplicitPropertyAssignment).rhs.effectiveValue)
|
|
||||||
return sz.value
|
|
||||||
}
|
|
||||||
return 32L
|
|
||||||
}
|
|
||||||
case ComponentDefinitionType.FIELD:{
|
|
||||||
val pa = componentDef.propertyAssignments.findFirst[PropertyAssignment pa |
|
|
||||||
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.FIELDWIDTH
|
|
||||||
]
|
|
||||||
if(pa !== null){
|
|
||||||
val sz = new IntegerWithRadix((pa as ExplicitPropertyAssignment).rhs.effectiveValue)
|
|
||||||
return sz.value
|
|
||||||
}
|
|
||||||
return 1L
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def String effectiveName(ComponentDefinition definition){
|
|
||||||
if(definition.name!==null){
|
|
||||||
definition.name
|
|
||||||
} else{
|
|
||||||
val pa = definition.propertyAssignments.findFirst[PropertyAssignment pa |
|
|
||||||
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.NAME
|
|
||||||
]
|
|
||||||
(pa as ExplicitPropertyAssignment).rhs.effectiveValue
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
def String effectiveValue(PropertyAssignmentRhs rhs){
|
|
||||||
if(rhs.value!== null)
|
|
||||||
rhs.value.effectiveValue
|
|
||||||
else if(rhs.instPropRef!==null)
|
|
||||||
rhs.instPropRef.effectiveValue
|
|
||||||
else if(rhs.enumRef!==null)
|
|
||||||
rhs.enumRef.name
|
|
||||||
}
|
|
||||||
|
|
||||||
def String effectiveValue(RValue rvalue){
|
|
||||||
if(rvalue.str!==null){
|
|
||||||
rvalue.str
|
|
||||||
} else if(rvalue.^val!=RValueConstant.UNDEFINED)
|
|
||||||
rvalue.^val.literal
|
|
||||||
else if(rvalue.num!==null){
|
|
||||||
val num = rvalue.num as IntegerWithRadix
|
|
||||||
num.toString
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def String effectiveValue(InstancePropertyRef ref){
|
|
||||||
throw new RuntimeException()
|
|
||||||
}
|
|
||||||
|
|
||||||
def ComponentDefinition definingComponent(Instantiation instantiation){
|
|
||||||
if(instantiation.componentRef!==null) instantiation.componentRef else instantiation.component
|
|
||||||
}
|
|
||||||
|
|
||||||
def int instanceCount(ComponentDefinition definition, ComponentDefinitionType type){
|
|
||||||
definition.instantiationsOfType(type).map[it.componentInstances.size].reduce[p1, p2| p1+p2]
|
|
||||||
}
|
|
||||||
|
|
||||||
def instantiationsOfType(ComponentDefinition definition, ComponentDefinitionType type){
|
|
||||||
definition.instantiations.filter[it.definingComponent.type == type]
|
|
||||||
}
|
|
||||||
|
|
||||||
def long byteSize(Instantiation instantiation, long start){
|
|
||||||
val componentDefinition = instantiation.definingComponent
|
|
||||||
var long componentSize=0;
|
|
||||||
if(instantiation.definingComponent.type == ComponentDefinitionType.REG){
|
|
||||||
componentSize=instantiation.definingComponent.regWidth/8
|
|
||||||
} else
|
|
||||||
for(subInstantiation: componentDefinition.instantiations)
|
|
||||||
componentSize = subInstantiation.byteSize(componentSize)
|
|
||||||
|
|
||||||
var long lastTopAddress = start
|
|
||||||
var long topAddress=start
|
|
||||||
for(componentInstance: instantiation.componentInstances ){
|
|
||||||
val byteSize = if(componentInstance.address !== null) (componentInstance.address as IntegerWithRadix).value+componentSize else componentSize + lastTopAddress
|
|
||||||
topAddress = Math.max(topAddress, byteSize)
|
|
||||||
lastTopAddress = byteSize
|
|
||||||
}
|
|
||||||
return topAddress
|
|
||||||
}
|
|
||||||
|
|
||||||
def long byteSize(Instantiation instantiation){
|
|
||||||
val componentDefinition = instantiation.definingComponent
|
|
||||||
var long componentSize=0;
|
|
||||||
if(instantiation.definingComponent.type == ComponentDefinitionType.REG){
|
|
||||||
componentSize=instantiation.definingComponent.regWidth/8
|
|
||||||
} else
|
|
||||||
for(subInstantiation: componentDefinition.instantiations)
|
|
||||||
componentSize = subInstantiation.byteSize(componentSize)
|
|
||||||
return componentSize
|
|
||||||
}
|
|
||||||
|
|
||||||
def String generateHeader()
|
def String generateHeader()
|
||||||
|
|
||||||
def String generateSource()
|
def String generateSource()
|
||||||
|
@ -8,6 +8,8 @@ import com.minres.rdl.rdl.Instantiation
|
|||||||
import java.util.Date
|
import java.util.Date
|
||||||
import com.minres.rdl.rdl.Range
|
import com.minres.rdl.rdl.Range
|
||||||
|
|
||||||
|
import static extension com.minres.rdl.RdlUtil.*
|
||||||
|
|
||||||
class RegfileGenerator extends RdlBaseGenerator{
|
class RegfileGenerator extends RdlBaseGenerator{
|
||||||
|
|
||||||
val ComponentDefinition componentDefinition
|
val ComponentDefinition componentDefinition
|
||||||
@ -145,7 +147,7 @@ class RegfileGenerator extends RdlBaseGenerator{
|
|||||||
inline void sysc::«componentDefinition.name»::registerResources(sysc::tlm_target<BUSWIDTH>& target) {
|
inline void sysc::«componentDefinition.name»::registerResources(sysc::tlm_target<BUSWIDTH>& target) {
|
||||||
«FOR instantiation : componentDefinition.instantiations»
|
«FOR instantiation : componentDefinition.instantiations»
|
||||||
«FOR instance : instantiation.componentInstances»
|
«FOR instance : instantiation.componentInstances»
|
||||||
target.addResource(«instance.name», 0x«Long.toHexString((instance.address as IntegerWithRadix).value)»UL);
|
target.addResource(«instance.name», «instance.addressValue»UL);
|
||||||
«ENDFOR»
|
«ENDFOR»
|
||||||
«ENDFOR»
|
«ENDFOR»
|
||||||
}
|
}
|
||||||
|
@ -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;
|
package com.minres.rdl.generator;
|
||||||
|
|
||||||
import com.minres.rdl.IntegerWithRadix;
|
import com.minres.rdl.IntegerWithRadix;
|
||||||
|
import com.minres.rdl.RdlUtil;
|
||||||
import com.minres.rdl.generator.RdlBaseGenerator;
|
import com.minres.rdl.generator.RdlBaseGenerator;
|
||||||
import com.minres.rdl.rdl.ComponentDefinition;
|
import com.minres.rdl.rdl.ComponentDefinition;
|
||||||
import com.minres.rdl.rdl.ComponentDefinitionType;
|
import com.minres.rdl.rdl.ComponentDefinitionType;
|
||||||
@ -20,19 +21,28 @@ public class AddrmapGenerator extends RdlBaseGenerator {
|
|||||||
@Override
|
@Override
|
||||||
public String generateHeader() {
|
public String generateHeader() {
|
||||||
StringConcatenation _builder = new StringConcatenation();
|
StringConcatenation _builder = new StringConcatenation();
|
||||||
_builder.append("#ifndef _E300_PLAT_MAP_H_");
|
_builder.append("#ifndef _");
|
||||||
_builder.newLine();
|
String _upperCase = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
|
||||||
_builder.append("#define _E300_PLAT_MAP_H_");
|
_builder.append(_upperCase);
|
||||||
_builder.newLine();
|
_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.append("// need double braces, see https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191");
|
||||||
_builder.newLine();
|
_builder.newLine();
|
||||||
_builder.append("const std::array<sysc::target_memory_map_entry<32>, ");
|
_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(_instanceCount);
|
||||||
_builder.append("> e300_plat_map = {{");
|
_builder.append("> ");
|
||||||
|
String _effectiveName = RdlUtil.effectiveName(this.componentDefinition);
|
||||||
|
_builder.append(_effectiveName);
|
||||||
|
_builder.append("_map = {{");
|
||||||
_builder.newLineIfNotEmpty();
|
_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) {
|
for(final Instantiation instantiation : _instantiationsOfType) {
|
||||||
{
|
{
|
||||||
EList<ComponentInstance> _componentInstances = instantiation.getComponentInstances();
|
EList<ComponentInstance> _componentInstances = instantiation.getComponentInstances();
|
||||||
@ -41,13 +51,12 @@ public class AddrmapGenerator extends RdlBaseGenerator {
|
|||||||
_builder.append("{&i_");
|
_builder.append("{&i_");
|
||||||
String _name = instance.getName();
|
String _name = instance.getName();
|
||||||
_builder.append(_name, " ");
|
_builder.append(_name, " ");
|
||||||
|
_builder.append(", ");
|
||||||
|
IntegerWithRadix _addressValue = RdlUtil.addressValue(instance);
|
||||||
|
_builder.append(_addressValue, " ");
|
||||||
_builder.append(", 0x");
|
_builder.append(", 0x");
|
||||||
Object _address = instance.getAddress();
|
String _hexString = Long.toHexString(RdlUtil.byteSize(instantiation));
|
||||||
String _hexString = Long.toHexString(((IntegerWithRadix) _address).value);
|
|
||||||
_builder.append(_hexString, " ");
|
_builder.append(_hexString, " ");
|
||||||
_builder.append(", 0x");
|
|
||||||
String _hexString_1 = Long.toHexString(this.byteSize(instantiation));
|
|
||||||
_builder.append(_hexString_1, " ");
|
|
||||||
_builder.append("},");
|
_builder.append("},");
|
||||||
_builder.newLineIfNotEmpty();
|
_builder.newLineIfNotEmpty();
|
||||||
}
|
}
|
||||||
@ -57,8 +66,11 @@ public class AddrmapGenerator extends RdlBaseGenerator {
|
|||||||
_builder.append("}};");
|
_builder.append("}};");
|
||||||
_builder.newLine();
|
_builder.newLine();
|
||||||
_builder.newLine();
|
_builder.newLine();
|
||||||
_builder.append("#endif /* _E300_PLAT_MAP_H_ */");
|
_builder.append("#endif /* _");
|
||||||
_builder.newLine();
|
String _upperCase_2 = RdlUtil.effectiveName(this.componentDefinition).toUpperCase();
|
||||||
|
_builder.append(_upperCase_2);
|
||||||
|
_builder.append("_MAP_H_ */");
|
||||||
|
_builder.newLineIfNotEmpty();
|
||||||
return _builder.toString();
|
return _builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.minres.rdl.generator;
|
package com.minres.rdl.generator;
|
||||||
|
|
||||||
|
import com.minres.rdl.RdlUtil;
|
||||||
import com.minres.rdl.generator.AddrmapGenerator;
|
import com.minres.rdl.generator.AddrmapGenerator;
|
||||||
import com.minres.rdl.generator.RdlBaseGenerator;
|
import com.minres.rdl.generator.RdlBaseGenerator;
|
||||||
import com.minres.rdl.generator.RegfileGenerator;
|
import com.minres.rdl.generator.RegfileGenerator;
|
||||||
@ -38,14 +39,14 @@ public class RDLGenerator extends AbstractGenerator {
|
|||||||
if ((gen != null)) {
|
if ((gen != null)) {
|
||||||
final String header = gen.generateHeader();
|
final String header = gen.generateHeader();
|
||||||
if (((header != null) && (header.length() > 0))) {
|
if (((header != null) && (header.length() > 0))) {
|
||||||
String _name = it.getName();
|
String _effectiveName = RdlUtil.effectiveName(it);
|
||||||
String _plus = (_name + ".h");
|
String _plus = (_effectiveName + ".h");
|
||||||
fsa.generateFile(_plus, this.outputConfig(fsa, "incl-out"), header);
|
fsa.generateFile(_plus, this.outputConfig(fsa, "incl-out"), header);
|
||||||
}
|
}
|
||||||
final String source = gen.generateSource();
|
final String source = gen.generateSource();
|
||||||
if (((source != null) && (source.length() > 0))) {
|
if (((source != null) && (source.length() > 0))) {
|
||||||
String _name_1 = it.getName();
|
String _effectiveName_1 = RdlUtil.effectiveName(it);
|
||||||
String _plus_1 = (_name_1 + ".cpp");
|
String _plus_1 = (_effectiveName_1 + ".cpp");
|
||||||
fsa.generateFile(_plus_1, this.outputConfig(fsa, "src-out"), source);
|
fsa.generateFile(_plus_1, this.outputConfig(fsa, "src-out"), source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,256 +1,7 @@
|
|||||||
package com.minres.rdl.generator;
|
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")
|
@SuppressWarnings("all")
|
||||||
public abstract class RdlBaseGenerator {
|
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 generateHeader();
|
||||||
|
|
||||||
public abstract String generateSource();
|
public abstract String generateSource();
|
||||||
|
@ -2,6 +2,7 @@ package com.minres.rdl.generator;
|
|||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.minres.rdl.IntegerWithRadix;
|
import com.minres.rdl.IntegerWithRadix;
|
||||||
|
import com.minres.rdl.RdlUtil;
|
||||||
import com.minres.rdl.generator.RdlBaseGenerator;
|
import com.minres.rdl.generator.RdlBaseGenerator;
|
||||||
import com.minres.rdl.rdl.ComponentDefinition;
|
import com.minres.rdl.rdl.ComponentDefinition;
|
||||||
import com.minres.rdl.rdl.ComponentDefinitionType;
|
import com.minres.rdl.rdl.ComponentDefinitionType;
|
||||||
@ -152,7 +153,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
if (_equals) {
|
if (_equals) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_builder.append("BEGIN_BF_DECL(");
|
_builder.append("BEGIN_BF_DECL(");
|
||||||
String _effectiveName = this.effectiveName(cdef);
|
String _effectiveName = RdlUtil.effectiveName(cdef);
|
||||||
_builder.append(_effectiveName, " ");
|
_builder.append(_effectiveName, " ");
|
||||||
_builder.append("+\'_t\'», uint");
|
_builder.append("+\'_t\'», uint");
|
||||||
_builder.append(cdef, " ");
|
_builder.append(cdef, " ");
|
||||||
@ -175,7 +176,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
{
|
{
|
||||||
if (((instantiation.getComponentRef() != null) && Objects.equal(instantiation.getComponentRef().getType(), ComponentDefinitionType.REG))) {
|
if (((instantiation.getComponentRef() != null) && Objects.equal(instantiation.getComponentRef().getType(), ComponentDefinitionType.REG))) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
String _effectiveName_1 = this.effectiveName(instantiation.getComponentRef());
|
String _effectiveName_1 = RdlUtil.effectiveName(instantiation.getComponentRef());
|
||||||
_builder.append(_effectiveName_1, " ");
|
_builder.append(_effectiveName_1, " ");
|
||||||
_builder.append("+\'_t\' ");
|
_builder.append("+\'_t\' ");
|
||||||
final Function1<ComponentInstance, String> _function = (ComponentInstance it) -> {
|
final Function1<ComponentInstance, String> _function = (ComponentInstance it) -> {
|
||||||
@ -202,7 +203,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
if (_greaterThan) {
|
if (_greaterThan) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_builder.append("uint");
|
_builder.append("uint");
|
||||||
long _size_1 = this.getSize(instantiation);
|
long _size_1 = RdlUtil.getSize(instantiation);
|
||||||
_builder.append(_size_1, " ");
|
_builder.append(_size_1, " ");
|
||||||
_builder.append("_t ");
|
_builder.append("_t ");
|
||||||
final Function1<ComponentInstance, Boolean> _function_2 = (ComponentInstance it) -> {
|
final Function1<ComponentInstance, Boolean> _function_2 = (ComponentInstance it) -> {
|
||||||
@ -228,7 +229,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
for(final ComponentInstance componentInstance : _filter) {
|
for(final ComponentInstance componentInstance : _filter) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_builder.append("std::array<uint");
|
_builder.append("std::array<uint");
|
||||||
long _size_2 = this.getSize(instantiation);
|
long _size_2 = RdlUtil.getSize(instantiation);
|
||||||
_builder.append(_size_2, " ");
|
_builder.append(_size_2, " ");
|
||||||
_builder.append("_t, ");
|
_builder.append("_t, ");
|
||||||
long _absSize = this.absSize(componentInstance.getRange());
|
long _absSize = this.absSize(componentInstance.getRange());
|
||||||
@ -248,16 +249,16 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
if (_not) {
|
if (_not) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_builder.append("BEGIN_BF_DECL(");
|
_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(_effectiveName_2, " ");
|
||||||
_builder.append("_t, uint");
|
_builder.append("_t, uint");
|
||||||
long _size_3 = this.getSize(instantiation);
|
long _size_3 = RdlUtil.getSize(instantiation);
|
||||||
_builder.append(_size_3, " ");
|
_builder.append(_size_3, " ");
|
||||||
_builder.append("_t);");
|
_builder.append("_t);");
|
||||||
_builder.newLineIfNotEmpty();
|
_builder.newLineIfNotEmpty();
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_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.append(_genFieldDeclarations_1, " ");
|
||||||
_builder.newLineIfNotEmpty();
|
_builder.newLineIfNotEmpty();
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
@ -283,7 +284,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
for(final ComponentInstance componentInstance_1 : _filter_1) {
|
for(final ComponentInstance componentInstance_1 : _filter_1) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_builder.append("std::array<");
|
_builder.append("std::array<");
|
||||||
String _effectiveName_3 = this.effectiveName(instantiation.getComponent());
|
String _effectiveName_3 = RdlUtil.effectiveName(instantiation.getComponent());
|
||||||
_builder.append(_effectiveName_3, " ");
|
_builder.append(_effectiveName_3, " ");
|
||||||
_builder.append("_t, ");
|
_builder.append("_t, ");
|
||||||
long _absSize_1 = this.absSize(componentInstance_1.getRange());
|
long _absSize_1 = this.absSize(componentInstance_1.getRange());
|
||||||
@ -321,7 +322,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
if (_isFilledByField_2) {
|
if (_isFilledByField_2) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_builder.append("sysc::sc_register<uint");
|
_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(_size_4, " ");
|
||||||
_builder.append("_t> ");
|
_builder.append("_t> ");
|
||||||
String _name_4 = instance.getName();
|
String _name_4 = instance.getName();
|
||||||
@ -336,7 +337,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
if (_not_1) {
|
if (_not_1) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_builder.append("sysc::sc_register<");
|
_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(_effectiveName_4, " ");
|
||||||
_builder.append("_t> ");
|
_builder.append("_t> ");
|
||||||
String _name_5 = instance.getName();
|
String _name_5 = instance.getName();
|
||||||
@ -356,7 +357,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
if (_isFilledByField_4) {
|
if (_isFilledByField_4) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_builder.append("sysc::sc_register_indexed<uint");
|
_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(_size_5, " ");
|
||||||
_builder.append("_t, ");
|
_builder.append("_t, ");
|
||||||
long _absSize_2 = this.absSize(instance.getRange());
|
long _absSize_2 = this.absSize(instance.getRange());
|
||||||
@ -374,7 +375,7 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
if (_not_2) {
|
if (_not_2) {
|
||||||
_builder.append(" ");
|
_builder.append(" ");
|
||||||
_builder.append("sysc::sc_register_indexed<");
|
_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(_effectiveName_5, " ");
|
||||||
_builder.append("_t, ");
|
_builder.append("_t, ");
|
||||||
long _absSize_3 = this.absSize(instance.getRange());
|
long _absSize_3 = this.absSize(instance.getRange());
|
||||||
@ -467,10 +468,9 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
_builder.append("target.addResource(");
|
_builder.append("target.addResource(");
|
||||||
String _name_14 = instance_2.getName();
|
String _name_14 = instance_2.getName();
|
||||||
_builder.append(_name_14, " ");
|
_builder.append(_name_14, " ");
|
||||||
_builder.append(", 0x");
|
_builder.append(", ");
|
||||||
Object _address = instance_2.getAddress();
|
IntegerWithRadix _addressValue = RdlUtil.addressValue(instance_2);
|
||||||
String _hexString = Long.toHexString(((IntegerWithRadix) _address).value);
|
_builder.append(_addressValue, " ");
|
||||||
_builder.append(_hexString, " ");
|
|
||||||
_builder.append("UL);");
|
_builder.append("UL);");
|
||||||
_builder.newLineIfNotEmpty();
|
_builder.newLineIfNotEmpty();
|
||||||
}
|
}
|
||||||
@ -505,12 +505,12 @@ public class RegfileGenerator extends RdlBaseGenerator {
|
|||||||
public boolean isFilledByField(final Instantiation instantiation) {
|
public boolean isFilledByField(final Instantiation instantiation) {
|
||||||
final int fieldCount = this.instanceCountOfType(instantiation.getComponent(), ComponentDefinitionType.FIELD);
|
final int fieldCount = this.instanceCountOfType(instantiation.getComponent(), ComponentDefinitionType.FIELD);
|
||||||
if ((fieldCount == 1)) {
|
if ((fieldCount == 1)) {
|
||||||
final long instSize = this.getSize(instantiation);
|
final long instSize = RdlUtil.getSize(instantiation);
|
||||||
final Instantiation field = ((Instantiation[])Conversions.unwrapArray(this.instantiationsOfType(instantiation.getComponent(), ComponentDefinitionType.FIELD), Instantiation.class))[0];
|
final Instantiation field = ((Instantiation[])Conversions.unwrapArray(RdlUtil.instantiationsOfType(instantiation.getComponent(), ComponentDefinitionType.FIELD), Instantiation.class))[0];
|
||||||
final ComponentInstance inst = field.getComponentInstances().get(0);
|
final ComponentInstance inst = field.getComponentInstances().get(0);
|
||||||
final Range range = inst.getRange();
|
final Range range = inst.getRange();
|
||||||
if ((range == null)) {
|
if ((range == null)) {
|
||||||
long _size = this.getSize(field);
|
long _size = RdlUtil.getSize(field);
|
||||||
return (instSize == _size);
|
return (instSize == _size);
|
||||||
}
|
}
|
||||||
Object _size_1 = range.getSize();
|
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) -> {
|
final Function2<Integer, Integer, Integer> _function_1 = (Integer p1, Integer p2) -> {
|
||||||
return Integer.valueOf(((p1).intValue() + (p1).intValue()));
|
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
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user