Skip to content

Commit 6f25996

Browse files
committed
Готов минимальный рабочий прототип
1 parent 51adab0 commit 6f25996

10 files changed

Lines changed: 399 additions & 288 deletions

File tree

src/components/NavBar.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ watch(screen, (newValue, oldValue) => {
3636
if (ide_state.value.activeScreen !== newScr)
3737
ide_state.value.activeScreen = newScr;
3838
});
39+
40+
watch(
41+
() => ide_state.value.activeScreen,
42+
() => {
43+
screen.value = ide_state.value.activeScreen;
44+
}
45+
);
3946
</script>
4047

4148
<template>

src/components/SignalWizard.vue

Lines changed: 175 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,77 +9,141 @@ import {
99
PopoverContent,
1010
PopoverTrigger,
1111
} from "@/components/ui/popover";
12+
import {
13+
Select,
14+
SelectContent,
15+
SelectGroup,
16+
SelectItem,
17+
SelectLabel,
18+
SelectTrigger,
19+
SelectValue,
20+
} from "@/components/ui/select";
1221
import {
1322
PinInput,
1423
PinInputGroup,
1524
PinInputInput,
1625
} from "@/components/ui/pin-input";
1726
import { computed, defineModel } from "vue";
1827
import { IDEState } from "@/lib/ideState";
19-
import {
20-
Stymulus,
21-
ClockStymulus,
22-
ConstStymulus,
23-
HotkeyStymulus,
24-
} from "@/testbench_generator/stymulus";
25-
import { ref, watch } from "vue";
28+
import { ref, watch, reactive } from "vue";
2629
import TimeInput from "./TimeInput.vue";
30+
import { Time } from "@/lib/measureUnits";
31+
import {
32+
CodeGeneratorData,
33+
GeneratorStymulus,
34+
ValueType,
35+
} from "@/testbench_generator/gen";
2736
28-
const keyValue = ref<string[]>([""]);
29-
const period = ref<number>(1000000);
37+
const props = defineProps<{ modelValue: GeneratorStymulus }>();
38+
const emit = defineEmits(["update:modelValue"]);
39+
40+
const mod: any = props.modelValue;
41+
42+
const hotkey_keyValue = ref<string[]>([""]);
43+
const hotkey_initialValue = ref<ValueType>(mod.initialValue ?? "0");
44+
const const_value = ref<ValueType>(mod.value ?? "0");
45+
const clock_lowValue = ref<ValueType>(mod.low_value ?? "0");
46+
const clock_highValue = ref<ValueType>(mod.high_value ?? "1");
47+
const clock_startsWith = ref<"low_value" | "high_value">(
48+
mod.starts_with ?? "low_value"
49+
);
50+
const clock_period = ref<Time>(mod.period ?? { exponent: "ns", mantissa: 10 });
51+
const clock_dutyCycle = ref<number>(mod.duty_cycle ?? 50);
52+
53+
const allVars = computed(() => {
54+
return {
55+
hotkey_keyValue: hotkey_keyValue.value,
56+
hotkey_initialValue: hotkey_initialValue.value,
57+
const_value: const_value.value,
58+
clock_lowValue: clock_lowValue.value,
59+
clock_highValue: clock_highValue.value,
60+
clock_startsWith: clock_startsWith.value,
61+
clock_period: clock_period.value,
62+
clock_dutyCycle: clock_dutyCycle.value,
63+
};
64+
});
65+
66+
watch(allVars, () => {
67+
if (stymulusType.value === "clock") {
68+
if (signal_stymulus.value.stimulus_type === "Clock") {
69+
signal_stymulus.value.duty_cycle = clock_dutyCycle.value;
70+
signal_stymulus.value.high_value = clock_highValue.value;
71+
signal_stymulus.value.low_value = clock_lowValue.value;
72+
signal_stymulus.value.period = clock_period.value;
73+
signal_stymulus.value.starts_with = clock_startsWith.value;
74+
} else throw "Error: types unaligned";
75+
} else if (stymulusType.value === "const") {
76+
if (signal_stymulus.value.stimulus_type === "Const") {
77+
signal_stymulus.value.value = const_value.value;
78+
} else throw "Error: types unaligned";
79+
} else if (stymulusType.value === "hotkey") {
80+
if (signal_stymulus.value.stimulus_type === "HotKey") {
81+
signal_stymulus.value;
82+
} else throw "Error: types unaligned";
83+
}
84+
});
3085
3186
const latinKeys = "qwertyuiopasdfghjklzxcvbnm";
3287
const cyrillicKeys = "йцукенгшщзфывапролдячсмить";
3388
34-
const signal_stymulus = defineModel<Stymulus>();
89+
const signal_stymulus = ref<GeneratorStymulus>(props.modelValue);
90+
91+
watch(signal_stymulus, (newValue) => {
92+
emit("update:modelValue", signal_stymulus.value);
93+
});
3594
3695
const description = computed(() => {
37-
return signal_stymulus.value.describe();
96+
return signal_stymulus.value.stimulus_type;
3897
});
3998
4099
const stymulusType = ref<"clock" | "const" | "hotkey">("clock");
41-
if (signal_stymulus.value instanceof ClockStymulus)
100+
if (signal_stymulus.value.stimulus_type === "Clock")
42101
stymulusType.value = "clock";
43-
else if (signal_stymulus.value instanceof ConstStymulus)
102+
else if (signal_stymulus.value.stimulus_type === "Const")
44103
stymulusType.value = "const";
45-
else if (signal_stymulus.value instanceof HotkeyStymulus)
104+
else if (signal_stymulus.value.stimulus_type === "HotKey")
46105
stymulusType.value = "hotkey";
47106
48107
const upperKey = () => {
49-
const kv = keyValue.value[0].toLowerCase();
108+
const kv = hotkey_keyValue.value[0].toLowerCase();
50109
if ((cyrillicKeys + latinKeys).indexOf(kv) == -1) {
51-
keyValue.value[0] = "";
110+
hotkey_keyValue.value[0] = "";
52111
return;
53112
}
54113
if (cyrillicKeys.indexOf(kv) != -1) {
55-
keyValue.value[0] = latinKeys[cyrillicKeys.indexOf(kv)].toUpperCase();
114+
hotkey_keyValue.value[0] =
115+
latinKeys[cyrillicKeys.indexOf(kv)].toUpperCase();
56116
} else {
57-
keyValue.value[0] = kv.toUpperCase();
117+
hotkey_keyValue.value[0] = kv.toUpperCase();
58118
}
59119
};
60120
watch(stymulusType, (newType, oldType) => {
61121
if (oldType !== newType) {
62-
if (newType === "const") signal_stymulus.value = new ConstStymulus("0");
122+
if (newType === "const")
123+
signal_stymulus.value = {
124+
stimulus_type: "Const",
125+
value: const_value.value,
126+
nameOfTarget: props.modelValue.nameOfTarget,
127+
};
63128
else if (newType === "clock") {
64-
signal_stymulus.value = new ClockStymulus(
65-
{ mantissa: 10, exponent: "ns" },
66-
{ mantissa: 5, exponent: "ns" },
67-
{ mantissa: 1, exponent: "ns" }
68-
);
129+
signal_stymulus.value = {
130+
stimulus_type: "Clock",
131+
starts_with: clock_startsWith.value,
132+
high_value: clock_highValue.value,
133+
low_value: clock_lowValue.value,
134+
period: clock_period.value,
135+
duty_cycle: clock_dutyCycle.value,
136+
nameOfTarget: props.modelValue.nameOfTarget,
137+
};
69138
} else if (newType === "hotkey") {
70-
signal_stymulus.value = new HotkeyStymulus("0", "a");
71-
signal_stymulus.value;
139+
signal_stymulus.value = {
140+
stimulus_type: "HotKey",
141+
time_line: [],
142+
nameOfTarget: props.modelValue.nameOfTarget,
143+
};
72144
}
73145
}
74146
});
75-
76-
watch(
77-
signal_stymulus,
78-
() => {
79-
console.log("Signal stymulus updated");
80-
},
81-
{ deep: true }
82-
);
83147
</script>
84148

