Docsity

CDMA Encoding and Decoding Assignment in Computer Science, Assignments of Computer Science

Toggle sidebar
bg1
-4 0 0 0
2 2 2 -2
-2 -2 -2 2
-2 2 -2 -2
-4 0 0 0
-4 0 0 0
2 -2 2 2
2 -2 2 2
-4 0 0 0
0 0 0 -4
2 2 -2 2
2 2 -2 2
-4 0 0 0
-2 -2 2 -2
-2 2 -2 -2
-2 2 2 2
-4 0 0 0
0 0 0 -4
2 2 -2 2
0 0 0 4
0 0 0 -4
4 0 0 0
-2 2 -2 -2
2 -2 -2 -2
-4 0 0 0
0 0 0 -4
2 2 -2 2
0 0 0 4
-2 -2 -2 2
0 4 0 0
0 0 -4 0
2 2 2 -2
cdmaTest.txt
0 1 0 1 0 0 0 0
0 1 1 1 0 0 1 0
0 1 1 0 1 1 1 1
0 1 1 0 0 1 1 1
test2.txt
0 1 0 0 0 0 1 1
0 0 1 1 0 0 0 1
0 0 1 1 0 1 0 0
0 0 1 1 0 1 0 1
test1.txt
0 0 1 0 0 0 1 1
0 0 1 1 0 0 0 0
0 0 1 1 0 1 0 1
0 0 1 1 1 0 1 0
test3.txt
0 1 0 0 0 0 1 1
0 1 0 0 0 1 0 0
0 1 0 0 1 1 0 1
0 1 0 0 0 0 0 1
test4.txt
Computer Science 145.002
Introduction to Computing for Engineers
Fall 2008
Programming Assignment 5
“Nested Functions”
Due: 7:30 AM, Thursday, October 16, 2008
In this programming assignment, you will break a large programming problem into ten self-contained functions, each of
which will solve a particular task as part of the overall programming effort. The program will deal with a technique
known as Code Division Multiple Access (CDMA), used in wireless communications to encode several simultaneous
binary transmissions in such a way that the individual messages can be deciphered upon arrival at a receiving station.
Essentially, each transmitted binary message is first converted from 0’s and 1’s into -1’s and 1’s, merely by changing each
0 into a -1. Next, each ±1 value is multiplied by that transmitter’s “chip set” a sequence of ±1 values in the form of a
vector. The resulting vectors from all of the transmitters are then added and transmitted across the wireless media as a
CDMA signal.
For example, let’s assume that there are four transmitters using the chip sets illustrated at right: (1, 1, 1, 1), (1, 1, -1, -1),
(1, -1, -1, 1), and (1, -1, 1, -1). If the first transmitter’s original binary message is 01001111, that gets translated to -1 1 -1
-1 1 1 1 1, which, after multiplied by the first chip set (1, 1, 1, 1) yields:
-1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
If the second transmitter’s original message is 01110101, that gets translated to -1 1 1 1 -1 1 -1 1,
which is multiplied by chip set (1, 1, -1, -1), producing:
-1 -1 1 1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1
Similarly, the third transmitter, with binary message 01100011, produces:
-1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1
Finally, the fourth transmitter, with binary message 01101000, produces:
-1 1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1
When these four vectors are added together, the final CDMA transmission is determined:
-4 0 0 0 4 0 0 0 2 -2 -2 -2 -2 2 -2 -2 0 0 4 0 0 4 0 0 0 0 0 4 2 2 -2 2
Since the transmission is wireless, every receiving station receives the entire CDMA message, but each station applies
the appropriate chip set to retrieve its intended message. The first receiving station multiplies the chip set (1, 1, 1, 1) as
a vector with each set of four incoming values, yielding (-4, 4, -4, -4, 4, 4, 4, 4). Converting every positive value to 1 and
every negative value to 0, this does, indeed, produce the first transmitting station’s binary signal of 01001111. Similarly,
the second receiving station multiplies the (1, 1, -1, -1) chip set with the incoming signal to produce (-4, 4, 4, 4, -4, 4, -4,
4), which converts to 01110101. The third receiving station multiplies the (1, -1, -1, 1) chip set with the incoming signal
to produce (-4, 4, 4, -4, -4, -4, 4, 4), which converts to 01100011. Finally, the fourth receiving station multiplies the (1, -1,
1, -1) chip set with the incoming signal to produce (-4, 4, 4, -4, 4, -4, -4, -4), which converts to 01101000.
Finally, notice that if each of the binary messages is treated as ASCII code, the four transmitted signals translate as:
Transmission # 1234
Binary Code 01001111 01110101 01100011 01101000
Integer Version 79 117 99 104
Character O u c h
Your assignment is to write a program that uses ten functions to read in four user-specified input files, each of which
contains 32 integers with values of 0 or 1, representing four ASCII characters (eight bits per ASCII character) that are
being transmitted separately. Your program will use the chip sets on the previous page to produce a CDMA encoding of
these four signals, outputting that encoding to another user-specified file.
Once the output file is successfully produced, your program will close the output file and then, using that same file as an
input file, read in the CDMA encoding four times, applying one of the chip sets to it to recreate the original binary
transmission, which is then output to the user. A sample interaction is displayed on the reverse side of this page.
The ten required functions are laid out in the diagram below, followed by a table with details involving their types, their
parameters, and a description of what they should do.
pf2

