

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


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:
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
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