FPGA_WebLab/src/components/WaveformDisplay/index.ts

62 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import WaveformDisplay from "./WaveformDisplay.vue";
export type LogicDataType = {
x: number[];
y: {
enabled: boolean;
type: "logic" | "number";
name: string;
color: string;
value: number[];
base: "bin" | "dec" | "hex";
}[];
xUnit: "s" | "ms" | "us" | "ns";
};
// 生成4路测试数据的函数
export function generateTestData(): LogicDataType {
// 生成时间轴数据 (0-100ns每1ns一个采样点)
const timePoints = Array.from({ length: 101 }, (_, i) => i);
return {
x: timePoints,
y: [
{
enabled: true,
type: "logic",
name: "CLK",
color: "#ff0000",
value: timePoints.map((t) => t % 2), // 时钟信号每1ns翻转
base: "bin",
},
{
enabled: true,
type: "logic",
name: "RESET",
color: "#00ff00",
value: timePoints.map((t) => (t < 10 ? 1 : 0)), // 复位信号前10ns为高电平
base: "bin",
},
{
enabled: true,
type: "number",
name: "DATA",
color: "#0000ff",
value: timePoints.map((t) => Math.floor(t / 4) % 16), // 计数器每4ns递增
base: "hex",
},
{
enabled: true,
type: "logic",
name: "ENABLE",
color: "#ff8800",
value: timePoints.map((t) => (t >= 20 && t < 80 ? 1 : 0)), // 使能信号20-80ns为高电平
base: "bin",
},
],
xUnit: "ns",
};
}
export { WaveformDisplay };