ClearAll["Global`*"]

Needs["FiniteFields`"]

ElementToPolynomial[0,x]:=0;
AllElements[F_]:=Table[FromElementCode[F,j],{j,0,FieldSize[F]-1}]

PrimitiveElements[F_]:=Module[
{q=FieldSize[F]},
Map[FromElementCode[F,#]&,Select[Range[q-1],Complement[Range[q-1],Table[ToElementCode[((FromElementCode[F,#])^α)],{α,1,q-1}]]=={}&]]
]
FirstPrimitiveElement[F_]:=PrimitiveElements[F][[1]]
SingletonArray[F_,γ_]:=Module[
{
q=FieldSize[F]

},
a[-1]:=1;
a[0]:=1;
a[j_]:=FromElementCode[F,1]/(FromElementCode[F,1]-(γ^j));
Table[Table[If[k<=q-j+1,If[j==1∨k==1,1,ToElementCode[a[j+k-3]]],If[q==4&&k==j==3,ToElementCode[a[1]],0]],{k,1,q}],{j,1,q}]
]
AMatrix[F_,n_,γ_]:=Map[FromElementCode[F,#]&,SingletonArray[F,γ][[1;;Floor[n/2],1;;Ceiling[n/2]]],{2}]
AMatrix[GF[4],6,γ_]:=Map[FromElementCode[GF[4],#]&,SingletonArray[GF[4],γ][[1;;Floor[(FieldSize[GF[4]]+2)/2],1;;Ceiling[(FieldSize[GF[4]]+2)/2]]],{2}]
GMatrix[F_,n_,γ_]:=ArrayFlatten[{{Map[FromElementCode[F,#]&,IdentityMatrix[Length[AMatrix[F,n,γ]]],{2}],AMatrix[F,n,γ]}}]
HMatrix[F_,n_,γ_]:=ArrayFlatten[{{-Transpose[AMatrix[F,n,γ]],Map[FromElementCode[F,#]&,IdentityMatrix[Length[AMatrix[F,n,γ][[1]]]],{2}]}}]

MMatrices[F_,n_,d_]:=Flatten[Map[Table[Map[{(#/.{Z->0,X->FromElementCode[F,1]}),(#/.{X->0,Z->FromElementCode[F,1]})}&,Permutations[Join[Table[0,{n-#}],Table[X,{i}],Table[Z,{#-i}]]]],{i,0,#}]&,{d}],2]

Clear[cXsavingfunction]
cXsavingfunction[F_,n_,G_]:=Module[{messagesG},
messagesG=Tuples[AllElements[F],Floor[n/2]];
cXsavingfunction[F,n,G]:=Map[(#.G)&,messagesG];
cXsavingfunction[F,n,G]
]
cZsavingfunction[F_,n_,H_]:=Module[{messagesH},
messagesH=Tuples[AllElements[F],Ceiling[n/2]];
cZsavingfunction[F,n,H]:=Map[(#.H)&,messagesH];
cZsavingfunction[F,n,H]
]

CheckQECC[F_,MX_,MZ_,G_,H_,d_]:=Module[{n,cX,cZ,allpushedMwithgoodweight,allerrorpositions},
n=Length[MX];
cX=Map[#+MX&,cXsavingfunction[F,n,G]];
cZ=Map[#+MZ&,cZsavingfunction[F,n,H]];

allpushedMwithgoodweight=Select[Flatten[Outer[Sign[#1+#2]&,Map[ToElementCode,cX,{2}],Map[ToElementCode,cZ,{2}],1],1],(d<=HammingDistance[#,Table[0,{n}]]<=Floor[n/2])&];
allerrorpositions=Permutations[Join[Table[0,{n-(d-1)}],Table[1,{d-1}]]];
{
Min[Flatten[Outer[HammingDistance[#1+#2,Table[0,{n}]]&,Map[ToElementCode,cX,{2}],Map[ToElementCode,cZ,{2}],1]]]≥d,
And@@Map[Function[{EF},Or@@Map[And[(And@@NonNegative[#-EF]),Or@@Positive[#-EF]]&,allpushedMwithgoodweight]],allerrorpositions]
}
]

Timing[
Table[
Function[{n,q,d},
{
"n="<>ToString[n],"q="<>ToString[q],"d="<>ToString[d],Table[{
ElementToPolynomial[γ,x],
Function[{G,H},
Select[Map[{Map[(X^ToElementCode[#])&,#[[1]]] Map[(Z^ToElementCode[#])&,#[[2]]],CheckQECC[GF[q],#[[1]],#[[2]],G,H,d]}&,MMatrices[GF[q],n,d]],(Or@@#[[-1]])&]
][GMatrix[GF[q],n,γ],HMatrix[GF[q],n,γ]]
}
,{γ,PrimitiveElements[GF[q]]}]
}
][nqd[[1]],nqd[[2]],nqd[[3]]]
,{nqd,{{3,2,1},{3,2,2},{3,3,2},{3,4,2},{4,3,2},{4,4,2},{5,4,2},{5,4,3},{5,5,2},{5,5,3},{6,4,2},{6,4,3},{6,5,3},{6,7,3},{6,8,3},{6,9,3},{6,11,3},{6,13,3},{7,7,3},{7,7,4},{7,8,3},{7,8,4},{8,7,4},{8,8,4}}}]
]