Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Page of 6 ZOOM Programming Exercise (50 points) Logic gates are the basic components of building a processor. At a higher level of abstraction is

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Page of 6 ZOOM Programming Exercise (50 points) Logic gates are the basic components of building a processor. At a higher level of abstraction is something like an adder that is built out of basic logic gates but performs a more complex operation like adding two binary numbers. All high-level language programs will be translated into instructions that can executed on these basic components. The correctness and performance of these components are extremely important. A computer system consists of hardware and software. Before we implement a hardware component, the design is normally simulated by a program first, so that we can verify ils correctness and evaluate its performance. In this project, you will write a Scheme program to simulate an n bit Adder. If you have not taken CSE120/SER232 and are not familiar with logic gates, you can ignore the physical meaning of the components. Instead, consider each as a pure math/logic function that does something, and where you are asked to create a more complex function using a few simpler functions in a specific way. (For example, an AND" below is really the same thing as "&&", the logical and operation in C/CH/Java. OR matches to , and NOT matches to !) 1 Write three Scheme procedures to simulate these three gates: AND, OR, and NOT, shown in the diagram in Figure 1. Test your procedures using all possible input combinations. Hint: Lecture slides showed the implementation of a not-gate in Scheme. [3 points] b AND OR NOT a a b 0 0 0 1 10 1 1 C 0 0 0 1 a 0 0 1 1 b 0 1 0 1 0 1 1 1 0 1 1 0 Figure 1. Logic gates AND, OR and NOT, and their function definitions The test cases and expected outputs are given in the code template file hw12.rkt. Do not remove or edit these lines. Page string" 1 10100)) should give "110100". [4 points) Page of 6 ZOOM 4.3 Follow the fantastic-four abstract approach to design your recursive solution to implement the diagram in Figure 4. You must also explain: [3 points) (1) What is the size-n problem of your procedure? List the lines of code you use. (2) What are the stopping condition and its return value? List the lines of code you use. (3) What is the size-(n-1) problem? List the lines of code you use. (4) What are the steps to construct the size-n problem solution from the size-(n-1) solution. List the lines of code you use. CSE240 - Homework 4 Page Write the answers as comments in the program, so that your entire program file is executable. 4.4 Following the fantastic-four steps that you have designed in the previous question, implement the n-bit adder, and test the program. [13 points) Note: your (n-bit-adder A B n) must call a recursive procedure, e.g., (recursive-add A B C), where c is a carry. You can follow the lecture slides to write these two procedures. However, you cannot use (quotient 1 2) and (remainder 1 2). Instead, you must call your (full-adder (tail A) (tail B) c). You can use (car (full-adder (tail A) (tail B) c)) and (cdr (full-adder (tail A) (tail B) c)) to obtain the sum and carry, respectively. Page of 6 ZOOM Programming Exercise (50 points) Logic gates are the basic components of building a processor. At a higher level of abstraction is something like an adder that is built out of basic logic gates but performs a more complex operation like adding two binary numbers. All high-level language programs will be translated into instructions that can executed on these basic components. The correctness and performance of these components are extremely important. A computer system consists of hardware and software. Before we implement a hardware component, the design is normally simulated by a program first, so that we can verify ils correctness and evaluate its performance. In this project, you will write a Scheme program to simulate an n bit Adder. If you have not taken CSE120/SER232 and are not familiar with logic gates, you can ignore the physical meaning of the components. Instead, consider each as a pure math/logic function that does something, and where you are asked to create a more complex function using a few simpler functions in a specific way. (For example, an AND" below is really the same thing as "&&", the logical and operation in C/CH/Java. OR matches to , and NOT matches to !) 1 Write three Scheme procedures to simulate these three gates: AND, OR, and NOT, shown in the diagram in Figure 1. Test your procedures using all possible input combinations. Hint: Lecture slides showed the implementation of a not-gate in Scheme. [3 points] b AND OR NOT a a b 0 0 0 1 10 1 1 C 0 0 0 1 a 0 0 1 1 b 0 1 0 1 0 1 1 1 0 1 1 0 Figure 1. Logic gates AND, OR and NOT, and their function definitions The test cases and expected outputs are given in the code template file hw12.rkt. Do not remove or edit these lines. Page string" 1 10100)) should give "110100". [4 points) Page of 6 ZOOM 4.3 Follow the fantastic-four abstract approach to design your recursive solution to implement the diagram in Figure 4. You must also explain: [3 points) (1) What is the size-n problem of your procedure? List the lines of code you use. (2) What are the stopping condition and its return value? List the lines of code you use. (3) What is the size-(n-1) problem? List the lines of code you use. (4) What are the steps to construct the size-n problem solution from the size-(n-1) solution. List the lines of code you use. CSE240 - Homework 4 Page Write the answers as comments in the program, so that your entire program file is executable. 4.4 Following the fantastic-four steps that you have designed in the previous question, implement the n-bit adder, and test the program. [13 points) Note: your (n-bit-adder A B n) must call a recursive procedure, e.g., (recursive-add A B C), where c is a carry. You can follow the lecture slides to write these two procedures. However, you cannot use (quotient 1 2) and (remainder 1 2). Instead, you must call your (full-adder (tail A) (tail B) c). You can use (car (full-adder (tail A) (tail B) c)) and (cdr (full-adder (tail A) (tail B) c)) to obtain the sum and carry, respectively

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Apache Cassandra 3 X An Expert Guide To Improving Database Scalability And Availability Without Compromising Performance

Authors: Aaron Ploetz ,Tejaswi Malepati ,Nishant Neeraj

3rd Edition

1789131499, 978-1789131499

More Books

Students also viewed these Databases questions

Question

2. What potential barriers would you encourage Samuel to avoid?

Answered: 1 week ago