@@ -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" ;
1221import {
1322 PinInput ,
1423 PinInputGroup ,
1524 PinInputInput ,
1625} from " @/components/ui/pin-input" ;
1726import { computed , defineModel } from " vue" ;
1827import { 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" ;
2629import 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
3186const latinKeys = " qwertyuiopasdfghjklzxcvbnm" ;
3287const 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
3695const description = computed (() => {
37- return signal_stymulus .value .describe () ;
96+ return signal_stymulus .value .stimulus_type ;
3897});
3998
4099const 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
48107const 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};
60120watch (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 >
0 commit comments