======XXX class======
The XXX class implements a functioning logical XXX gate for use with our CPU simulator.
=====XXX() constructor=====
XXX myXXXGate;
^ Function ^ Parameter(s) ^ Return value |
| XXX() | none | pointer/variable instantiation of the newly allocated XXX gate |
XXX() is the parameterless constructor that is responsible for creating a new instance of an XXX.
=====reset()=====
reset() will reset both inputs coming into the XXX to FALSE values.
myXXXGate.reset();
^ Function ^ Parameter(s) ^ Return value |
| void reset() | no parameters | none |
=====set(bool)=====
set(bool) will take the parameter and set both inputs to that value.
myXXXGate.set(true);
^ Function ^ Parameter(s) ^ Return value |
| void set() | bool | none |
=====set(bool, bool)=====
set(bool, bool) will take the parameter and set each input to a unique value.
bool a = true;
bool b = false;
...
myXXXGate.set(a, b);
^ Function ^ Parameter(s) ^ Return value |
| void set() | bool, bool | none |
=====setvalue()=====
get() will retrieve the output of the XXX.
bool output = myXXXGate.get();
^ Function ^ Parameter(s) ^ Return value |
| bool get(int) | none | boolean value of gate's output |
\\
**XXX.h**\\
#ifndef _XXX_H
#define _XXX_H
class XXX
{
public:
XXX();
void set();
void set(bool);
void set(bool, bool);
bool get();
private:
bool input1;
bool input2;
};
#endif
\\
**XXX.cc**\\
#include "XXX.h"
XXX::XXX()
{
input1 = input2 = false;
}
void XXX::set()
{
input1 = input2 = false;
}
void XXX::set(bool value)
{
input1 = input2 = value;
}
void XXX::set(bool val1, bool val2)
{
input1 = val1;
input2 = val2;
}
bool XXX::get()
{
bool result = false;
if ((input1 == true) || (input2 == true))
{
result = true;
}
return (result);
}
\\
**XXXtest.cc**\\
#include
#include "XXX.h"
int main()
{
bool a, b;
a = true, b = false;
printf("--------------------\n");
printf("TRUE is: %d\n", true);
printf("FALSE is: %d\n", false);
printf("--------------------\n\n");
XXX myXXXGate;
printf(" a b | x \n");
printf("-----+---\n");
for(int temp = 0; temp <=3; temp++)
{
a = temp & 0x02;
b = temp & 0x01;
//if(temp & 0x02) a = true;
//else a = false;
//if(temp & 0x01) b = true;
//else b = false;
////switch(temp)
////{
//// case 0:
//// a = false;
//// b = false;
//// break;
//// case 1:
//// a = false;
//// b = true;
//// break;
//// case 2:
//// a = true;
//// b = false;
//// break;
//// case 3:
//// a = true;
//// b = true;
//// break;
////}
myXXXGate.set(a, b);
printf(" %d %d | %d\n", a, b, myXXXGate.get());
}
printf("---------\n");
return(0);
}