Skip to content

Commit 1636d98

Browse files
committed
correction bug lab 1 et 3
1 parent 8c34cf1 commit 1636d98

File tree

1 file changed

+61
-26
lines changed

1 file changed

+61
-26
lines changed

menus.py

Lines changed: 61 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -800,22 +800,22 @@ def decodeFunc(self,inVar, funcName):
800800
D1 = inVar[1]["val"]
801801
D2 = inVar[0]["val"]
802802
D3 = inVar[0]["val"]
803-
sT = f"T{self.varTempNum} = {CE} & {iL} & !T{self.varTempNum}_precedant + !{iL} & {D0} + !{CE} & {iL} & T{self.varTempNum}_precedant; "
803+
sT = f"T{self.varTempNum} = clk & {CE} & {iL} & !T{self.varTempNum}_precedant | !{iL} & {D0} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedant; "
804804
self.numTemp += [self.varTempNum]
805805
self.varTempNum +=1
806806
self.varScript += [sT]
807807
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-1}_precedant | !T{self.varTempNum}_precedant) & " \
808-
+ f"({CE} & T{self.varTempNum - 1}_precedant + T{self.varTempNum}_precedant ) & {iL} + !{iL} & {D1} + !{CE} & {iL} & T{self.varTempNum}_precedant; "
808+
+ f"({CE} & T{self.varTempNum - 1}_precedant | T{self.varTempNum}_precedant ) & {iL} & clk | !{iL} & {D1} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedant; "
809809
self.numTemp += [self.varTempNum]
810810
self.varTempNum +=1
811811
self.varScript += [sT]
812-
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-2}_precedant | !T{self.varTempNum-1}_precedant | !T{self.varTempNum}_precedant) & " \
813-
+ f"({CE} & T{self.varTempNum - 2}_precedant & T{self.varTempNum - 1}_precedant + T{self.varTempNum}_precedant ) & {iL} + !{iL} & {D2} + !{CE} & {iL} & T{self.varTempNum}_precedant; "
812+
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-2}_precedant | !T{self.varTempNum-1}_precedant | !T{self.varTempNum}_precedant) & clk & " \
813+
+ f"({CE} & T{self.varTempNum - 2}_precedant & T{self.varTempNum - 1}_precedant | T{self.varTempNum}_precedant ) & {iL} & clk | !{iL} & {D2} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedant; "
814814
self.numTemp += [self.varTempNum]
815815
self.varTempNum +=1
816816
self.varScript += [sT]
817817
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-3}_precedant | !T{self.varTempNum-2}_precedant | !T{self.varTempNum-1}_precedant | !T{self.varTempNum}_precedant) & " \
818-
+ f"({CE} & T{self.varTempNum - 3}_precedant & T{self.varTempNum - 2}_precedant & T{self.varTempNum - 1}_precedant + T{self.varTempNum}_precedant ) & {iL} + !{iL} & {D3} + !{CE} & {iL} & T{self.varTempNum}_precedant; "
818+
+ f"({CE} & T{self.varTempNum - 3}_precedant & T{self.varTempNum - 2}_precedant & T{self.varTempNum - 1}_precedant | T{self.varTempNum}_precedant ) & {iL} & clk | !{iL} & {D3} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedant; "
819819
self.numTemp += [self.varTempNum]
820820
self.varTempNum +=1
821821
self.varScript += [sT]
@@ -853,88 +853,118 @@ def checkCloseCircuit(self, ioOut, params={}):
853853
idOut, inLst, fName, outLst = deepcopy(f)
854854
if chip_select:
855855
chipSel = chip_select
856-
[chipSel] = [list(chipS[1:]) for chipS in chipSel if chipS[0] == idOut]
856+
chipSel = [list(chipS[1:]) for chipS in chipSel if chipS[0] == idOut]
857+
if chipSel:
858+
[chipSel] = chipSel
857859
else: chipSel = []
858860

