473,385 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Creating a 4 bit multiplier with only two methods (final programming contest task at our university)

I saw this task at a programming competition at our university and since then I can't get rid of it.

I somehow can't figure out which logical conclusion to make.

We have given two methods:

Once a 4 bit Adder, where I pass two 4 bit numbers as a String. As return value I get the addition and a carry bit in a string array, where in the first string are the 4 bits of the addition and in the second string the carry bit.

In addition we have a 4 bit identity method A 4 bit identity simply means that I pass 4 bits to this method and another bit, if the other bit is 0 the method returns 0000 as a String, but if the bit is 1,the method returns the 4 bits, which I gave the method as a String.

You must not use loops, conditions, other variables, etc. Only the two methods.

The adder method can only be passed two strings that are 4 bits long and as a result, as mentioned, you get in one string the 4 bits of the addition and in another string the carry bit!

And with the identity method you also pass two strings, once a string that must be 4 bits long and another string that is either 1 or 0, if it is 1 you get the passed string back, otherwise 0000.

I know that when I add a number to itself, I create a left shift.

But still I can't get the result....

(As result must come out 8 bits, for this we have given 8 strings, where we can insert the 8 bits one by one).

I donīt now how we could solve this task.

(I dont need the code,I would just like to know what the procedure is)
Mar 30 '22 #1
1 10974
dev7060
636 Expert 512MB
Since
You must not use loops, conditions, other variables, etc.
Once a 4 bit Adder, where I pass two 4 bit numbers as a String. As return value I get the addition and a carry bit in a string array, where in the first string are the 4 bits of the addition and in the second string the carry bit.
Use the truth table to derive the output expressions and implement the sum and carry using operators.

Truth table https://en.wikipedia.org/wiki/Adder_(electronics)

A is the bit of the first number. B is the respective bit of the second number. C is the carry bit.

Sum = C XOR (A XOR B)
Carry = AB + BC + AC

The above expression can be obtained after simplification (a method like K-map https://en.wikipedia.org/wiki/Karnaugh_map
can be used).

In addition we have a 4 bit identity method A 4 bit identity simply means that I pass 4 bits to this method and another bit, if the other bit is 0 the method returns 0000 as a String, but if the bit is 1,the method returns the 4 bits, which I gave the method as a String.
Use bitwise AND.
Apr 9 '22 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: potm | last post by:
I hope you'll allow me a few moments to tell you about a programming contest that may be of interest to you. It's completely for fun, unsponsored, and pressure-free. It's called the POTM, and we...
0
by: Robby Findler | last post by:
Think your favorite programming language is the best one out there? Put it to the test in this year's International Conference on Functional Programming's annual Programming Contest. The contest...
13
by: Varun | last post by:
Hi Friends, Department of Information Technology, Madras Institute of Technology, Anna University, India is conducting a technical symposium, Samhita. As a part of samhita, an Online Programming...
0
by: Sridhar | last post by:
Hi, We, the students of CEG, Anna University are organizing an online programming contest as part of aBaCus 2005. The contest itself will start on 6th March 2005 at 1:00 pm IST and will end...
0
by: Sridhar | last post by:
Hi, We, the students of CEG, Anna University are organizing an online programming contest as part of aBaCus 2005. The contest itself will start on 6th March 2005 at 1:00 pm IST and will end...
0
by: Tom 7 | last post by:
Language lovers: Registration is now open for the 9th Annual ICFP Programming Contest! http://icfpcontest.org/ The contest, associated with the International Conference on Functional...
0
by: Wim Vanhoof | last post by:
----------------------------------------------------------- WLPE' 07 - CALL FOR PAPERS Workshop on Logic-based Methods in Programming Environments (satellite workshop of ICLP'07) ...
22
by: SETT Programming Contest | last post by:
The SETT Programming Contest: The fastest set<Timplementation Write the fastest set<Timplementation using only standard C++/C. Ideally it should have the same interface like std::set. At least...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.