Un pas de plus vers l'automatisation
Pour automatiser la réductions des quines, le programme présenté il y a quelques articles est modifié pour générer automatiquement les diverses équations réduites directement du tableau des transitions. La procédure se fait grâce à un premier programme qui transforme le tableau des transitions en autant de fichiers qu'il y a de commandes de bascules :
#!/usr/local/bin/rpl -csp
/*
* Format du fichier d'entrée :
* abcdefghia'b'c'd'j3k3j2k2j1k1j0k0
*/
TRANSITIONS
<<
{ "length*(1)" }
{ { "name" "transitions.global" } "sequential" "old"
"readonly" "flow" }
open format
0
-> F_IN NB_LIGNES
<<
while
F_IN "end of file" inquire not
repeat
""
do
F_IN read 1 get
until
if
dup "\n" same
F_IN "end of file" inquire or
then
drop true
else
+
false
end
end
if
dup "" same not
then
'NB_LIGNES' incr
else
drop
end
end
F_IN close
NB_LIGNES ->table
>>
14
-> L I
<<
{ "j3" "k3" "j2" "k2" "j1" "k1" "j0" "k0" }
forall E
{ "length*(*)" }
"name" "transitions." E +
if
dup "existence" inquire
then
{ "sequential" "replace" "readwrite" "flow" }
else
{ "sequential" "new" "readwrite" "flow" }
end
rot rot 2 ->list 1 ->list swap +
open format
-> FICHIER
<<
1 L size for K
L K 1 ->list get I dup sub
-> F
<<
if
F "0" same not
then
if
F "X" same
then
"*"
else
""
end
L K 1 ->list get 1 9 sub + "\n" +
1 ->list
FICHIER write
end
>>
next
FICHIER close
>>
'I' incr
next
>>
>>
Cette première étape est suivie par une seconde qui transforme l'écriture réduite des états en un fichier compréhensible par qmc-cli :
#!/usr/local/bin/rpl -csp
/*
* Format du fichier d'entrée :
* 010X00X
* *1111111
* *X000X01
*
* Le X correspond à une valeur indifférente. Les entiers binaires
* spécifiés doivent donner une combinaison vraie. Les lignes commençant par
* une étoile indiquent un résultat indifférent.
*/
PRINCIPAL
<<
{ "j0" "k0" "j1" "k1" "j2" "k2" "j3" "k3" }
forall I
I TRANSITIONS
next
>>
TRANSITIONS
<<
-> E
<<
{ "length*(1)" }
"name" "transitions." E + 2 ->list 1 ->list
{ "sequential" "old" "readonly" "flow" } +
open format
0
-> F_IN NB_LIGNES
<<
while
F_IN "end of file" inquire not
repeat
""
do
F_IN read 1 get
until
if
dup "\n" same
F_IN "end of file" inquire or
then
drop true
else
+
false
end
end
if
dup "" same not
then
'NB_LIGNES' incr
else
drop
end
end
F_IN close
NB_LIGNES ->list
>>
1
-> LISTE I
<<
do
LISTE I get ucase
-> E
<<
if
E "X" pos dup
then
// Il y a au moins un X
-> P
<<
{ "0" "1" } forall J
if
P 1 same
then
J E 2 over size sub +
elseif
P E size same
then
E 1 over size 1 - sub J +
else
E 1 P decr sub J +
E P incr E size sub +
end
next
LISTE swap I swap put swap
1 ->list + 'LISTE' sto
>>
else
// Pas de X, on passe au suivant
drop
'I' incr
end
>>
until
LISTE size I same
end
LISTE l->t << < >> sort
{ "length*(*)" }
"name" E ".in" +
if
dup "existence" inquire
then
{ "sequential" "replace" "flow" }
else
{ "sequential" "new" "flow" }
end
rot rot 2 ->list 1 ->list swap +
open format
-> F_OUT
<<
forall I
if
I "*" pos
then
"x" "# " I 2 over size sub + "b" + str->
b->r ->str +
else
"# " I + "b" + str-> b->r ->str
end
->str "\n" + 1 ->list F_OUT write
next
F_OUT close
>>
>>
>>
>>
À la fin de la procédure, les huit fichiers j0.in, j1.in, j2.in, j3.in, k0.in, k1.in, k2.in et k3.in sont créés. Reste à les faire passer dans la moulinette qmc-cli pour obtenir la réduction des quines.
Après réduction, les équations deviennent :
j0=q3'q2'((q1 xor i) + iC255)+q3'q2(q1'i'+iPHT)+q3'i(PBT'+q1PHT)
k0=q2'PBT
C15(q1'iPHT'+q3'q1PHT)+q3'q2i'(q1+PHT)+q3q1'(q2'+q0PBT')
+q3'q2i'PBT'
j1=q3'q2'q0'i'(PBT+PHT)+q3'q0i(PHT+C15)+q3'q2(i(PBT'+PHT')+q0PHT)
+q3q2'q1'q0'(PHT+PBTC15)+q2q1'q0PBT'
k1=q3'q2'(q1'i'+q0PBTPHTC15)+q3'q2q0i'
j2=q3'q1'(q0'i'(PBT+PHT)+q0iPHT)+q3'q1(i(PBT'+qo'PHT)
+q0(PBT'+C15))+q3q2'q1'q0'(PHT+PBTC15)+q3'q0iPBT'C15
k2=q3'q0(q1'(i+PBTPHT'C255)+q1i')
j3=q3'q0'i'(q1 xor q2)+q1'i'(q3'q2PBTPHT'C255+q2'q0)
k3=q2'q1'q0'(PHT+C15)+q2q1'q0(PBT'+C15)
Le schéma du circuit de contrôle des alimentations devient alors :
Fig. 1 : schéma de la machine à états (le même en grand)
J'ai pu tester ce circuit dans tous les sens. Il donne presque entièrement satisfaction. Tous les défauts sont bien détectés, les temporisations sont correctes pour les phases d'allumage et d'extinction. Ami lecteur, sauras-tu corriger ce circuit pour qu'il soit parfait ?
Aucun commentaire pour le moment
Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /export/home/bertrand/web/blog/b2evolution/blogs/inc/_core/_param.funcs.php on line 1407
Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /export/home/bertrand/web/blog/b2evolution/blogs/inc/_core/_param.funcs.php on line 1407
Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /export/home/bertrand/web/blog/b2evolution/blogs/inc/_core/_misc.funcs.php on line 10537
Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /export/home/bertrand/web/blog/b2evolution/blogs/inc/_core/_misc.funcs.php on line 10542
Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /export/home/bertrand/web/blog/b2evolution/blogs/inc/_core/_misc.funcs.php on line 10537
Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /export/home/bertrand/web/blog/b2evolution/blogs/inc/_core/_misc.funcs.php on line 10542