859861
if chip_in_enable_inv:
860862
chipEnInv = chip_in_enable_inv
861-
[chipEnInv] = [list(chipEI[1:]) for chipEI in chipEnInv if chipEI[0] == idOut]
863+
chipEnInv = [list(chipEI[1:]) for chipEI in chipEnInv if chipEI[0] == idOut]
864+
if chipEnInv:
865+
[chipEnInv] = chipEnInv
862866
else: chipEnInv = []
863867

864868
if chip_in_enable:
865869
chipEn = chip_in_enable
866-
[chipEn] = [list(chipE[1:]) for chipE in chipEn if chipE[0] == idOut]
870+
chipEn = [list(chipE[1:]) for chipE in chipEn if chipE[0] == idOut]
871+
if chipEn:
872+
[chipEn] = chipEn
867873
else: chipEn = []
868874

869875
if chip_in_clock:
870876
chipInClock = chip_in_clock
871-
[chipInClock] = [list(chipICLK[1:]) for chipICLK in chipInClock if chipICLK[0] == idOut]
877+
chipInClock = [list(chipICLK[1:]) for chipICLK in chipInClock if chipICLK[0] == idOut]
878+
if chipInClock:
879+
[chipInClock] =chipInClock
872880
chipInClock = [(c1,l1) for (c1,l1,nfunc) in chipInClock if nfunc == nf]
873881
else: chipInClock = []
874882

875883
if chip_in_inv_reset:
876884
chipInInvReset = chip_in_inv_reset
877-
[chipInInvReset] = [list(chipInInvR[1:]) for chipInInvR in chipInInvReset if chipInInvR[0] == idOut]
885+
chipInInvReset = [list(chipInInvR[1:]) for chipInInvR in chipInInvReset if chipInInvR[0] == idOut]
886+
if chipInInvReset:
887+
[chipInInvReset] = chipInInvReset
878888
chipInInvReset = [(c1,l1) for (c1,l1,nfunc) in chipInInvReset if nfunc == nf]
879889
else: chipInInvReset = []
880890

881891
if chip_in_inv_set:
882892
chipInInvSet = chip_in_inv_set
883-
[chipInInvSet] = [list(chipInInvS[1:]) for chipInInvS in chipInInvSet if chipInInvS[0] == idOut]
893+
chipInInvSet = [list(chipInInvS[1:]) for chipInInvS in chipInInvSet if chipInInvS[0] == idOut]
894+
if chipInInvSet:
895+
[chipInInvSet] = chipInInvSet
884896
chipInInvSet = [(c1,l1) for (c1,l1,nfunc) in chipInInvSet if nfunc == nf]
885897
else: chipInInvSet = []
886898

887899
if chip_in_inv_clock:
888900
chipInInvClk = chip_in_inv_clock
889-
[chipInInvClk] = [list(chipInIClk[1:]) for chipInIClk in chipInInvClk if chipInIClk[0] == idOut]
901+
chipInInvClk = [list(chipInIClk[1:]) for chipInIClk in chipInInvClk if chipInIClk[0] == idOut]
902+
if chipInInvClk:
903+
[chipInInvClk] = chipInInvClk
890904
chipInInvClk = [(c1,l1) for (c1,l1,nfunc) in chipInInvClk if nfunc == nf]
891905
else: chipInInvClk = []
892906

893907
if chip_in_j:
894908
chipInJ = chip_in_j
895-
[chipInJ] = [list(chipIIJ[1:]) for chipIIJ in chipInJ if chipIIJ[0] == idOut]
909+
chipInJ = [list(chipIJ[1:]) for chipIJ in chipInJ if chipIJ[0] == idOut]
910+
if chipInJ:
911+
[chipInJ] = chipInJ
896912
chipInJ = [(c1,l1) for (c1,l1,nfunc) in chipInJ if nfunc == nf]
897913
else: chipInJ = []
898914

