update to latest CoreDSL 2.0.2
This commit is contained in:
@ -15,12 +15,12 @@ import com.minres.coredsl.coreDsl.Encoding
|
||||
import com.minres.coredsl.coreDsl.BitField
|
||||
import com.minres.coredsl.coreDsl.BitValue
|
||||
import java.util.List
|
||||
import com.minres.coredsl.coreDsl.AttributeName
|
||||
import com.minres.coredsl.coreDsl.ISA
|
||||
import org.json.JSONObject
|
||||
import org.json.JSONArray
|
||||
import com.minres.coredsl.util.BigIntegerWithRadix
|
||||
import com.minres.coredsl.coreDsl.Statement
|
||||
import org.eclipse.xtext.resource.XtextResource
|
||||
|
||||
/**
|
||||
* Generates code from your model files on save.
|
||||
@ -35,14 +35,14 @@ class CoreDslJsonGenerator extends AbstractGenerator {
|
||||
for (e : resource.allContents.toIterable.filter(CoreDef)) {
|
||||
val root = new JSONObject()
|
||||
root.put('instructions', e.compile)
|
||||
fsa.generateFile(e.name + ".json", root.toString)
|
||||
fsa.generateFile(e.name + ".json", root.toString(2))
|
||||
}
|
||||
}
|
||||
|
||||
def Boolean isHls(Instruction inst){
|
||||
val instrSet = inst.eContainer as ISA;
|
||||
!(inst.attributes.filter[it.type==AttributeName.HLS].isEmpty &&
|
||||
instrSet.attributes.filter[it.type==AttributeName.HLS].isEmpty)
|
||||
!(inst.attributes.filter[it.type=='hls'].isEmpty &&
|
||||
instrSet.commonInstructionAttributes.filter[it.type=='hls'].isEmpty)
|
||||
}
|
||||
def JSONArray compile(CoreDef coreDef) {
|
||||
val insts = coreDef.allInstr
|
||||
@ -53,35 +53,15 @@ class CoreDslJsonGenerator extends AbstractGenerator {
|
||||
|
||||
def JSONObject jsonDescr(Instruction inst){
|
||||
val ret = new JSONObject();
|
||||
ret.put("decoding", inst.encoding.fields.map[it.asString].join(' '))
|
||||
ret.put("decoding", inst.encoding.fields.map[it.asString].join('|'))
|
||||
ret.put("name", inst.name);
|
||||
ret.put('disassembly', inst.disass !== null? inst.name.toLowerCase + ' ' + inst.disass.toLowerCase : inst.name)
|
||||
ret.put('disassembly', inst.assembly !== null? inst.name.toLowerCase + ' ' + inst.assembly.toLowerCase : inst.name)
|
||||
ret.put('execution', inst.behavior.source)
|
||||
ret.put('restrictions', '')
|
||||
}
|
||||
|
||||
def String getSource(Statement stmt){
|
||||
// val c = CoreDslFactory.eINSTANCE.createDescriptionContent => [
|
||||
// definitions += CoreDslFactory.eINSTANCE.createISA => [
|
||||
// name = 'dummy'
|
||||
// instructions += CoreDslFactory.eINSTANCE.createInstruction => [
|
||||
// name = 'dummy'
|
||||
// encoding = CoreDslFactory.eINSTANCE.createEncoding => [
|
||||
// fields += CoreDslFactory.eINSTANCE.createBitField => [
|
||||
// name = 'dummy'
|
||||
// left = CoreDslFactory.eINSTANCE.createIntegerConstant => [ value= BigInteger.valueOf(32) ]
|
||||
// right = CoreDslFactory.eINSTANCE.createIntegerConstant => [ value= BigInteger.ZERO ]
|
||||
// ]
|
||||
// ]
|
||||
// behavior = stmt
|
||||
// ]
|
||||
// ]
|
||||
// ]
|
||||
// val rs = rsp.get
|
||||
// val r = rs.createResource(URI.createURI("dummy.core_desc"))
|
||||
// r.contents+=c
|
||||
// c.serialize
|
||||
stmt.toString
|
||||
(stmt.eResource as XtextResource).serializer.serialize(stmt)
|
||||
}
|
||||
|
||||
def Iterable<Instruction> allInstr(CoreDef core) {
|
||||
|
Reference in New Issue
Block a user