Question: This must be done in the programming language Scheme. Problem #36 from your book (Page 296 - 297). A computer system consists of hardware and


This must be done in the programming language Scheme.
Problem #36 from your book (Page 296 - 297). A computer system consists of hardware and software. Normally, before we physically make a piece of hardware, we simulate the hardware by a program, so that we can verify its correctness and evaluate its performance. As we know, all complex hardware components can be implemented by the basic gates AND, OR, NOT, and XOR shown in Figure 4.9. a a D Dar b b b Figure 4.9. Basic gates. 1. Write four scheme functions to simulate these four gates. You will then use those functions below. 2. Define a Scheme procedure (fulladder x a b) to simulate the logic in Figure 4.10. The procedure must return a list with two elements (sc), where s is the sum of a, b, and x, and c is the carry-out. Hint: You can use two procedures to produce the two results, respectively, and then write a main procedure to call the two sub procedures. s a b Figure 4.10. The logic of a full adder. 3. Verify your procedure by exhaustive testing. Use all valid inputs to test the procedure. There are eight valid inputs: (fulladder 000) (fulladder 001) (fulladder 010) (fulladder 0 1 1) (fulladder 1 00) (fulladder 1 01) (fulladder 1 1 0 (fulladder i l 1) What to Turn in: Turn in a single Scheme file (logic.ss file) with the following functions defined (these names start with little L's, not l's or 1's): . . . O l-and: Takes two 1-bit integers and returns a 1-bit integer l-or: Takes two 1-bit integers and returns a 1-bit integer I-not: Takes one 1-bit integer and returns a 1-bit integer l-xor: Takes two 1-bit integers and returns a 1-bit integer fulladdr: Takes three 1-bit integers and returns a pair of two,1-bit integers Note: Result should be a pair: (sum . carry) Note: It must use the functions l-and, l-or, and l-xor. n-bit-addr: Takes two lists of 1-bit integers and a 1-bit integer for carry-in. It returns a pair of a list of 1-bit integers, and a 1-bit integer for carry-out o Note: You can assume the lists are the same size Note: Result should be a pair: (list-sum . carry-out) o Note: It must use the function fulladdr. o . O Testing: Make sure you test your functions as you develop them. fulladdr should behave like this: > (fulladdr 000) (0 : 0) > (fulladdr 0 0 1) (1 : 0) > (fulladdr 0 10) (1 : 0) > (fulladdr 0 1 1) (0 : 1) > (fulladdr 1 00) (1 : 0) > (fulladdr 1 0 1) (0 : 1) > (fulladdr 1 1 0) (0 : 1) > (fulladdr 1 1 1) (1 : 1) Here are some test cases for your n-bit-addr. Of course, you can create more: > (n-bit-addr '(010) '(0 1 1) 1) ((1 10) .0) > (n-bit-addr '(1 1 1) '(0 0 0) 1) ((0 0 0) . 1) > (n-bit-addr '(1 1 0 0 1 0 1 0 1) '(1 0 1 1 0 0 0 1 1) 0) ((0 11111000) . 1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