899915
if chip_in_k:
900916
chipInK = chip_in_k
901-
[chipInK] = [list(chipIK[1:]) for chipIK in chipInK if chipIK[0] == idOut]
917+
chipInK = [list(chipIK[1:]) for chipIK in chipInK if chipIK[0] == idOut]
918+
if chipInK:
919+
[chipInK] = chipInK
902920
chipInK = [(c1,l1) for (c1,l1,nfunc) in chipInK if nfunc == nf]
903921
else: chipInK = []
904922

905923
if chip_in_inv_k:
906924
chipInInvK = chip_in_inv_k
907-
[chipInInvK] = [list(chipIIK[1:]) for chipIIK in chipInInvK if chipIIK[0] == idOut]
925+
chipInInvK = [list(chipIIK[1:]) for chipIIK in chipInInvK if chipIIK[0] == idOut]
926+
if chipInInvK:
927+
[chipInInvK] = chipInInvK
908928
chipInInvK = [(c1,l1) for (c1,l1,nfunc) in chipInInvK if nfunc == nf]
909929
else: chipInInvK = []
910930

911931
if chip_in_ce:
912932
chipInCE = chip_in_ce
913-
[chipInCE] = [list(chipICE[1:]) for chipICE in chipInCE if chipICE[0] == idOut]
933+
chipInCE = [list(chipICE[1:]) for chipICE in chipInCE if chipICE[0] == idOut]
934+
if chipInCE:
935+
[chipInCE] = chipInCE
914936
chipInCE = [(c1,l1) for (c1,l1,nfunc) in chipInCE if nfunc == nf]
915937
else: chipInCE = []
916938

917939
if chip_in_inv_L:
918940
chipInInvL = chip_in_inv_L
919-
[chipInInvL] = [list(chipIIL[1:]) for chipIIL in chipInInvL if chipIIL[0] == idOut]
941+
chipInInvL = [list(chipIIL[1:]) for chipIIL in chipInInvL if chipIIL[0] == idOut]
942+
if chipInInvL:
943+
[chipInInvL] = chipInInvL
920944
chipInInvL = [(c1,l1) for (c1,l1,nfunc) in chipInInvL if nfunc == nf]
921945
else: chipInInvL = []
922946

923947
if chip_in_inv_U:
924948
chipInInvU = chip_in_inv_U
925-
[chipInInvU] = [list(chipIIU[1:]) for chipIIU in chipInInvU if chipIIU[0] == idOut]
949+
chipInInvU = [list(chipIIU[1:]) for chipIIU in chipInInvU if chipIIU[0] == idOut]
950+
if chipInInvU:
951+
[chipInInvU] = chipInInvU
926952
chipInInvU = [(c1,l1) for (c1,l1,nfunc) in chipInInvU if nfunc == nf]
927953
else: chipInInvU = []
928954

929955
if chip_out_TC:
930956
chipOutTC = chip_out_TC
931-
[chipOutTC] = [list(chipOTC[1:]) for chipOTC in chipOutTC if chipOTC[0] == idOut]
957+
chipOutTC = [list(chipOTC[1:]) for chipOTC in chipOutTC if chipOTC[0] == idOut]
958+
if chipOutTC:
959+
[chipOutTC] = chipOutTC
932960
chipOutTC = [(c1,l1) for (c1,l1,nfunc) in chipOutTC if nfunc == nf]
933961
else: chipOutTC = []
934962

935963
if chip_out_inv:
936964
chipOutInv = chip_out_inv
937-
[chipOutInv] = [list(chipOI[1:]) for chipOI in chipOutInv if chipOI[0] == idOut]
965+
chipOutInv = [list(chipOI[1:]) for chipOI in chipOutInv if chipOI[0] == idOut]
966+
if chipOutInv:
967+
[chipOutInv] = chipOutInv
938968
else: chipOutInv = []
939969

