@@ -138,7 +138,7 @@ def __init__(
138138
139139 self .script = ""
140140
141- self .selected_microcontroller = None
141+ self .selected_microcontroller = "Arduino Mega"
142142 """The selected microcontroller."""
143143
144144 self .menu_bar = tk .Frame (parent , bg = "#333333" )
@@ -178,7 +178,7 @@ def __init__(
178178 # Display selected microcontroller label
179179 self .microcontroller_label = tk .Label (
180180 self .menu_bar ,
181- text = "(Aucun microcontrôleur n'est choisi)" ,
181+ text = "(Aucun microcontrôleur n'est choisi)" if not self . selected_microcontroller else self . selected_microcontroller ,
182182 bg = "#333333" ,
183183 fg = "white" ,
184184 font = ("FiraCode-Bold" , 12 ),
@@ -757,12 +757,27 @@ def decodeFunc(self,inVar, funcName):
757757 s += inVar [0 ]['val' ] + " & CLK & " + inVar [3 ]["iset" ] + " & " + inVar [2 ]["irst" ] + " | !" + inVar [3 ]["iset" ]
758758 s += " ) "
759759 elif funcName == "JKFlipFlop" :
760- s = "("
761- s += inVar [0 ]['val' ] + " & CLK & " + inVar [3 ]["iset" ] + " & " + inVar [2 ]["irst" ] + " | !" + inVar [3 ]["iset" ]
762- s += " ) "
760+ if inVar [4 ].get ("iK" ):
761+ K = f"!{ inVar [4 ]["iK" ]} "
762+ else : K = inVar [4 ]["K" ]
763+ if inVar [1 ].get ("clk" ):
764+ CLK = f"{ inVar [1 ]["clk" ]} "
765+ else : CLK = f"!{ inVar [3 ]["iclk" ]} "
766+ if inVar [3 ].get ("iset" ):
767+ iSet = f"{ inVar [3 ]["iset" ]} "
768+ iRst = f"{ inVar [2 ]["irst" ]} "
769+ else :
770+ iSet = f"!{ inVar [2 ]["iset" ]} "
771+ iRst = f"{ inVar [1 ]["irst" ]} "
772+ sT = f"T{ self .varTempNum } = "
773+ sT += "((" + inVar [0 ]['J' ] + f" & T{ self .varTempNum } _precedant) | (!{ K } & t{ self .varTempNum } _precedant)) & !{ iSet } & !{ iRst } & CLK | !{ iSet } "
774+ sT += " ); "
775+ s = inVar [0 ]["numO" ]* " !" + f"T{ self .varTempNum } "
776+ self .varTempNum += 1
777+ self .varScript += [sT ]
763778
764779
765- return s
780+ return s
766781
767782 def checkCloseCircuit (self , ioOut , params = {}):
768783 #id, (c1,l1,c2,l2) = ioOut
@@ -1137,6 +1152,8 @@ def checkCircuit(self):
11371152 chip_in_j = []
11381153 chip_in_k = []
11391154 chip_in_inv_k = []
1155+ self .varTempNum = 1
1156+ self .varScript = []
11401157
11411158 self .show_correspondence_table (False )
11421159 for id , component in self .current_dict_circuit .items ():
@@ -1240,8 +1257,8 @@ def checkCircuit(self):
12401257 for (n ,numPin ) in sum (ioInClockInv ,[])
12411258 ]
12421259 if ioInCLKInv :
1243- chip_in_inv_clock += [(id , * ioInCLK )]
1244- self .chip_in += [(id , * ioInCLK )]
1260+ chip_in_inv_clock += [(id , * ioInCLKInv )]
1261+ self .chip_in += [(id , * ioInCLKInv )]
12451262
12461263 #### l' entrée Reset Inv ###
12471264 ioInResetInv = component .get ("inv_reset_pin" , [])
@@ -1507,10 +1524,14 @@ def checkCircuit(self):
15071524 # "chip_in_address_pins":chip_in_address_pins}
15081525 for no ,ioOut in enumerate (self .io_out ):
15091526 #self.script += self.mcu_pin[f"O{ioOut[0][4:]}"] + " = " # f"O{no+1}"
1510- self . script += f"O { no + 1 } " + " = "
1527+
15111528 circuitClose , script = self .checkCloseCircuit (ioOut ,params )
15121529 if circuitClose :
15131530 print (f"le circuit est fermée sur la sortie { ioOut } " )
1531+ for s in self .varScript :
1532+ self .script += s
1533+ self .varScript = []
1534+ self .script += f"O{ no + 1 } " + " = "
15141535 self .script += f"{ script } ; "
15151536 print (f"script temp : { self .script } " )
15161537 else : print (f"le circuit est ouvert sur la sortie { ioOut } " )
0 commit comments