diff --git a/.gitignore b/.gitignore index 67bef79..ceb6e51 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,6 @@ pnpm-debug.log* *.vcd *.view -deploy.bat \ No newline at end of file +deploy.bat +*.bin +*.zip \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 13271bc..b23721a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "d3": "^7.9.0", "element-plus": "^2.9.1", "elkjs": "^0.9.3", + "fflate": "^0.8.2", "mitt": "^3.0.1", "vue": "^3.2.13", "vue-i18n": "10.0.5", @@ -6381,6 +6382,11 @@ "node": ">=0.8.0" } }, + "node_modules/fflate": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", + "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==" + }, "node_modules/figures": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/figures/-/figures-2.0.0.tgz", diff --git a/package.json b/package.json index 7e5bea2..29fecdb 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "d3": "^7.9.0", "element-plus": "^2.9.1", "elkjs": "^0.9.3", + "fflate": "^0.8.2", "mitt": "^3.0.1", "vue": "^3.2.13", "vue-i18n": "10.0.5", diff --git a/public/index.html b/public/index.html index ee3f957..df2105d 100644 --- a/public/index.html +++ b/public/index.html @@ -15,10 +15,13 @@ diff --git a/public/test.skin b/public/test.skin new file mode 100644 index 0000000..7d8080c Binary files /dev/null and b/public/test.skin differ diff --git a/src/App.vue b/src/App.vue index 5906aeb..c9663fe 100644 --- a/src/App.vue +++ b/src/App.vue @@ -14,6 +14,7 @@ import { setDefaultCss } from './hook/css'; import { NetlistRender } from './hook/render'; import * as d3 from 'd3'; +import { globalLookup } from './hook/global'; const { t } = useI18n(); @@ -22,10 +23,14 @@ onMounted(async () => { setDefaultCss(); // 初始化载入 netlist 的 json 文件 - const [ netJson ] = await window.readNetFile(); + const [ netJson, skinBinary ] = await window.readNetFile(); - // TODO: 计算得到实际渲染的 size - const render = new NetlistRender(netJson, 800, 1000); + const render = globalLookup.netlistRender; + const skinManager = globalLookup.skinManager; + + skinManager.load(skinBinary); + + render.load(netJson); const layout = await render.createLayout(); const svg = await render.render(layout, '#netlist'); diff --git a/src/hook/global.js b/src/hook/global.js index e933a0e..7cd65c5 100644 --- a/src/hook/global.js +++ b/src/hook/global.js @@ -1,5 +1,7 @@ import mitt from 'mitt'; import { reactive } from 'vue'; +import { SkinManager } from './skin'; +import { NetlistRender } from './render'; export const emitter = mitt(); @@ -8,6 +10,18 @@ export const globalSetting = reactive({ language: 'zh' }); +export const globalLookup = { + /** + * @type {SkinManager} + */ + skinManager: new SkinManager(), + + /** + * @type {NetlistRender} + */ + netlistRender: new NetlistRender() +}; + function loadSetting() { const settingString = localStorage.getItem('setting') try { diff --git a/src/hook/render/index.js b/src/hook/render/index.js index 74e65d9..f1c1dd7 100644 --- a/src/hook/render/index.js +++ b/src/hook/render/index.js @@ -11,15 +11,7 @@ export class NetlistRender { * @param {number} renderHeight * @param {number} renderWidth */ - constructor(rawNet, renderHeight, renderWidth) { - /** - * @type {YosysRawNet} - */ - this.rawNet = rawNet; - - this.renderHeight = renderHeight; - this.renderWidth = renderWidth; - + constructor() { /** * @type {ElkGraph} */ @@ -38,14 +30,18 @@ export class NetlistRender { */ this.nameToModule = new Map(); - this.loadYosysRawNet(rawNet); } /** * @description 加载 yosys 格式的 json * @param {YosysRawNet} rawNet */ - loadYosysRawNet(rawNet) { + load(rawNet) { + /** + * @type {YosysRawNet} + */ + this.rawNet = rawNet; + // 转换为 elkjs 格式的 graph for (const [moduleName, rawModule] of Object.entries(rawNet.modules)) { const top = parseInt(rawModule.attributes.top); diff --git a/src/hook/skin/index.js b/src/hook/skin/index.js new file mode 100644 index 0000000..6a72809 --- /dev/null +++ b/src/hook/skin/index.js @@ -0,0 +1,21 @@ +import * as fflate from 'fflate'; + +export class SkinManager { + constructor() { + + } + + /** + * @description 载入加密 zip 字节 + * @param {ArrayBuffer} binary + */ + load(binary) { + const buffer = new Uint8Array(binary); + const folderTree = fflate.unzipSync(buffer); + } +} + + +/** + * @typedef + */ \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (combined)/ANDN.svg b/src/static/Gate/Combinatorial cells (combined)/ANDN.svg new file mode 100644 index 0000000..ff73416 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (combined)/ANDN.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (combined)/AOI3.svg b/src/static/Gate/Combinatorial cells (combined)/AOI3.svg new file mode 100644 index 0000000..e992516 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (combined)/AOI3.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (combined)/AOI4.svg b/src/static/Gate/Combinatorial cells (combined)/AOI4.svg new file mode 100644 index 0000000..be3e0a2 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (combined)/AOI4.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (combined)/MUX4.svg b/src/static/Gate/Combinatorial cells (combined)/MUX4.svg new file mode 100644 index 0000000..171d818 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (combined)/MUX4.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (combined)/MUX8.svg b/src/static/Gate/Combinatorial cells (combined)/MUX8.svg new file mode 100644 index 0000000..c01df52 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (combined)/MUX8.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (combined)/NMUX.svg b/src/static/Gate/Combinatorial cells (combined)/NMUX.svg new file mode 100644 index 0000000..7b10093 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (combined)/NMUX.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (combined)/OAI3.svg b/src/static/Gate/Combinatorial cells (combined)/OAI3.svg new file mode 100644 index 0000000..7a6cd02 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (combined)/OAI3.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (combined)/OAI4.svg b/src/static/Gate/Combinatorial cells (combined)/OAI4.svg new file mode 100644 index 0000000..653a86c --- /dev/null +++ b/src/static/Gate/Combinatorial cells (combined)/OAI4.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (combined)/ORN.svg b/src/static/Gate/Combinatorial cells (combined)/ORN.svg new file mode 100644 index 0000000..873ea25 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (combined)/ORN.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/$XOR.svg b/src/static/Gate/Combinatorial cells (simple)/$XOR.svg new file mode 100644 index 0000000..4b16ed1 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/$XOR.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/$_AND_.svg b/src/static/Gate/Combinatorial cells (simple)/$_AND_.svg new file mode 100644 index 0000000..170a234 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/$_AND_.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/$_BUF_.svg b/src/static/Gate/Combinatorial cells (simple)/$_BUF_.svg new file mode 100644 index 0000000..567a8b3 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/$_BUF_.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/$_MUX_.svg b/src/static/Gate/Combinatorial cells (simple)/$_MUX_.svg new file mode 100644 index 0000000..10e32de --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/$_MUX_.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/$_NAND_.svg b/src/static/Gate/Combinatorial cells (simple)/$_NAND_.svg new file mode 100644 index 0000000..e2321f7 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/$_NAND_.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/$_NOR_.svg b/src/static/Gate/Combinatorial cells (simple)/$_NOR_.svg new file mode 100644 index 0000000..01aefbe --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/$_NOR_.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/$_NOT_.svg b/src/static/Gate/Combinatorial cells (simple)/$_NOT_.svg new file mode 100644 index 0000000..c54e8ca --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/$_NOT_.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/$_OR_.svg b/src/static/Gate/Combinatorial cells (simple)/$_OR_.svg new file mode 100644 index 0000000..c667a82 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/$_OR_.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/$_XNOR_.svg b/src/static/Gate/Combinatorial cells (simple)/$_XNOR_.svg new file mode 100644 index 0000000..7b34701 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/$_XNOR_.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/static/Gate/Combinatorial cells (simple)/TBUF.svg b/src/static/Gate/Combinatorial cells (simple)/TBUF.svg new file mode 100644 index 0000000..53ee7d2 --- /dev/null +++ b/src/static/Gate/Combinatorial cells (simple)/TBUF.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file