TI MSP430G2553 - Implementation of XOR, OR, AND gates

Thread Starter

em_cardc

Joined Apr 5, 2016
43
Hello,

I have an assignment that consists in the creation of a full-adder using the microcontroller unit listed in the title. I understand the logic of the gates and how this all would work out operation-wise



What I am stuck on is if there is a necessity to use CMOSes to create each of the given logic gates as seen in the diagram below. What I have so far is the MCU which I believe should send out the three inputs, a couple of LEDs (to demonstrate the output (1 being on, 0 being off) and I don't know what else would be required in this case.

I can create the code but I need a little guidance as to how to start programming this and getting the desired results.

Thank you in advance.
 

WBahn

Joined Mar 31, 2012
30,060
I'm confused about just what the assignment is. Is the MCU supposed to implement the full-adder such that all of these pins in the diagram correspond to I/O pins on the MCU and the full adder behavior is implement in code? Or is the MCU being used to drive a separate full-adder circuit that is implement using discrete logic gates?
 

MrChips

Joined Oct 2, 2009
30,807
I will get you started.
Create variables you need.

int A, B, Cin, Cout, S, D, E, F, G;

Each variable may have only two possible values, 0 or 1.
For example,
A = 0;
B = 1;

Use bitwise boolean operators.
For example F = A AND B is written as:

F = A & B;

F = A OR B is written as:

F = A | B;

You take it from here.
 

Thread Starter

em_cardc

Joined Apr 5, 2016
43
I'm confused about just what the assignment is. Is the MCU supposed to implement the full-adder such that all of these pins in the diagram correspond to I/O pins on the MCU and the full adder behavior is implement in code? Or is the MCU being used to drive a separate full-adder circuit that is implement using discrete logic gates?

I hope this helps.


Thing is, I don't know if there's a possibility to create the full adder with the MCU (since the MCU has 13 I/O pins/ports) or if it is rather simpler to create the FA with ICs (such as CMOS or any other alternative to such).
 

Thread Starter

em_cardc

Joined Apr 5, 2016
43
I will get you started.
Create variables you need.

int A, B, Cin, Cout, S, D, E, F, G;

Each variable may have only two possible values, 0 or 1.
For example,
A = 0;
B = 1;

Use bitwise boolean operators.
For example F = A AND B is written as:

F = A & B;

F = A OR B is written as:

F = A | B;

You take it from here.
I see what you're trying to communicate here. My only concern is as for the D-G inputs... what is the function of each of these?
 

WBahn

Joined Mar 31, 2012
30,060
I hope this helps.


Thing is, I don't know if there's a possibility to create the full adder with the MCU (since the MCU has 13 I/O pins/ports) or if it is rather simpler to create the FA with ICs (such as CMOS or any other alternative to such).
The diagram makes it clear. The MCU is NOT implementing the full adder. It is being used to TEST a separate full adder circuit. Although normally you would have the Cout and S outputs from the full-adder circuit go back to inputs on the MCU so that the MCU code could generate a set of test inputs to the full adder circuit and then verify that it produces the correct outputs. But I suspect you are at a stage where they are trying to take things one small chunk at a time.

So you are almost certainly expected to implement the full adder circuit using the indicated logic ICs. Using CMOS chips should work fine, just be careful to have the chips sink current to turn on the LEDs (meaning that a lit LED indicates LO output) or use an inverter after each of the outputs so that a LO output from them turns on the LED but indicates a HI output from the full-adder. Also be sure that you use proper current limiting resistors in series with the LEDs.
 

Thread Starter

em_cardc

Joined Apr 5, 2016
43
The diagram makes it clear. The MCU is NOT implementing the full adder. It is being used to TEST a separate full adder circuit. Although normally you would have the Cout and S outputs from the full-adder circuit go back to inputs on the MCU so that the MCU code could generate a set of test inputs to the full adder circuit and then verify that it produces the correct outputs. But I suspect you are at a stage where they are trying to take things one small chunk at a time.

So you are almost certainly expected to implement the full adder circuit using the indicated logic ICs. Using CMOS chips should work fine, just be careful to have the chips sink current to turn on the LEDs (meaning that a lit LED indicates LO output) or use an inverter after each of the outputs so that a LO output from them turns on the LED but indicates a HI output from the full-adder. Also be sure that you use proper current limiting resistors in series with the LEDs.

Alright! One last thing, for my program implementation. There's 8 cases to be taken into account for a FA, some which will light up LED2 (Sum) some LED1 (Cout), one special case where both LEDs are off (0,0) and another where LED1+LED2 are both on (1,1). Is there any possibility in my code that I can shrink the number of cases (in a single loop) to test such conditions?
 

WBahn

Joined Mar 31, 2012
30,060
Alright! One last thing, for my program implementation. There's 8 cases to be taken into account for a FA, some which will light up LED2 (Sum) some LED1 (Cout), one special case where both LEDs are off (0,0) and another where LED1+LED2 are both on (1,1). Is there any possibility in my code that I can shrink the number of cases (in a single loop) to test such conditions?
Normally you would just have your code run through all possible conditions, which is a simple loop that counts from 0 (000) to 7 (111).

How is this test going to be performed? How will you know whether the outputs are correct since you will see the LEDs but won't know what the MCU is providing for inputs while, by the same token, the MCU will know what the inputs are that it is providing but won't know what the corresponding outputs from the full adder are?
 

Thread Starter

em_cardc

Joined Apr 5, 2016
43
Normally you would just have your code run through all possible conditions, which is a simple loop that counts from 0 (000) to 7 (111).

How is this test going to be performed? How will you know whether the outputs are correct since you will see the LEDs but won't know what the MCU is providing for inputs while, by the same token, the MCU will know what the inputs are that it is providing but won't know what the corresponding outputs from the full adder are?
What is assigned in general is to send out each case and produce the output in the LEDs (for example the first case which is all 0 inputs produce a 0 output in both LEDs), once this result is produced the LEDs must hold the value for at least a second (delay?) before moving on to the next case. I am also considering that I must set the LEDs as inputs (P0DIR) which I do not know why it should be set that way? I am guessing that these will be inputs to the MSP430 so that it reads them back and knows when to change?
 

WBahn

Joined Mar 31, 2012
30,060
I would imagine that the LEDs are also supposed to be used as inputs to the MCU precisely for the reason I mentioned -- this is supposed to be a system that tests the correctness of the full adder circuit. It really can't do that unless it has the ability to send outputs to the inputs of the full adder and then to accept the outputs of the full adder as inputs to the MCU so that it can compare what the circuit is supposed to do to what the circuit actually did in order to determine if it passes the test.
 
Top