85149
<template>
@@ -96,15 +160,75 @@ watch(
96160
</TabsList>
97161
<TabsContent value="const">
98162
<div class="flex flex-row gap-3 items-center mt-3">
99-
<Label>0</Label>
100-
<Switch />
101-
<Label>1</Label>
163+
<Select v-model="const_value">
164+
<SelectTrigger>
165+
<SelectValue placeholder="Select an exponent" />
166+
</SelectTrigger>
167+
<SelectContent>
168+
<SelectGroup>
169+
<SelectLabel>Values</SelectLabel>
170+
<SelectItem value="0"> 0 </SelectItem>
171+
<SelectItem value="1"> 1 </SelectItem>
172+
</SelectGroup>
173+
</SelectContent>
174+
</Select>
102175
</div>
103176
</TabsContent>
104177
<TabsContent value="clock">
105178
<div class="flex flex-col gap-3">
106179
<div><h3>Parameters</h3></div>
107-
<div class="flex flex-row"><Label>Low value</Label></div>
180+
<div class="flex flex-row">
181+
<Label>Low value</Label
182+
><Select v-model="clock_lowValue">
183+
<SelectTrigger>
184+
<SelectValue placeholder="Select an exponent" />
185+
</SelectTrigger>
186+
<SelectContent>
187+
<SelectGroup>
188+
<SelectLabel>Values</SelectLabel>
189+
<SelectItem value="0"> 0 </SelectItem>
190+
<SelectItem value="1"> 1 </SelectItem>
191+
</SelectGroup>
192+
</SelectContent>
193+
</Select>
194+
</div>
195+
<div class="flex flex-row">
196+
<Label>High value</Label
197+
><Select v-model="clock_highValue">
198+
<SelectTrigger>
199+
<SelectValue placeholder="Select an exponent" />
200+
</SelectTrigger>
201+
<SelectContent>
202+
<SelectGroup>
203+
<SelectLabel>Values</SelectLabel>
204+
<SelectItem value="0"> 0 </SelectItem>
205+
<SelectItem value="1"> 1 </SelectItem>
206+
</SelectGroup>
207+
</SelectContent>
208+
</Select>
209+
</div>
210+
<div class="flex flex-row">
211+
<Label>Starts with</Label
212+
><Select v-model="clock_startsWith">
213+
<SelectTrigger>
214+
<SelectValue placeholder="Select an exponent" />
215+
</SelectTrigger>
216+
<SelectContent>
217+
<SelectGroup>
218+
<SelectLabel>Values</SelectLabel>
219+
<SelectItem value="low_value"> Low value </SelectItem>
220+
<SelectItem value="high_value"> High value </SelectItem>
221+
</SelectGroup>
222+
</SelectContent>
223+
</Select>
224+
</div>
225+
<div class="flex flex-row">
226+
<Label>Period</Label><TimeInput v-model="clock_period" />
227+
</div>
228+
<div class="flex flex-row">
229+
<Label>Duty cycle</Label><Input v-model="clock_dutyCycle" />
230+
<div>%</div>
231+
</div>
108232
</div>
109233
</TabsContent>
110234
<TabsContent value="hotkey">
@@ -113,7 +237,7 @@ watch(
113237
<span> HotKey:</span>
114238
<PinInput
115239
id="pin-input"
116-
v-model="keyValue"
240+
v-model="hotkey_keyValue"
117241
placeholder="○"
118242
@complete="upperKey">
119243
<PinInputGroup>
@@ -124,9 +248,18 @@ watch(
124248
<div class="flex flex-row gap-3 items-center">
125249
<span>Value at start:</span>
126250
<div class="flex flex-row gap-3 items-center">
127-
<Label>0</Label>
128-
<Switch />
129-
<Label>1</Label>
251+
<Select v-model="hotkey_initialValue">
252+
<SelectTrigger>
253+
<SelectValue placeholder="Select an exponent" />
254+
</SelectTrigger>
255+
<SelectContent>
256+
<SelectGroup>
257+
<SelectLabel>Values</SelectLabel>
258+
<SelectItem value="0"> 0 </SelectItem>
259+
<SelectItem value="1"> 1 </SelectItem>
260+
</SelectGroup>
261+
</SelectContent>
262+
</Select>
130263
</div>
131264
</div>
132265
</div>

src/components/TimeInput.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const value = defineModel<Time>({ required: true });
1717
const stringMantissa = ref<string>(value.value.mantissa.toString());
1818
1919
watch(stringMantissa, () => {
20-
console.log("Первий вочер");
2120
if (isValid.value) {
2221
value.value.mantissa = parseFloat(stringMantissa.value.replace(",", "."));
2322
}
@@ -26,7 +25,6 @@ watch(stringMantissa, () => {
2625
watch(
2726
value,
2827
(newValue, oldValue) => {
29-
console.log("Второй вочер");
3028
if (newValue.mantissa !== oldValue.mantissa) {
3129
stringMantissa.value = newValue.mantissa.toString();
3230
}

src/components/waveform/WfPlot.vue

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,38 @@ let leftIndex = ref(0); // Индекс последнего события, у
1111
let rightIndex = ref(props.waveformData.events.length - 1); // Индекс первого события, у которого timestamp не меньше props.scaleData.rightBorder
1212
1313
function updateIndex() {
14+
if (props.waveformData.events.length < 2) {
15+
leftIndex.value = 0;
16+
rightIndex.value = props.waveformData.events.length ? 0 : -1;
17+
return;
18+
}
1419
let newLeftIndex = leftIndex.value;
1520
let newRightIndex = rightIndex.value;
16-
while (props.waveformData[newLeftIndex] < props.scaleData.leftBorder)
21+
22+
while (
23+
props.waveformData.events[newLeftIndex].timestamp <
24+
props.scaleData.leftBorder &&
25+
newLeftIndex < props.waveformData.events.length - 1
26+
)
1727
newLeftIndex++;
18-
while (props.waveformData[newLeftIndex] > props.scaleData.leftBorder)
28+
while (
29+
props.waveformData.events[newLeftIndex].timestamp >
30+
props.scaleData.leftBorder &&
31+
newLeftIndex > 0
32+
)
1933
newLeftIndex--;
2034
21-
while (props.waveformData[newRightIndex] > props.scaleData.rightBorder)
35+
while (
36+
props.waveformData.events[newRightIndex].timestamp >
37+
props.scaleData.rightBorder &&
38+
newRightIndex > 0
39+
)
2240
newRightIndex--;
23-
while (props.waveformData[newRightIndex] < props.scaleData.rightBorder)
41+
while (
42+
props.waveformData.events[newRightIndex].timestamp <=
43+
props.scaleData.rightBorder &&
44+
newRightIndex < props.waveformData.events.length - 1
45+
)
2446
newRightIndex++;
2547
leftIndex.value = newLeftIndex;
2648
rightIndex.value = newRightIndex;
@@ -50,15 +72,20 @@ const renderData = computed<RenderDataType>(() => {
5072
const scale =
5173
props.scaleData.plotsSectionWidth /
5274
(props.scaleData.rightBorder - props.scaleData.leftBorder);
53-
for (let i = leftIndex.value; i < rightIndex.value; i++) {
54-
const prevValue = props.waveformData.events[i].value;
75+
for (let i = leftIndex.value; i <= rightIndex.value; i++) {
76+
const prevEvent = props.waveformData.events[i - 1];
5577
const value = props.waveformData.events[i].value;
5678
const leftFs = props.waveformData.events[i].timestamp;
57-
const rightFs = props.waveformData.events[i + 1].timestamp;
79+
let rightFs: number;
80+
if (i >= props.waveformData.events.length - 1) {
81+
rightFs = props.scaleData.currentSimTime;
82+
} else {
83+
rightFs = props.waveformData.events[i + 1].timestamp;
84+
}
5885
const leftX = Math.round((leftFs - props.scaleData.leftBorder) * scale);
5986
const rightX = Math.round((rightFs - props.scaleData.leftBorder) * scale);
6087
out.lines.push({ x_from: leftX, x_to: rightX, type: value });
61-
if (prevValue != undefined && prevValue!=value) {
88+
if (prevEvent != undefined && prevEvent.value != value) {
6289
out.lineChanges.push({ x_center: rightX });
6390
}
6491
const textLeftX = Math.max(leftX, 0);

0 commit comments

Comments
 (0)