解决没有考虑 gcd 导致跳转异常的问题
This commit is contained in:
parent
de7600a578
commit
802f95ab0a
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.readVcdFile = async () => {
|
window.readVcdFile = async () => {
|
||||||
const response = await fetch('test.vcd');
|
const response = await fetch('FFT_IFFT.vcd');
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
BIN
public/vcd.wasm
BIN
public/vcd.wasm
Binary file not shown.
@ -52,8 +52,6 @@ function onMousedown() {
|
|||||||
updateWireCurrentValue();
|
updateWireCurrentValue();
|
||||||
changeCursorLocation();
|
changeCursorLocation();
|
||||||
|
|
||||||
console.log(MovingPivot);
|
|
||||||
|
|
||||||
// 关闭所有
|
// 关闭所有
|
||||||
for (const id of UserPivotCtxShows.keys()) {
|
for (const id of UserPivotCtxShows.keys()) {
|
||||||
UserPivotCtxShows.set(id, false);
|
UserPivotCtxShows.set(id, false);
|
||||||
|
@ -46,8 +46,9 @@ export function toBegin() {
|
|||||||
|
|
||||||
export function toEnd() {
|
export function toEnd() {
|
||||||
const pstate = globalLookup.pstate;
|
const pstate = globalLookup.pstate;
|
||||||
|
const gcd = globalLookup.tgcd || 1;
|
||||||
if (pstate) {
|
if (pstate) {
|
||||||
moveto(globalLookup.time, pstate.width - pstate.sidebarWidth, pstate);
|
moveto(globalLookup.time * gcd, pstate.width - pstate.sidebarWidth, pstate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +65,7 @@ function clip(v, min, max) {
|
|||||||
export function toPrevChange() {
|
export function toPrevChange() {
|
||||||
const link = sidebarSelectedWires.lastLink;
|
const link = sidebarSelectedWires.lastLink;
|
||||||
const pstate = globalLookup.pstate;
|
const pstate = globalLookup.pstate;
|
||||||
|
const gcd = globalLookup.tgcd || 1;
|
||||||
|
|
||||||
if (link === undefined || pstate === undefined) {
|
if (link === undefined || pstate === undefined) {
|
||||||
return;
|
return;
|
||||||
@ -81,13 +83,15 @@ export function toPrevChange() {
|
|||||||
let pivot = bisearch(wave, currentT);
|
let pivot = bisearch(wave, currentT);
|
||||||
|
|
||||||
const pwave = wave[pivot];
|
const pwave = wave[pivot];
|
||||||
if (pwave[0] === currentT) {
|
if (pwave[0] * gcd === currentT) {
|
||||||
pivot = clip(pivot - 1, 0, wave.length - 1);
|
pivot = clip(pivot - 1, 0, wave.length - 1);
|
||||||
} else {
|
} else {
|
||||||
pivot = clip(pivot, 0, wave.length - 1);
|
pivot = clip(pivot, 0, wave.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetT = wave[pivot][0];
|
console.log(pivot, wave.length);
|
||||||
|
|
||||||
|
const targetT = wave[pivot][0] * gcd;
|
||||||
moveto(targetT, (pstate.width + pstate.sidebarWidth) / 2, pstate);
|
moveto(targetT, (pstate.width + pstate.sidebarWidth) / 2, pstate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,6 +101,7 @@ export function toPrevChange() {
|
|||||||
export function toNextChange() {
|
export function toNextChange() {
|
||||||
const link = sidebarSelectedWires.lastLink;
|
const link = sidebarSelectedWires.lastLink;
|
||||||
const pstate = globalLookup.pstate;
|
const pstate = globalLookup.pstate;
|
||||||
|
const gcd = globalLookup.tgcd || 1;
|
||||||
|
|
||||||
if (link === undefined || pstate === undefined) {
|
if (link === undefined || pstate === undefined) {
|
||||||
return;
|
return;
|
||||||
@ -115,10 +120,10 @@ export function toNextChange() {
|
|||||||
let targetT;
|
let targetT;
|
||||||
if (pivot === wave.length - 1) {
|
if (pivot === wave.length - 1) {
|
||||||
pivot = clip(pivot + 1, 0, wave.length - 1);
|
pivot = clip(pivot + 1, 0, wave.length - 1);
|
||||||
targetT = globalLookup.time;
|
targetT = globalLookup.time * gcd;
|
||||||
} else {
|
} else {
|
||||||
pivot = clip(pivot + 1, 0, wave.length - 1);
|
pivot = clip(pivot + 1, 0, wave.length - 1);
|
||||||
targetT = wave[pivot][0];
|
targetT = wave[pivot][0] * gcd;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveto(targetT, (pstate.width + pstate.sidebarWidth) / 2, pstate);
|
moveto(targetT, (pstate.width + pstate.sidebarWidth) / 2, pstate);
|
||||||
@ -157,8 +162,11 @@ export function clearAllPivot() {
|
|||||||
* @return {number}
|
* @return {number}
|
||||||
*/
|
*/
|
||||||
export function bisearch(wave, time) {
|
export function bisearch(wave, time) {
|
||||||
|
const gcd = globalLookup.tgcd || 1;
|
||||||
const times = wave.map(p => p[0]);
|
const times = wave.map(p => p[0]);
|
||||||
|
|
||||||
|
time = time / gcd;
|
||||||
|
|
||||||
// 二分查找,并将结果存入 i
|
// 二分查找,并将结果存入 i
|
||||||
let i = 0, j = wave.length - 1;
|
let i = 0, j = wave.length - 1;
|
||||||
while (i < j) {
|
while (i < j) {
|
||||||
|
@ -167,6 +167,9 @@ async function updateWireCurrentValue(time) {
|
|||||||
time = globalLookup.currentTime;
|
time = globalLookup.currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gcd = globalLookup.tgcd || 1;
|
||||||
|
time = time / gcd;
|
||||||
|
|
||||||
const currentSignalValues = globalLookup.currentSignalValues;
|
const currentSignalValues = globalLookup.currentSignalValues;
|
||||||
|
|
||||||
for (const signal of globalLookup.currentWires) {
|
for (const signal of globalLookup.currentWires) {
|
||||||
|
@ -498,12 +498,9 @@ class WebGL2WaveRender {
|
|||||||
if (signal.size === 1) {
|
if (signal.size === 1) {
|
||||||
// 如果是 bit
|
// 如果是 bit
|
||||||
gl.uniform2fv(webglLocation.widthShifts, gl_WidthShifts);
|
gl.uniform2fv(webglLocation.widthShifts, gl_WidthShifts);
|
||||||
|
|
||||||
|
|
||||||
gl.uniform2fv(webglLocation.shifts, gl_Shifts);
|
gl.uniform2fv(webglLocation.shifts, gl_Shifts);
|
||||||
gl.bindVertexArray(signalItem.lineVao);
|
gl.bindVertexArray(signalItem.lineVao);
|
||||||
gl.drawArrays(gl.TRIANGLE_STRIP, 0, lineVertices.length / glslInputLength);
|
gl.drawArrays(gl.TRIANGLE_STRIP, 0, lineVertices.length / glslInputLength);
|
||||||
|
|
||||||
gl.bindVertexArray(signalItem.maskVao);
|
gl.bindVertexArray(signalItem.maskVao);
|
||||||
gl.drawArrays(gl.TRIANGLES, 0, maskVertices.length / glslInputLength);
|
gl.drawArrays(gl.TRIANGLES, 0, maskVertices.length / glslInputLength);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user