修复默认不是 16 进制渲染格式的问题 | 修复有符号数字计算错误的问题 | 给高位宽的数字加上前缀 0
This commit is contained in:
parent
3834ffe02c
commit
5aac2f15c4
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,5 +22,6 @@ pnpm-debug.log*
|
|||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
*.vcd
|
*.vcd
|
||||||
|
*.view
|
||||||
|
|
||||||
deploy.bat
|
deploy.bat
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.readVcdFile = async () => {
|
window.readVcdFile = async () => {
|
||||||
let inputVcdFile = 'test.vcd';
|
let inputVcdFile = 'movAvg.vcd';
|
||||||
let inputViewFile = 'test.view';
|
let inputViewFile = 'movAvg.view';
|
||||||
const response = await fetch(inputVcdFile);
|
const response = await fetch(inputVcdFile);
|
||||||
const arrayBuffer = await response.arrayBuffer();
|
const arrayBuffer = await response.arrayBuffer();
|
||||||
return [arrayBuffer, inputVcdFile, inputViewFile];
|
return [arrayBuffer, inputVcdFile, inputViewFile];
|
||||||
|
BIN
public/test.view
BIN
public/test.view
Binary file not shown.
@ -55,24 +55,28 @@ function getVecRenderModal(link) {
|
|||||||
function addVecRenderItem(link) {
|
function addVecRenderItem(link) {
|
||||||
const link2CurrentWires = globalLookup.link2CurrentWires;
|
const link2CurrentWires = globalLookup.link2CurrentWires;
|
||||||
const modal = getVecRenderModal(link);
|
const modal = getVecRenderModal(link);
|
||||||
|
|
||||||
if (modal === 0) {
|
if (modal === 0) {
|
||||||
const signal = link2CurrentWires.get(link);
|
const signal = link2CurrentWires.get(link);
|
||||||
return {
|
return {
|
||||||
name: signal.name,
|
name: signal.name,
|
||||||
kind: signal.kind,
|
kind: signal.kind,
|
||||||
ref: signal.link
|
ref: signal.link,
|
||||||
|
width: signal.size
|
||||||
}
|
}
|
||||||
} else if (modal === 1) {
|
} else if (modal === 1) {
|
||||||
return {
|
return {
|
||||||
name: '',
|
name: '',
|
||||||
kind: '',
|
kind: '',
|
||||||
ref: ''
|
ref: '',
|
||||||
|
width: 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
name: '',
|
name: '',
|
||||||
kind: '',
|
kind: '',
|
||||||
ref: ''
|
ref: '',
|
||||||
|
width: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +105,8 @@ function* renderValues(desc, pstate) {
|
|||||||
renderSignals.push({
|
renderSignals.push({
|
||||||
name: '',
|
name: '',
|
||||||
kind: '',
|
kind: '',
|
||||||
ref: ''
|
ref: '',
|
||||||
|
width: 1
|
||||||
});
|
});
|
||||||
// 如果没有关闭,把所有子节点加入其中
|
// 如果没有关闭,把所有子节点加入其中
|
||||||
if (view.groupInfo.collapse === false) {
|
if (view.groupInfo.collapse === false) {
|
||||||
@ -172,11 +177,13 @@ function* renderValues(desc, pstate) {
|
|||||||
const xCur = getX(pstate, tCur);
|
const xCur = getX(pstate, tCur);
|
||||||
|
|
||||||
if (vPre !== undefined || mPre !== undefined) {
|
if (vPre !== undefined || mPre !== undefined) {
|
||||||
if (xPre > width && xCur > width) { // both time stamps to the right
|
if (xPre > width && xCur > width) {
|
||||||
|
// both time stamps to the right
|
||||||
break perLane;
|
break perLane;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((xPre < sidebarWidth) && (xCur < sidebarWidth))) { // both time stamps to the left
|
if (!((xPre < sidebarWidth) && (xCur < sidebarWidth))) {
|
||||||
|
// both time stamps to the left
|
||||||
const xPreNorm = ((xPre > sidebarWidth) ? xPre : sidebarWidth) | 0;
|
const xPreNorm = ((xPre > sidebarWidth) ? xPre : sidebarWidth) | 0;
|
||||||
const xCurNorm = ((xCur < width) ? xCur : width) | 0;
|
const xCurNorm = ((xCur < width) ? xCur : width) | 0;
|
||||||
const w = xCurNorm - xPreNorm;
|
const w = xCurNorm - xPreNorm;
|
||||||
|
@ -14,7 +14,8 @@ function getValueFormatCode(link) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
// 默认 16 进制
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,7 +137,29 @@ export class FormatValueRender {
|
|||||||
|
|
||||||
|
|
||||||
// 无符号的各类进制数字
|
// 无符号的各类进制数字
|
||||||
const valueString = value.toString(radix);
|
let valueString = value.toString(radix);
|
||||||
|
// 如果是 2, 8, 16 进制,需要根据宽度自动完全前面的 0 的填充
|
||||||
|
let displayWidth, padding;
|
||||||
|
switch (radix) {
|
||||||
|
case 2:
|
||||||
|
displayWidth = Number(width);
|
||||||
|
padding = "0".repeat(displayWidth - valueString.length);
|
||||||
|
valueString = padding + valueString;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
displayWidth = Math.ceil(Number(width) / 3);
|
||||||
|
padding = "0".repeat(displayWidth - valueString.length);
|
||||||
|
valueString = padding + valueString;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
displayWidth = Math.ceil(Number(width) / 4);
|
||||||
|
padding = "0".repeat(displayWidth - valueString.length);
|
||||||
|
valueString = padding + valueString;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (pos === -1 || valueString.length <= pos) {
|
if (pos === -1 || valueString.length <= pos) {
|
||||||
return valueString;
|
return valueString;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user