Partial preview of the text

Download CDMA Encoding and Decoding Assignment in Computer Science and more Assignments Computer Science in PDF only on Docsity!

cdmaTest.txt

test2.txt

test1.txt

test3.txt

test4.txt

Computer Science 145. Introduction to Computing for Engineers Fall 2008 Programming Assignment 5 “Nested Functions” Due: 7:30 AM, Thursday, October 16, 2008 In this programming assignment, you will break a large programming problem into ten self-contained functions, each of which will solve a particular task as part of the overall programming effort. The program will deal with a technique known as Code Division Multiple Access (CDMA), used in wireless communications to encode several simultaneous binary transmissions in such a way that the individual messages can be deciphered upon arrival at a receiving station. Essentially, each transmitted binary message is first converted from 0’s and 1’s into -1’s and 1’s, merely by changing each 0 into a -1. Next, each ±1 value is multiplied by that transmitter’s “chip set” a sequence of ±1 values in the form of a vector. The resulting vectors from all of the transmitters are then added and transmitted across the wireless media as a CDMA signal. For example, let’s assume that there are four transmitters using the chip sets illustrated at right: (1, 1, 1, 1), (1, 1, -1, -1), (1, -1, -1, 1), and (1, -1, 1, -1). If the first transmitter’s original binary message is 01001111, that gets translated to -1 1 - -1 1 1 1 1, which, after multiplied by the first chip set (1, 1, 1, 1) yields: -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 If the second transmitter’s original message is 01110101, that gets translated to -1 1 1 1 -1 1 -1 1, which is multiplied by chip set (1, 1, -1, -1), producing: -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 - Similarly, the third transmitter, with binary message 01100011, produces: -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 Finally, the fourth transmitter, with binary message 01101000, produces: -1 1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 When these four vectors are added together, the final CDMA transmission is determined: -4 0 0 0 4 0 0 0 2 -2 -2 -2 -2 2 -2 -2 0 0 4 0 0 4 0 0 0 0 0 4 2 2 -2 2 Since the transmission is wireless, every receiving station receives the entire CDMA message, but each station applies the appropriate chip set to retrieve its intended message. The first receiving station multiplies the chip set (1, 1, 1, 1) as a vector with each set of four incoming values, yielding (-4, 4, -4, -4, 4, 4, 4, 4). Converting every positive value to 1 and every negative value to 0, this does, indeed, produce the first transmitting station’s binary signal of 01001111. Similarly, the second receiving station multiplies the (1, 1, -1, -1) chip set with the incoming signal to produce (-4, 4, 4, 4, -4, 4, -4, 4), which converts to 01110101. The third receiving station multiplies the (1, -1, -1, 1) chip set with the incoming signal to produce (-4, 4, 4, -4, -4, -4, 4, 4), which converts to 01100011. Finally, the fourth receiving station multiplies the (1, -1, 1, -1) chip set with the incoming signal to produce (-4, 4, 4, -4, 4, -4, -4, -4), which converts to 01101000. Finally, notice that if each of the binary messages is treated as ASCII code, the four transmitted signals translate as:

