The most important item on all homework is YOUR NAME! No name, no credit. ALSO, put last 4 digits of SS#. Staple or clip pages together.
Homework must be submitted when due. You loose 10%, one grade, the first day homework is late. Then 10% each week thereafter. Max 50% off. A zero really hurts your average! Paper or EMail to squire@cs.umbc.edu is acceptable. If I can not read or understand your homework, you do not get credit. Type or print if your handwriting is bad. Homework is always due on a scheduled class day within 15 minutes after the start of the class. If class is canceled then homework is due the next time the class meets.
EMail only plain text! No word processor formats. You may use a word processor or other software tools and print the results and turn in paper. Put CS411 and HW number in subject line.
The "submit" facility only works on the "irix.gl" machines. The student commands are: submit cs411 HW4 file puts your "file" into cs411 HW4 submitrm cs411 HW4 file removes your "file" from cs411 HW4 submitls cs411 HW4 lists your files in cs411 HW4 Note: For this semester the 'HW4' can be HW4, HW6, part1, part2 or part3. a) you must have your userid registered for "submit" send mail from a gl machine to squire if your submit fails b) you have to be logged onto a gl machine, kermit or telnet are OK c) everything is case sensitive, sorry about the uppercase HW.
Book Page 45, Exercises 1.1 through 1.26. The answer is just two columns. The first column is the numbers 1 through 26, the second column is the answer letter from the set {a-z}
You do not have to copy the questions, but show the computation and clearly indicate the answers.. Be sure to label the answers with the Exercise number. Book Page 93, Exercises 2.18, 2.19, 2.20 Book Page 101, Exercises 2.41, 2.42
Using the program matmul2.c from here or Downloadable source: On an SGI machine, MIPS architecture only: 1) Count the instructions inside the inner loop on 'j' from Method 1 2) How many times are these instructions executed? from Method 1 3) Count the instructions inside the inner loop on 'j' from Method 2 4) How many times are these instructions executed? from Method 2 5) Give one assembly language statement for the double multiply mul.d Use Method 2 below to get this 6) Give the corresponding 32 bit hexadecimal for 5) Use information from Method 2 to find this in Method 3 7) Give the instruction field format values for 5) This should be six decimal values computed by hand. The fields are 6,5,5,5,5,6 bits respectively Check your result against Fig 4.47, p 291 (except registers) Note: The answers are not unique. It depends on which compiler is used, which options are used and possibly which computer is used. For example, on 9/21/98, UMBC8 and UMBC9 gave different results. This assignment should be run on an SGI machine using c89 -g3 -O4 . Use c89 -g3 -O3 if that is the only thing that works. Method 1 for getting assembly language source code to a file matmul1.s gcc -g3 -O4 -S matmul2.c or gcc -g3 -O3 -S matmul2.c mv matmul2.s matmul2gcc.s (save in case next clobbers.) Method 2 for getting assembly language source code to a file c89 -g3 -O3 -S matmul2.c may create matmul2.s or c89 -g3 -O4 -S matmul2.c may create u.out.s Now, look and compare the instructions in the 'j' loop for Method 1 and 2. These instructions will later go through another program, a reorganizer. Answer question parts 1) 2) 3) 4) For Method 3, if gdb is not available, figure out how to use some other debugger. e.g. dbx or some X windows debugger. When running with redirection, ">", first test without redirection to be sure you can type the correct input and it works. Then type carefully or use a script to make the redirected run. Ignore the error: "Cannot access memory at address 0x20" Method 3 for getting assembly language source code to a file assy.out c89 -g3 -O3 matmul2.c or c89 -g3 -O4 matmul2.c gdb a.out break main <-- write down this number 0x10000ad4 or whatever run <-- may get garbage error message disassemble 0x10000ad4 0x10000d00 <-- or some number 300 bigger q y <-- interactively, have to hit returns c89 -g3 -O3 matmul2.c or c89 -g3 -O4 matmul2.c gdb a.out > assy.out break main <-- you are typing blind, be careful run disassemble 0x??? 0x??? <-- fill in with something that worked above. q y Now, look and compare instructions in assy.out to Method 2 matmul2.s Method 3 gives the instructions that are actually in memory during execution. And, you can find the memory address of matmul2.c A method for getting hex printout of 32 bit instructions to file hex.out c89 -g3 -O3 matmul2.c or c89 -g3 -O4 matmul2.c gdb a.out > hex.out gdb a.out > hex.out break main break main run run x/400xw 0x10000ad4 or abc x/202xw 0x400980 q q y y The command x/400xw 0x10000ad4 says dump 400 words in hex starting at address 0x10000ad4 YOUR RUN MAY NEED DIFFERENT VALUES. Remember memory addresses are in bytes, instructions take 4 bytes. (Even in the 64 bit machine!) 0x400980 is from the 32 bit machine. In hex.out use main+number to relate to assy.out to find the same word. If gdb is not available, try dbx. Instructions are in man dbx and dbx help. e.g. for hex dump of memory try: dbx -d a.out stop main rerun list 1,26 0x10000ae8/400X <--- "ae8" may not be right for you, check "rerun" q e.g. for disassembly of memory try: dbx -d a.out stop main rerun list 1,26 (#1)/400i q Read it on-line or capture to a file with redirection or commands: record output file-name.out unrecord The instruction field format is on page 117 of textbook, also 121, 131 or appendix A-73 area. mul.d is the MIPS=SGI double precision floating point multiply, "R" format. Watch out for where the register values are placed. (R2000 instruction may differ from UMBC8 or UMBC9 that are RX000.) Pitfalls: The compiler may use optimization and unroll the loop. This means a few mul.d instructions could be in the loop and the number of times through the loop will be proportionally less. Most of the instruction in the loop are "housekeeping", there are various instructions for loading and storing data, l.d and s.d are just one pair. Run the debugger, gdb, without the redirection "> xxx.out" first. When running with redirection you will not see what you type! Be careful! You may find the disassembly from the debugger the most accurate to count while being the hardest to find the inside of the loop. Optimization is O as in oh!, not 0 as in zero! -O2, -O3 and -O4 can be used.
"submit" a single file named add32c.e that is a fast carry 32 bit adder. (This is not the same adder as previous classes) You will use this file in HW6 and the three parts of the project. It is not important what the signal names are in add32c.e, but keep the same size and order. Build a four bit fast adder component or download add4c.e You need a 32 bit adder, so use eight add4c components in an add32 component [NO 'c' on component name] , cin goes into bottom stage, the carry out of each stage goes into the bottom of the next stage, the carry out from the last stage gets the signal name cout. Use unique signal names or unique subscripts. All connections with the same name are tied together and have the same value. Build a main circuit for testing your add32 component or download tadd32c.e Get the .run file to test your circuit tadd32c.run Use these commands to set up esim and ecomp, then compile and simulate: On irix.gl.umbc.edu ln -s /afs/umbc.edu/users/s/q/squire/pub/ecomp ecomp ln -s /afs/umbc.edu/users/s/q/squire/pub/esim esim (remember to rm esim rm ecomp if typed wrong first time.) or on linux.gl.umbc.edu or UMBC PC booting Linux ln -s /afs/umbc.edu/users/s/q/squire/pub/linux/redhat52/ecomp ecomp ln -s /afs/umbc.edu/users/s/q/squire/pub/linux/redhat52/esim esim ecomp add32c.e tadd32c.e -o tadd32c.net esim < tadd32c.run > tadd32c.out Check to file tadd32c.out to be sure your adder worked. The answers are in tadd32c.chk You can check your output with the command diff tadd32c.out tadd32c.chk. Submit ONE file add32c.e that has the component add32 in it. submit cs411 HW4 add32c.e Your circuits must run. Incorrect results loose points. Late submittals loose even more points. You must include a few comments so anyone reading your circuits can understand them. Follow the links below to Project and Download for more information. See the writeups on ecomp, esim, tutorial and sample circuits. The building blocks become part of your final project.
1. Write two esim statements that implement the truth table below the answer starts x <= y <= a b c | x y ------+---- 0 0 0 | 0 0 0 0 1 | 0 1 0 1 0 | 0 0 0 1 1 | 1 0 1 0 0 | 0 0 1 0 1 | 1 0 1 1 0 | 0 0 1 1 1 | 0 1 2. Write the esim statement that implements the logic diagram +----+ a --|AND |____ b --| | | +----+ | +----+ --|XOR | +----+ | | c --|OR |_____| |__ d --| | | | | +----+ | | | --| | | +----+ | | | | e --|NOT |---| +----+ | +----+ +----+ |--|OR | | |-- g f ------------------------| | +----+ 3. Draw the logic diagram that represents the esim statement g <= ((~a|b)^(c&d&~e))|(e&~f); 4. textbook, Page 330, Problem 4.49 with the additional instructions: Use A, B, E and F all as four ones. e.g. A <= #b1111 etc. The answer is a six bit result S. 5. textbook, page 331, Problem 4.50 Watch out, the problem states 2T, not 1T Be sure to count the longest path.
Code up a circuit that does a 32bit times 32bit multiplication and outputs the 64 bit product. Call this bmul32c.e and use 'submit' to submit it as HW6. (Well, this breaks esim, so use 16 x 16 = 32) IT RUNS TOO LONG ON GL MACHINES, do a 16 x 16 = 32 multiply call the file bmul16c.e and submit cs411 HW6 bmul16c.e Basic long hand multiply on positive numbers 7 * 12 = 84 the multiplicand 1100 12 | * 0111 7 | ----------- v 1100 <-- note 1 & 1100 1100 <-- note 1 & 1100 1100 <-- note 1 & 1100 0000 <-- note 0 & 1100 ----------- ^ 01010100 84 | | the multiplier Observe that when the multiplier has a bit=1, add the multiplicand. When the multiplier has a bit=0, add all zeros. Shift the object being added one place for each bit in the multiplier. A 32 bit by 32 bit multiply could be performed sequentially using one adder and 32 clock times. A simple parallel circuit would use 32 adders hooked together just like the long hand example. This multiplier would have a delay about 32 times as long as the basic 32 bit adder. A more complicated multiplier would add pairs of partial products, then pairs of pairs, in a tree like circuit. This type of circuit generally takes log base 2 of the length times the basic time for a 32 bit adder. A compromise is to use a group of carry save adders. First, let us demonstrate on a four bit machine. Look at the basic add4c adder component. Next look at the add4csa carry save adder. Bring up a schematic of add4csa. Then, look at the bmul4c component. Bring up a schematic of bmul4c. Finally, a test circuit with a counter running all 256 cases of four bits times four bits using unsigned numbers tbmul4c.e These can be downloaded by clicking right mouse button, then compiling ecomp add4c.e bmul4c.e tbmul4c.e -o tbmul4c.net Now download the .run file tbmul4c.run and simulate using esim < tbmul4c.run > tbmul4c.out and look at the tbmul4c.chk file. The 8 bit version looks like add8c.e bmul8c.e tbmul8c.e tbmul8c.run tbmul8c.chk Your homework 6 is to code up a bmul32c.e and test it, then do a submit, submit cs411 HW6 bmul32c.e For testing: You may use tbmul32c.e with tbmul32c.run and check against tbmul32c.chkOld, only do a 16 bit by 16 bit multiplier
using commands to build and run HW6 (see below for 16 bit) ecomp bmul32c.e tbmul32c.e -o tbmul32c.net esim < tbmul32c.run > tbmul32c.out diff tbmul32c.out tbmul32c.chk Unfortunately, the esim < tbmul32c.run takes a LONG time, try it first to see if 2 x 2 = 4. The full answer should be a= 00000002, b= 00000002 a*b= 0000000000000004 Start from the 4 bit or 8 bit version, or start from scratch. Cut down your add32c.e file, make a add16 component basic adder. You can use the tbmul8c.run by changing the name of the .net file and [esim show a] to [esim show -hex a], etc. . Please do not try to run all 2**64 test cases. Just the 16 to 64 test cases similar to the 8 bit test will be sufficient. Problems: My bmul8c.e is OK but testing can fail if not enough time is given for the circuit to settle. The sequence should be: esim set -hex a 40 esim set -hex b 40 esim run 200 puts "a=[esim show a], b=[esim show b], a*b=[esim show c]" then more test cases if you wish Watch out when you cut and paste. Lines that are long get broken and cause ecomp errors. Especially the end of comments! Can't get the same answer twice? You have hit a rare timing problem between the SGI and esim. Back off to a 16 x 16 = 32 bit multiplier using add16c.e tbmul16c.e tbmul16c.run tbmul16c.chk After downloading the files to your directory, you code up bmul16c.e based on bmul8c.e, and run the commands:Old, replaced !!!
ecomp add4c.e add16c.e bmul16c.e tbmul16c.e -o tbmul16c.netNew, please submit all in one file
ecomp bmul16c.e tbmul16c.e -o tbmul16c.net esim < tbmul16c.run > tbmul16c.out diff tbmul16c.out tbmul16c.chk When the check is OK, submit cs411 HW6 bmul16c.e
Closed book. Multiple choice questions based on reading assignments and esim lectures and homework. Exam covers book: 1.1-1.6 common sense questions, not dates or people 2.1-2.6 page 118, 146 and 148 instruction formats 4.1-4.8 Exam covers homework: HW1-HW5 Exam covers esim tutorial.
Last updated 3/27/00