940970
inLst += chipSel + chipEnInv + chipEn + chipInClock + chipInInvReset + chipInInvSet + \
@@ -999,7 +1029,7 @@ def checkCloseCircuit(self, ioOut, params={}):
9991029
findIn = True
10001030
print("connecté à pwr")
10011031
if not findIn:
1002-
for io_inZone in self.io_in:
1032+
for n_io,io_inZone in enumerate(self.io_in):
10031033
id, [zone] = io_inZone
10041034
if self.is_linked_to(zone, inFunc):
10051035
constKey = 'val'
@@ -1046,12 +1076,12 @@ def checkCloseCircuit(self, ioOut, params={}):
10461076
constKey = "iU"
10471077

10481078
#inFuncConst += [{constKey:self.mcu_pin[f"I{id[4:]}"], "num":n, "numO":no}] # [self.mcu_pin[f"I{id[4:]}"]] # ici ajouter n
1049-
inFuncConst += [{constKey:f"I{n+1}", "num":n, "numO":no}] # [self.mcu_pin[f"I{id[4:]}"]] # ici ajouter n
1079+
inFuncConst += [{constKey:f"I{n_io+1}", "num":n_io, "numO":no}] # [self.mcu_pin[f"I{id[4:]}"]] # ici ajouter n
10501080
findIn = True
10511081
print("connecté à une ENTRÉE EXTERNE")
10521082
break
10531083
if not findIn:
1054-
for io_chipInZone in self.chip_in_wire:
1084+
for n_io, io_chipInZone in enumerate(self.chip_in_wire):
10551085
id, zone = io_chipInZone
10561086
if self.is_linked_to(zone, inFunc):
10571087
constKey = 'val'
@@ -1098,7 +1128,7 @@ def checkCloseCircuit(self, ioOut, params={}):
10981128
constKey = "iU"
10991129

11001130
#inFuncConst += [{constKey:self.mcu_pin[f"I{id[4:]}"], "num":n, "numO":no}]
1101-
inFuncConst += [{constKey:f"I{n+1}", "num":n, "numO":no}]
1131+
inFuncConst += [{constKey:f"I{n_io+1}", "num":n_io, "numO":no}]
11021132
findIn = True
11031133
print("connecté à une ENTRÉE EXTERNE par cable") # ici ajouter n {'val':self.mcu_pin[f"I{id[4:]}"], "num":n}
11041134
break
@@ -1628,7 +1658,9 @@ def checkCircuit(self):
16281658
ciw += deepcopy(self.board.sketcher.matrix[f"{cu1},{lu1}"]["link"])
16291659
self.wireNotUsed.remove(wused)
16301660
again = True
1631-
self.chip_in_wire += [(ioin[0], ciw)]
1661+
elt = (ioin[0], ciw)
1662+
if not elt in self.chip_in_wire:
1663+
self.chip_in_wire += [elt]
16321664

16331665
############### Verification des self.chip_out sur chip_out #####################
16341666
for chipAllio in self.chip_out:
@@ -1652,11 +1684,14 @@ def checkCircuit(self):
16521684
cow += deepcopy(self.board.sketcher.matrix[f"{cu2},{lu2}"]["link"])
16531685
self.wireNotUsed.remove(wused)
16541686
again = True
1687+
if not cow in self.chip_out_wire:
1688+
self.chip_out_wire += [cow]
16551689
elif self.is_linked_to(cow, (cu2, lu2)):
16561690
cow += deepcopy(self.board.sketcher.matrix[f"{cu1},{lu1}"]["link"])
16571691
self.wireNotUsed.remove(wused)
16581692
again = True
1659-
self.chip_out_wire += [cow]
1693+
if not cow in self.chip_out_wire:
1694+
self.chip_out_wire += [cow]
16601695

16611696
################# Redefinir les zones des io_out avec les cables non utilisés ##############
16621697
for n,ioOut in enumerate(self.io_out):

0 commit comments

Comments
 (0)