Question: Develop a python program to convert two decimal numbers (A and B) to binary numbers. You should generate B complement signal (flip all the bits

Develop a python program to convert two decimal numbers (A and B) to binary numbers. You should generate B complement signal (flip all the bits of Input B,1 e.g. not(B1)) when you insert them in the 4-bit binary full adder. For example, if your Inputs A = 6 and B = 7, generate the binary inputs 0110 (A) and 1000 (B complement). Your subtractor will execute the following operation:
 Develop a python program to convert two decimal numbers (A and
B) to binary numbers. You should generate B complement signal (flip all
the bits of Input B,1 e.g. not(B1)) when you insert them in

Input A 6 (0110) 0110 Input B-7 (0111) 1000 (B complement) carry in (cin) 1 (due to +5V) 1111 (decimal -1) adder py-/home/pi Ele Edt Format Bun Options Window Help Impor ting libraries import RP.Gp10 as Gp10 inport tine GPIO. setmode(GPIO.8CM) GPIO.setwarnings(False) Define input A A4 12 A3 16 A1 = 5 # Define input B B4 = 20 B321 82 26 81-19 s Define input s LED 54 25 LED S3 8 LED 52 11 LED S1 9 GPIO. setup(A4, GPIO OUT GPIO. setup(A3, GPIO.OUT GPIO.setup(A2, GPIO.OUT GPIO.setup(A1, GPIO.OUT GPIO. setup(B4, GPIO.OUT GPIO.setup(B3, GPIO.OUT GPIO. setup(82, GPIO.OUT GPIO, setup(81, GPIO.OUT GPIO.setup(LED S4, GPIO. IN) GPIO.setup( LED S3, GPIO.IN GPIO.setup(LED S2, GPIO.IN GPIO.setup(LED_S1, GPIO. IN) A input("Enter a decisal number for A [e, 15]: B input("Enter a decisal number for B [o, 15]: Abin a bin Abin [o,8,0,0 Bbin-[0,0,0,0 hile A0 Remainderint (A32) A int(A/2 inder while B 0: Bbin[n) Remainder n:int(a/2) print "Binary value for A: or x in reversed(Abin): print(x) print "Binary value for 8: " y in reversed(nbin): print(y) GPIO,out put (A4, Abin(3]) GP1O output (A3, GP10.output (A2 LED S425 LED-S2 11 LED S19 GPIO.setup(A4, GPIO.OUT) GPIO.setup(A3, GPIO.OUT) GPIO.setup (A2, GPIO.OUT) GPIO.setup(A1, GPIO.OUT) GPIO.setup (B4, GPIO.OUT) GPIO.setup (B3, GPIO.OUT) GPIO.setup (B2, GPIO.OUT) GPIO. setup (81, GPIO.OUT) GPIO.setup (LED S4, GPIO. IN) GPIO.setup (LED S3, GPIO.IN) GPIO.setup(LED S2, GPIO.IN) GPIO.setup(LED S1, GPIO. IN) B input("Enter a decimal number for B to, 15j: Abin - Bbin Abin [0,0,0,0 Bbin [0,0,0,0] while A0: Remainder = int( 2) Abin n] Remainder A int(A/2 while B0: Remainder int(B2) Bbin[n] Remainder B int (B/2) n=n+1 print "Binary value for A: for x in reversed (Abin): print(x) print "Binary value for B: for y in reversed(Bbin): print(y) GPIO.Output (A4, Abin[3 GPIO.output (A3, Abin[2 GPIO.output (A2, Abin[1 GPIO.out put (A1, Abin[o GPIO.output (B4, GPIO.output (B3, GPIO.output (82, GPIO.output (B1, Bbin( 3) Bbin[2 Bbin[1 Bbin[o print "Binary value for s: " print GPIO.input (LED S4 print GPIO.input (LED S3) print GPIO.input (LED_ S2 print GPIO.input (LED s1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!