Transmission # 1 2 3 4

Binary Code 01001111 01110101 01100011 01101000

Integer Version 79 117 99 104

Character O u c h

Your assignment is to write a program that uses ten functions to read in four user-specified input files, each of which contains 32 integers with values of 0 or 1, representing four ASCII characters (eight bits per ASCII character) that are being transmitted separately. Your program will use the chip sets on the previous page to produce a CDMA encoding of these four signals, outputting that encoding to another user-specified file. Once the output file is successfully produced, your program will close the output file and then, using that same file as an input file, read in the CDMA encoding four times, applying one of the chip sets to it to recreate the original binary transmission, which is then output to the user. A sample interaction is displayed on the reverse side of this page. The ten required functions are laid out in the diagram below, followed by a table with details involving their types, their parameters, and a description of what they should do.

Function Type Parameters Description

main void none Supervises the retrieval of the binary input, its

CDMA encoding, and its subsequent decoding

and output as ASCII characters.

retrieveInputFilenames void 4 strings, by reference Supervises the retrieval of the four input file names.

retrieveInputFilename string 1 integer, by value Handles the retrieval of one input file's name.

cdmaEncode string 4 strings, by value Opens the relevant input and oputput files, supervises the CDMA

encoding of the input files into the output file, and then closes all

of the files.

cdmaEncode void 4 ifstreams, by reference

1 ofstream, by reference

Supervises the repeated retrieval of the next bit from each of the

four input files, and the subsequent CDMA encoding and output

of the resulting four values.

encodeNextBit void 1 ifstream, by reference

4 integers, by value

4 integers, by reference

Uses the parameterized chip set to retrieve the next bit from the

parameterized input file and encodes that bit into four values.

incrementSequence void 4 integers, by value

4 integers, by reference

Adds the four parameterized values to the four respective sums.

cdmaDecode void 5 strings, by value Supervises the decoding of the output file with the parameterized

name by applying the four chip sets that are associated with the

four input files, whose names are also parameterized.

cdmaDecode void 2 strings, by value

4 integers, by value

Supervises the character-by-character decoding of the four

characters whose ASCII representation was in the input file with

the parameterized file name, applying the parameterized chip set

to the CDMA encoding contained within the file with the pther

parameterized file name.

cdmaDecodeNextChar void 1 ifstream, by reference

4 integers, by value

Retrieves eight quartets of values from the parameterized input

file, applies the parameterized chip set to each quartet, interprets

the result as a sequence of bits representing an ASCII character,

and outputs that ASCII character.

Name your project PA5_ Lastname where Lastname is your last name (e.g., Fred Flintstone’s project would be PA5_Flintstone). A zipped folder containing several sets of sample input files is available on the course Web page at http://www.cs.siue.edu/wwhite/CS145/Syllabus.htm. Be sure to include adequate explanatory comments in your code. Zip-compress the entire project folder and place the zipped folder on your Moodle dropbox by 7:30 AM on Thursday, October 16, 2008. m a i n

mainretrieveInputFilename

s

retrieveInputFilenamecdmaEncodecdmaEncodeencodeNextBitincrementSequencecdmaDecodecdmaDecodecdmaDecodeNextChar