WRITE THIS PROGRAM USING SCHEME 1 Write three Scheme procedures to simulate thes
ID: 3817309 • Letter: W
Question
WRITE THIS PROGRAM USING SCHEME
1 Write three Scheme procedures to simulate these three gates: AND, OR, and XOR, shown in the diagram in Figure 1. Test your procedures using all possible input combinations. (6 points) Figure 1 Logic gates AND, OR, andXOR 2 Define a Scheme procedure (bitAdder x a b) to simulate the logic design given in the diagram in Figure 2 The procedure must call the gate procedures that you defined in Question 1 and must return a pair with two elements (s c) where s is the binary sum 3 P a g e CSE240 Introduction to Programming Language Homework 12 of a b, and x, while c is the carry-out. You will implement the procedure in three steps using three procedures, as listed below. 2.1 Write a procedure (sum-bit x a b) to generate the result bit s (5 points) 2.2 Write a procedure (carry-out x a b) to generate the carry-out bit c (5 points) 2.3 Write a procedure (bitAdder x a b to generate the pair out put (s. c) (4 points)Explanation / Answer
Answers
1.scheme procedures for AND OR and XOR
;;internal logic
;;testing
;;run the test cases
2.schema procedure for bit adder x a b
;;define gates
;;Run test cases
;;Define Sum-Bit
;;Test sum bit
;;Define Carry-Bit
;;Test Carry-Bit
;;Define Bit-Adder
;;Test Bit-Adder
;;Run the Tests
3.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.