Ejemplo n.º 1
0
def createMod512LookupTable(encoding):
	table = LookupTable()

	points = generatePointsMatrix(24)
	baseBitStrings = generateBaseBitStringMatrixMod512()
	
	if encoding == LINEAR:
		linearList = BG.generateBitList(9)
		index = 0
		for i in range(0, 24):
			for j in range(0, 24):
				if baseBitStrings[i][j] != None:
					baseBitStrings[i][j] = BSH.charListToString(linearList[index])
					index += 1

	else:
		fillInBitStringMatrixMod512(baseBitStrings)
		replaceWithGrayCodeBinary(baseBitStrings, 9)
		mirrorTopLeftQuadrant(baseBitStrings)
		
	for i in range(0, 24):
		for j in range(0, 24):
			if baseBitStrings[i][j] != None:
				table.add(baseBitStrings[i][j], points[i][j])	 

	return table
Ejemplo n.º 2
0
def createMod32LookupTable(encoding):
	table = LookupTable()

	points = generatePointsMatrix(6)
	baseBitStrings = generateBaseBitStringMatrixMod32()
	
	if encoding == LINEAR:
		linearList = BG.generateBitList(5)
		index = 0
		for i in range(0, 6):
			for j in range(0, 6):
				if baseBitStrings[i][j] != None:
					baseBitStrings[i][j] = BSH.charListToString(linearList[index])
					index += 1

	else:
		linearList = BG.generateBitList(3)
		grayList = []
		for value in linearList:
			grayList.append(BSH.charListToString(Encoder.convertToGray(value)))

		baseBitStrings[0][0] = None
		baseBitStrings[0][1] = grayList[4]
		baseBitStrings[0][2] = grayList[3]
		baseBitStrings[1][0] = grayList[5]
		baseBitStrings[1][1] = grayList[6]
		baseBitStrings[1][2] = grayList[7]
		baseBitStrings[2][0] = grayList[2]
		baseBitStrings[2][1] = grayList[1]
		baseBitStrings[2][2] = grayList[0]

		# With QAM levels that are an odd power of 2 it is no longer possible
		# to arrange the values such that no 2 differ by more than 1 bit. The 
		# above pattern is the best that can be done. It gives 8 adjacent pairs
		# that differ by more than 1 bit. This pattern is scaled up to be used 
		# in 128 and 512 QAM. 
		mirrorTopLeftQuadrant(baseBitStrings)

	for i in range(0, 6):
		for j in range(0, 6):
			if baseBitStrings[i][j] != None:
				table.add(baseBitStrings[i][j], points[i][j])	 

	return table
Ejemplo n.º 3
0
def replaceWithGrayCodeBinary(matrix, numberOfBits):
	bitValues = BG.generateBitList(numberOfBits - 2);
	grayValues = []
	for bitValue in bitValues: 
		grayValues.append(BSH.charListToString(Encoder.convertToGray(bitValue)))

	for i in range(0,12):
		for j in range(0,12):
			if matrix[i][j] != None and matrix[i][j] != ' ':
				matrix[i][j] = grayValues[int(matrix[i][j])]
Ejemplo n.º 4
0
def testQAM(numberOfBits, numberOfLevels, encoding):
	failures = 0
	values = BG.generateBitList(numberOfBits)

	encString = "Linear"
	if encoding == 1:
		encString = "Gray"

	print "\n{} QAM {} - number of permutations to test: {}".format(numberOfLevels, encString,len(values))
	for value in values: 
		mod = Modulation.mod(value, Modulation.MOD_SCHEME_QAM,numberOfLevels, encoding)
		demod = Modulation.demod(mod, Modulation.MOD_SCHEME_QAM,numberOfLevels, encoding)
		#print value, " = ", demod
		if value != demod:
			failures += 1
	print "{} QAM {} failures: {}\n".format(numberOfLevels,encString,failures)
Ejemplo n.º 5
0
def createMod4GrayLookupTable():
	table = LookupTable()
	values = BG.generateBitList(2)

	stringValues = []
	for value in values: 
		stringValues.append(BSH.charListToString(Encoder.convertToGray(value)))

	points = generatePointsMatrix(2)
	nextString = 0
	for i in range(0, 2):
		for j in range(0, 2):
			table.add(stringValues[nextString], points[i][j])
			nextString += 1

	return table
Ejemplo n.º 6
0
def generateSquareMatrix(numberOfBits, encoding):
	bitsPerSide = int(math.sqrt(2 ** numberOfBits))
	linearList = BG.generateBitList(int(math.log(bitsPerSide,2)))
	grayList = []
	listToUse = linearList
	if encoding == GRAY:
		for value in linearList:
			grayList.append(Encoder.convertToGray(value))
		listToUse = grayList	

	stringList = []
	for value in listToUse:
		stringList.append(BSH.charListToString(value))

	matrix = []
	for i in range(0,bitsPerSide):
		nextRow = []
		for j in range(0, bitsPerSide):
			newValue = stringList[i] + stringList[j]
			nextRow.append(newValue)
		matrix.append(nextRow)
	return matrix
Ejemplo n.º 7
0
def createMod8LookupTable(encoding):
	table = LookupTable()
	values = BG.generateBitList(3)

	stringValues = []
	for value in values: 
		if encoding == LINEAR:
			stringValues.append(BSH.charListToString(value))
		else:
			stringValues.append(BSH.charListToString(Encoder.convertToGray(value)))

	bitMatrix = []

	nextRow = []
	nextRow.append(stringValues[0])
	nextRow.append(stringValues[1])
	nextRow.append(stringValues[2])
	bitMatrix.append(nextRow)

	nextRow = []
	nextRow.insert(0, stringValues[3])
	nextRow.insert(0, None)
	nextRow.insert(0, stringValues[7])
	bitMatrix.append(nextRow)

	nextRow = []
	nextRow.append(stringValues[6])
	nextRow.append(stringValues[5])
	nextRow.append(stringValues[4])
	bitMatrix.append(nextRow)

	points = generatePointsMatrix(3)

	for i in range(0,3):
		for j in range(0,3):
			table.add(bitMatrix[i][j], points[i][j])
			
	return table
Ejemplo n.º 8
0
import Encoder
import BitGenerator as BG
import BitStringHelper as BSH

index = 0
values = BG.generateBitList(5)
for i in values:
	print index, BSH.charListToString(Encoder.convertToGray(i))
	index += 1
Ejemplo n.º 9
0
array = QAM.generateSquareMatrix(10, 0)
differByOneByOnly(array)
print "\n\n"


print "1024 QAM Gray"
array = QAM.generateSquareMatrix(10, 1)
differByOneByOnly(array)
print "\n\n"




# 32 QAM Linear
baseBitStrings = QAM.generateBaseBitStringMatrixMod32()
linearList = BG.generateBitList(5)
index = 0
for i in range(0, 6):
	for j in range(0, 6):
		if baseBitStrings[i][j] != None:
			baseBitStrings[i][j] = BSH.charListToString(linearList[index])
			index += 1

print "32 QAM Linear"
differByOneByOnly(baseBitStrings)
print "\n\n"


# 32 QAM Gray 
linearList = BG.generateBitList(3)
grayList = []