duh-ipxact
Advanced tools
Comparing version 0.7.4 to 0.7.6
122
lib/ml2on.js
@@ -6,94 +6,6 @@ 'use strict'; | ||
const mergeTail = node => { | ||
let res = {}; | ||
const arr = node.full; | ||
for (let i = 2; i < arr.length; i++) { | ||
const ai = arr[i]; | ||
Object.keys(ai).map(key => { | ||
if (res[key] === undefined) { | ||
res[key] = ai[key]; | ||
} else if (Array.isArray(res[key])) { | ||
res[key] = res[key].concat(ai[key]); | ||
} else { | ||
res[key] = ai[key]; | ||
} | ||
}); | ||
} | ||
return res; | ||
}; | ||
const porter = require('./porter.js'); | ||
const mergeTail = require('./merge-tail.js'); | ||
const toNumber = require('./to-number.js'); | ||
const toNumber = node => { | ||
const str = node.full[2] || ''; | ||
if (typeof str !== 'string') { | ||
throw new Error(JSON.stringify(node.full, null, 2)); | ||
} | ||
const m16 = str.match(/^'h([0-9a-zA-Z]+)$/); | ||
if (m16) { | ||
return Number('0x' + m16[1].trim()); | ||
} | ||
const m2 = str.match('\'b([01]+)'); | ||
if (m2) { | ||
return Number('0b' + m2[1].trim()); | ||
} | ||
const m10 = str.match('\'d([0-9]+)'); | ||
if (m10) { | ||
return Number(m10[1].trim()); | ||
} | ||
let res = Number(str); | ||
return Number.isNaN(res) ? str : res; | ||
}; | ||
const porter = node => { | ||
let info = mergeTail(node); | ||
let width; | ||
let vectors = info.wire.vectors; | ||
if (vectors === undefined) { | ||
let vector = info.wire.vector; | ||
if (vector === undefined) { | ||
width = 1; | ||
} else { | ||
if (Number.isInteger(vector.left) && (vector.right === 0)) { | ||
width = vector.left + 1; | ||
} else { | ||
throw new Error(JSON.stringify(info, null, 2)); | ||
} | ||
} | ||
} else { | ||
let vector = info.wire.vectors.vector; | ||
if (vector === undefined) { | ||
width = 1; | ||
} else { | ||
if (Number.isInteger(vector.left) && (vector.right === 0)) { | ||
width = vector.left + 1; | ||
} else { | ||
throw new Error(JSON.stringify(info, null, 2)); | ||
} | ||
} | ||
} | ||
let res; | ||
if (info.wire.direction === 'out') { | ||
res = -width; | ||
} else | ||
if (info.wire.direction === 'in') { | ||
res = width; | ||
} else | ||
if (info.wire.direction === 'inout') { | ||
res = { | ||
direction: 'inout', | ||
width: width | ||
}; | ||
} else { | ||
throw new Error(JSON.stringify(info, null, 2)); | ||
} | ||
return { | ||
[info.name]: res | ||
}; | ||
}; | ||
const portMapper = node => { | ||
@@ -112,4 +24,2 @@ const arr = node.full; | ||
// const portsReduce = node => { | ||
@@ -125,6 +35,2 @@ // let res = {}; | ||
// | ||
// const toNumber = val => { | ||
// const num = Number(val); | ||
// return (isNaN(num) || ((num |0) !== num)) ? val : num; | ||
// }; | ||
@@ -215,3 +121,4 @@ const luter = str => | ||
const namedProps = luter(` | ||
logicalPort physicalPort | ||
logicalPort | ||
physicalPort | ||
`); | ||
@@ -347,6 +254,7 @@ /* | ||
case ns + 'vendorExtensions': | ||
this.replace((n => { | ||
let res = n.full.slice(2); | ||
return {[name]: res}; | ||
})(node)); | ||
this.replace(true); | ||
// this.replace((n => { | ||
// let res = n.full.slice(2); | ||
// return {[name]: res}; | ||
// })(node)); | ||
break; | ||
@@ -356,3 +264,6 @@ | ||
case ns + 'mirroredSlave': | ||
this.replace({interfaceMode: 'initiator'}); | ||
this.replace({ | ||
interfaceMode: 'initiator', | ||
addressSpaceRef: (tail.addressSpaceRef || {}).addressSpaceRef | ||
}); | ||
break; | ||
@@ -362,3 +273,6 @@ | ||
case ns + 'mirroredMaster': | ||
this.replace({interfaceMode: 'target'}); | ||
this.replace({ | ||
interfaceMode: 'target', | ||
memoryMapRef: (tail.memoryMapRef || {}).memoryMapRef | ||
}); | ||
break; | ||
@@ -365,0 +279,0 @@ |
@@ -5,6 +5,6 @@ 'use strict'; | ||
let spirit = 'http://www.spiritconsortium.org/XMLSchema'; | ||
let spirit14 = spirit + '/SPIRIT/1.4'; | ||
let spirit09 = spirit + '/SPIRIT/1685-2009'; | ||
let xsi = 'http://www.w3.org/2001/XMLSchema-instance'; | ||
const spirit = 'http://www.spiritconsortium.org/XMLSchema'; | ||
const spirit14 = spirit + '/SPIRIT/1.4'; | ||
const spirit09 = spirit + '/SPIRIT/1685-2009'; | ||
const xsi = 'http://www.w3.org/2001/XMLSchema-instance'; | ||
@@ -11,0 +11,0 @@ exports.spirit14 = obj => Object.assign((obj || {}), { |
{ | ||
"name": "duh-ipxact", | ||
"version": "0.7.4", | ||
"version": "0.7.6", | ||
"description": "IP-XACT import / export package", | ||
@@ -5,0 +5,0 @@ "author": "SiFive", |
32712
15
720