This assignment is worth 50 points.
For example, if your program requires 2× 107 instructions and your clock cycle is 570ps (picoseconds), the time required is 2× 107 × 570ps = 1.14 × 1010 ps.
Unfortunately, as humans we really don't understand picoseconds. We are more comfortable with things in larger units. Therefor you should convert the time to several more palatable units. To be specific, the program should output the following:
The program should read in a single line without prompting. This line will be in the format c:i where c is an integer representing the clock speed for the machine and i is the instruction count for the program. You should discard the : between these two values.
I will be using an automated system to grade this program, so you should print the output exactly is written below.
Example Run
Input is bold
570:20000000 11400000000 ps 11400000 ns, 0 ps 11400 us, 0 ns, 0 ps 11 ms, 400 us, 0 ns, 0 ps 0 s, 11 ms, 400 us, 0 ns, 0 ps 0 min, 0 s, 11 ms, 400 us, 0 ns, 0 ps
You should perform all computations as a long to avoid overflow. All data should be stored in an integer type.
All computations can be done with the instructions you know. You do not need if statements or loops to complete this program.
Integer division and modulus are very helpful in this program.
Your identifiers should be constructed properly, with meaningful names.
You should document your code with comments.
Your output should be organized, easy to read, and make appropriate use of white space.
Any numbers with a fixed meaning should be stored as a constant.
You should only perform any given computation once, store the results.
~dbennett/130/p2/runTests myprogNote there is no .C or .cpp on the end. This will build an executable called myprog. If it is successful, it will run a number of tests. These tests are by no means exhaustive, I will be running others when I test your code.
My program was called solution.C and here is a transcript of running the test code.
~dbennett/130/p2/runTests solution make: 'solution' is up to date. Test 1 Success Test 2 Success Test 3 Success Success, all tests have run correctlyI stuck a clear at the top of the test driver, so it will clear your screen.
make: 'solution' is up to date is normal if the program has already been compiled in your directory.