Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 334 → Rev 335

/Classwork/ECE5505 - Test and Verification/Final Project/Canvas.cpp
0,0 → 1,305
#include "Canvas.h"
 
Canvas::Canvas(QWidget *parent) : QGraphicsView(parent)
{
// Set some drawing options to improve performance
setBackgroundRole(QPalette::Base);
setAutoFillBackground(true);
setFrameStyle(Sunken | StyledPanel);
setRenderHint(QPainter::Antialiasing, true);
setDragMode(QGraphicsView::RubberBandDrag);
setOptimizationFlags(QGraphicsView::DontSavePainterState);
setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
 
scene = new QGraphicsScene;
setScene(scene);
 
zoomLevel = 100;
_pan = false;
 
circuit = NULL;
 
// Draw axis lines when running in debug mode
#ifdef _DEBUG
QGraphicsLineItem *xAxis = new QGraphicsLineItem(-1000, 0, 1000, 0);
QGraphicsLineItem *yAxis = new QGraphicsLineItem(0, -800, 0, 800);
scene->addItem(xAxis);
scene->addItem(yAxis);
debugPen = QPen(QColor(COLOR_WIRE_REGION_OUTLINE), 1, Qt::DashDotLine);
#endif
 
/*
Gate_BASE *g;
for (int i = 1; i < 6; i++) {
g = new Gate_INPUT(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 000);
 
g = new Gate_OUTPUT(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 150);
 
g = new Gate_BUFFER(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 300);
 
g = new Gate_AND(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 500);
 
g = new Gate_NAND(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 700);
 
g = new Gate_OR(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 900);
 
g = new Gate_NOR(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 1100);
 
g = new Gate_XOR(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 1300);
 
g = new Gate_XNOR(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 1500);
 
g = new Gate_NOT(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 1700);
 
g = new Gate_DFF(0, gate_INPUT, i, 0);
scene->addItem(g);
g->setCanvasPosition(BASE_GATE_SIZE_X + i * 2 * (BASE_GATE_SIZE_X + 20), 1900);
}*/
 
}
 
QSize Canvas::minimumSizeHint() const
{
return QSize(400,400);
}
 
QSize Canvas::sizeHint() const
{
return QSize(800,600);
}
 
void Canvas::drawCircuit(Circuit *circuit)
{
 
this->circuit = circuit;
 
// Calculate the maximum distance between gates including spacing
int largestLevelCount = 0; int largestYSize = 0;
for (int i = 0; i < circuit->gatesPerLevel.keys().size(); i++) {
int level = circuit->gatesPerLevel.keys()[i];
QList<Gate_BASE*> gates = circuit->gatesPerLevel[level];
 
// We want center to center distance of top and bottom gate
int levelYSize = (gates[0]->ySize / 2) + (gates[gates.size() - 1]->ySize / 2);
levelYSize += CANVAS_GATE_Y_SPACING * (gates.size() - 1);
for (int j = 1; j < gates.size() - 1; j++) {
levelYSize += gates[j]->ySize;
}
if (levelYSize > largestYSize) {
largestLevelCount = gates.size();
largestYSize = levelYSize;
}
}
 
 
// Iterate through each level of the circuit and draw the gates
int xOffset = 0, yOffset = 0, ySpacing = 0;
int xSize = (circuit->gatesPerLevel.keys().size() - 1) * CANVAS_GATE_X_SPACING;
xOffset = - xSize / 2;
for (int i = 0; i < circuit->gatesPerLevel.keys().size(); i++) {
int level = circuit->gatesPerLevel.keys()[i];
QList<Gate_BASE*> gates = circuit->gatesPerLevel[level];
 
// Calculate offsets and spacing between gates
if (gates.size() == largestLevelCount) {
ySpacing = largestYSize / (gates.size() - 1);
yOffset = - largestYSize / 2;
} else {
ySpacing = largestYSize / (gates.size());
yOffset = - largestYSize / 2 + ySpacing / 2;
}
 
// Draw gates onto canvas
for (int j = 0; j < gates.size(); j++) {
scene->addItem(gates[j]);
connect(gates[j], SIGNAL(updateStatus(QString)), this, SIGNAL(updateStatus(QString)));
gates[j]->setCanvasPosition(xOffset, yOffset);
yOffset += ySpacing;
}
 
xOffset += CANVAS_GATE_X_SPACING;
}
 
/*
// Go through and calculate wiring region between gate objects
wireSpace *vSpacing;
for (int i = 1; i < circuit->gatesPerLevel.keys().size() - 1; i++) {
int level = circuit->gatesPerLevel.keys()[i];
QList<Gate_BASE*> gates = circuit->gatesPerLevel[level];
 
// Compute and save top region
QRectF topSpace = QRectF(gates[0]->x(), -largestYSize / 2, gates[0]->xSize, gates[0]->y() + largestYSize / 2);
vSpacing = new wireSpace;
vSpacing->region = topSpace;
circuit->wireVSpacing[level].append(vSpacing);
 
// Compute and save intermediate regions
for (int j = 0; j < gates.size() - 1; j++) {
QRectF midSpace;
if (gates[j]->xSize >= gates[j+1]->xSize) {
midSpace = QRectF(gates[j]->x(), gates[j]->y() + gates[j]->ySize, gates[j]->xSize, gates[j+1]->y() - (gates[j]->y() + gates[j]->ySize));
} else {
midSpace = QRectF(gates[j+1]->x(), gates[j]->y() + gates[j]->ySize, gates[j+1]->xSize, gates[j+1]->y() - (gates[j]->y() + gates[j]->ySize));
}
 
vSpacing = new wireSpace;
vSpacing->region = midSpace;
circuit->wireVSpacing[level].append(vSpacing);
}
 
// Compute and save bottom region
Gate_BASE *lastGate = gates[gates.size() - 1];
QRectF botSpace = QRectF(lastGate->x(), lastGate->y() + lastGate->ySize, lastGate->xSize, largestYSize / 2 - (lastGate->y() + lastGate->ySize));
vSpacing = new wireSpace;
vSpacing->region = botSpace;
circuit->wireVSpacing[level].append(vSpacing);
 
// Draw regions in debug mode
#ifdef _DEBUG
for (int j = 0; j < circuit->wireVSpacing[level].size(); j++)
scene->addRect(circuit->wireVSpacing[level][j]->region, debugPen, QBrush(QColor(COLOR_WIRE_REGION_V)));
#endif
}*/
 
/*
// Go through and calculate wiring region between levels
wireSpace *hSpacing;
for (int i = 0; i < circuit->gatesPerLevel.keys().size() - 1; i++) {
int level = circuit->gatesPerLevel.keys()[i];
QList<Gate_BASE*> gates = circuit->gatesPerLevel[level];
 
// Compute the max X position for this level and min X position for next level
 
}*/
 
 
// Instantiate wires for each output->input connection on each gate
QList<int> gateIDs = circuit->gateIndex.keys();
for (int i = 0; i < gateIDs.size(); i++) {
Gate_BASE *tmp = circuit->gateIndex[gateIDs[i]];
// Connect each gate's input to other gate's output
for (int j = 0; j < tmp->fanInGates.size(); j++) {
Wire *wire = new Wire();
wire->setPoints(tmp->fanInGates[j], tmp, j);
// Store wires in gates on both ends
tmp->gateInputWires.append(wire);
tmp->fanInGates[j]->gateOutputWires.append(wire);
// Save wire information into circuit
circuit->wires.append(wire);
connect(wire, SIGNAL(updateStatus(QString)), this, SIGNAL(updateStatus(QString)));
connect(circuit, SIGNAL(toggleShowWireValues()), wire, SLOT(toggleShowValues()));
scene->addItem(wire);
}
}
 
scene->update();
emit updateStatus("Circuit file successfully loaded");
}
 
/**
* Zooms the canvas using matrix scaling
*/
void Canvas::zoomCanvas(int level)
{
zoomLevel = level;
 
qreal scale = qPow(qreal(2), (zoomLevel - 160) / qreal(40));
 
QMatrix matrix;
matrix.scale(scale,scale);
 
setMatrix(matrix);
}
 
#ifndef QT_NO_WHEELEVENT
void Canvas::wheelEvent(QWheelEvent *event)
{
// Zoom canvas on scroll wheel
if (event->delta() > 0) {
zoomCanvas(zoomLevel + 5);
emit updateZoomSlider(zoomLevel + 5);
} else {
zoomCanvas(zoomLevel - 5);
emit updateZoomSlider(zoomLevel - 5);
}
event->accept();
}
#endif
 
void Canvas::mousePressEvent(QMouseEvent *event)
{
// If CTRL is held down, pan the canvas
if (event->modifiers() & Qt::ControlModifier) {
_pan = true;
_panStartX = event->x();
_panStartY = event->y();
setCursor(Qt::ClosedHandCursor);
event->accept();
return;
}
 
if (circuit != NULL && circuit->circuitLoaded) {
// Clear any previously selected gates and wires
for (int i = 0; i < circuit->gatesPerLevel.size(); i++) {
QList<Gate_BASE*> gates = circuit->gatesPerLevel[i];
for (int j = 0; j < gates.size(); j++) {
gates[j]->setHighlight(false, QColor(0,0,0,255));
}
}
for (int i = 0; i < circuit->wires.size(); i++) {
circuit->wires[i]->setHighlight(false, QColor(0,0,0,255));
}
updateStatus("");
}
 
// If not panning, propogate event to child objects
QGraphicsView::mousePressEvent(event);
}
 
void Canvas::mouseMoveEvent(QMouseEvent *event)
{
// Process panning if active
if (_pan) {
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - (event->x() - _panStartX));
verticalScrollBar()->setValue(verticalScrollBar()->value() - (event->y() - _panStartY));
_panStartX = event->x();
_panStartY = event->y();
event->accept();
return;
}
 
// Otherwise propogate event to child objects
QGraphicsView::mouseMoveEvent(event);
}
 
void Canvas::mouseReleaseEvent(QMouseEvent *event)
{
// Stop panning if active
_pan = false;
setCursor(Qt::ArrowCursor);
event->accept();
 
// Propogate event to child objects
QGraphicsView::mouseReleaseEvent(event);
}
/Classwork/ECE5505 - Test and Verification/Final Project/Canvas.h
0,0 → 1,56
#ifndef CANVAS_H
#define CANVAS_H
 
#include "GlobalDefines.h"
#include "Circuit.h"
 
#define CANVAS_GATE_X_SPACING 240
#define CANVAS_GATE_Y_SPACING 20
 
#define COLOR_WIRE_REGION_OUTLINE 255,0,0,200
#define COLOR_WIRE_REGION_V 255,0,0,50
#define COLOR_WIRE_REGION_H 0,0,255,50
 
class Canvas : public QGraphicsView
{
Q_OBJECT
public:
Canvas(QWidget *parent = 0);
 
QSize minimumSizeHint() const;
QSize sizeHint() const;
 
void drawCircuit(Circuit *circuit);
 
signals:
void updateZoomSlider(int value);
void updateStatus(QString status);
 
public slots:
void zoomCanvas(int);
 
protected:
#ifndef QT_NO_WHEELEVENT
virtual void wheelEvent(QWheelEvent *event);
#endif
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
 
private:
QGraphicsScene *scene;
QGraphicsTextItem *resolution;
 
int zoomLevel;
 
Circuit *circuit;
 
bool _pan;
int _panStartX, _panStartY;
 
#ifdef _DEBUG
QPen debugPen;
#endif
};
 
#endif // CANVAS_H
/Classwork/ECE5505 - Test and Verification/Final Project/Circuit.cpp
0,0 → 1,209
#include "Circuit.h"
 
Circuit::Circuit()
{
numGates = 0;
numFFs = 0;
numInputs = 0;
numOutputs = 0;
circuitLoaded = false;
 
sim = new Simulator(this);
connect(sim, SIGNAL(updateStatus(QString)), this, SIGNAL(updateStatus(QString)));
}
 
/**
* Reads a circuit (lev) file into local data structure
*/
int Circuit::readGates(QString name)
{
QFile inputFile(name);
 
// Check to make sure file exists before reading
if (!inputFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
lastError = "Unable to open circuit (.lev) file!";
return 1;
}
 
// Open file as stream and begin reading
QTextStream fileStream(&inputFile);
 
int numLines, junk;
int gateID, gateType, gateLevel, gateInputs, gateOutputs;
int input, output;
QMap<int, QList<int> > tmpInputs;
QMap<int, QList<int> > tmpOutputs;
 
fileStream >> numLines;
fileStream >> junk;
for (int i = 0; i < numLines - 1; i++) {
// Read the first four values and create the gate
fileStream >> gateID;
fileStream >> gateType;
fileStream >> gateLevel;
fileStream >> gateInputs;
 
// Initialize an instance of the specified gate
Gate_BASE *gate;
switch ((gType)gateType) {
case gate_UNKNOWN:
break;
case gate_INPUT:
numGates++;
numInputs++;
gate = new Gate_INPUT(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_OUTPUT:
numGates++;
numOutputs++;
gate = new Gate_OUTPUT(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_BUFFER:
numGates++;
gate = new Gate_BUFFER(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_AND:
numGates++;
gate = new Gate_AND(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_NAND:
numGates++;
gate = new Gate_NAND(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_OR:
numGates++;
gate = new Gate_OR(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_NOR:
numGates++;
gate = new Gate_NOR(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_XOR:
numGates++;
gate = new Gate_XOR(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_XNOR:
numGates++;
gate = new Gate_XNOR(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_NOT:
numGates++;
gate = new Gate_NOT(gateID, (gType)gateType, gateInputs, gateLevel);
break;
case gate_DFF:
numGates++;
numFFs++;
gate = new Gate_DFF(gateID, (gType)gateType, gateInputs, gateLevel);
break;
}
 
// Link gate to simulator
connect(gate, SIGNAL(enqueueSim(Gate_BASE*)), sim, SLOT(enqueueGate(Gate_BASE*)));
 
// Store the gate into persistent storage
gateIndex[gateID] = gate;
 
// Seperately map gates to levels
gatesPerLevel[gateLevel].append(gate);
 
// Read and save the inputs to this gate
for (int j = 0; j < gateInputs; j++) {
fileStream >> input;
tmpInputs[gateID].append(input);
}
// Ignore the repeated values
for (int j = 0; j < gateInputs; j++) {
fileStream >> junk;
}
 
// Read and save the outputs from this gate
fileStream >> gateOutputs;
for (int j = 0; j < gateOutputs; j++) {
fileStream >> output;
tmpOutputs[gateID].append(output);
}
 
// Ignore the rest of the line
fileStream.readLine();
}
 
// Once all the gates are allocated, we can go back and properly save fanin/fanouts
// (allows for easier reference and path tracing)
for (int i = 1; i <= numGates; i++) {
Gate_BASE *tmp = gateIndex[i];
for (int j = 0; j < tmpInputs[i].size(); j++) {
tmp->fanInGates.append(gateIndex[tmpInputs[i][j]]);
}
for (int j = 0; j < tmpOutputs[i].size(); j++) {
tmp->fanOutGates.append(gateIndex[tmpOutputs[i][j]]);
}
}
 
circuitLoaded = true;
 
return 0;
}
 
/**
* Reads a vector (vec) file into local data structure
*/
int Circuit::readVectors(QString name)
{
QFile inputFile(name);
 
// Check to make sure file exists before reading
if (!inputFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
lastError = "Unable to open vector (.vec) file!";
return 1;
}
 
return 0;
}
 
/**
* Reads a circuit faults (eqf) file into local data structure
*/
int Circuit::readFaults(QString name)
{
QFile inputFile(name);
 
// Check to make sure file exists before reading
if (!inputFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
lastError = "Unable to open fault (.eqf) file!";
return 1;
}
 
return 0;
}
 
/**
* Returns the last error generated from this class
*/
QString Circuit::getLastError()
{
return lastError;
}
 
/**
* Resets all gate and wire values to unknown 'X'
*/
void Circuit::reset()
{
if (circuitLoaded) {
QList<int> keys = gateIndex.keys();
for (int i = 0; i < gateIndex.size(); i++) {
gateIndex[keys[i]]->reset();
}
}
}
 
/**
* Brings up the circuit simulator control widget
*/
void Circuit::showSimController()
{
simController = new SimController();
connect(simController, SIGNAL(singleStep()), sim, SLOT(singleStep()));
connect(simController, SIGNAL(autoStep()), sim, SLOT(autoStep()));
simController->show();
}
/Classwork/ECE5505 - Test and Verification/Final Project/Circuit.h
0,0 → 1,67
#ifndef CIRCUIT_H
#define CIRCUIT_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
#include "Gate_INPUT.h"
#include "Gate_OUTPUT.h"
#include "Gate_BUFFER.h"
#include "Gate_AND.h"
#include "Gate_NAND.h"
#include "Gate_OR.h"
#include "Gate_NOR.h"
#include "Gate_XOR.h"
#include "Gate_XNOR.h"
#include "Gate_NOT.h"
#include "Gate_DFF.h"
#include "Wire.h"
#include "Simulator.h"
#include "SimController.h"
 
typedef struct {
QRectF region;
} wireSpace;
 
class Simulator;
class SimController;
 
class Circuit : public QObject
{
Q_OBJECT
public:
Circuit();
 
int readGates(QString file);
int readVectors(QString file);
int readFaults(QString file);
 
QString getLastError(void);
 
QMap<int, Gate_BASE*> gateIndex;
QMap<int, QList<Gate_BASE*> > gatesPerLevel;
int numGates;
int numFFs;
int numInputs;
int numOutputs;
 
bool circuitLoaded;
 
QList<Wire*> wires;
QMap<int, QList<wireSpace*> > wireVSpacing;
QMap<int, QList<wireSpace*> > wireHSpacing;
 
signals:
void updateStatus(QString status);
void toggleShowWireValues();
 
public slots:
void reset();
void showSimController();
 
private:
Simulator *sim;
SimController *simController;
QString lastError;
};
 
#endif // CIRCUIT_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_AND.cpp
0,0 → 1,99
#include "Gate_AND.h"
 
Gate_AND::Gate_AND(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
textRect = QRectF(BORDER_OFFSET, BORDER_OFFSET, xSize - BORDER_OFFSET * 3, ySize - BORDER_OFFSET * 2);
}
 
void Gate_AND::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs < 2) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
for (int i = 0; i < numInputs; i++) {
painter->drawEllipse(inputPoints[i], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
}
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
painter->drawLine(BORDER_OFFSET, BORDER_OFFSET, BORDER_OFFSET, ySize - BORDER_OFFSET);
painter->drawLine(BORDER_OFFSET, BORDER_OFFSET, xSize - (BORDER_OFFSET * (numInputs + 1.5)), BORDER_OFFSET);
painter->drawLine(BORDER_OFFSET, ySize - BORDER_OFFSET, xSize - (BORDER_OFFSET * (numInputs + 1.5)), ySize - BORDER_OFFSET);
 
QRect arcBox(xSize - BORDER_OFFSET * (numInputs + 1) * 2, BORDER_OFFSET, BORDER_OFFSET * (numInputs + 1) * 2 - BORDER_OFFSET, ySize - BORDER_OFFSET * 2);
painter->drawArc(arcBox, -90 * 16, 180 * 16);
 
// Draw I/O lines
for (int i = 0; i < numInputs; i++) {
painter->drawLine(inputPoints[i], QPointF(inputPoints[i].x() + BORDER_OFFSET, inputPoints[i].y()));
}
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_AND::simulateToOutput()
{
// Save initial values to compare to later
logicValue initValue = outputValue;
logicValue initFaultyValue = outputFaultyValue;
 
// Compute new output values
bool undefined = false, undefinedFaulty = false;
bool allOnes = true, allOnesFaulty = true;
bool allZeros = true, allZerosFaulty = true;
for (int i = 0; i < numInputs; i++) {
if (inputValues[i] == logicValue_X) undefined = true;
if (inputValues[i] == logicValue_0) allOnes = false;
if (inputValues[i] == logicValue_1) allZeros = false;
 
if (inputFaultyValues[i] == logicValue_X) undefinedFaulty = true;
if (inputFaultyValues[i] == logicValue_0) allOnesFaulty = false;
if (inputFaultyValues[i] == logicValue_1) allZerosFaulty = false;
}
 
if (undefined) outputValue = logicValue_X;
else if (allOnes) outputValue = logicValue_1;
else outputValue = logicValue_0;
 
if (undefinedFaulty) outputFaultyValue = logicValue_X;
else if (allOnesFaulty) outputFaultyValue = logicValue_1;
else outputFaultyValue = logicValue_0;
 
// If outputs have changed, queue the connected gate for simulation
if (outputValue != initValue || outputFaultyValue != initFaultyValue)
emit enqueueSim(this);
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_AND.h
0,0 → 1,17
#ifndef GATE_AND_H
#define GATE_AND_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_AND : public Gate_BASE
{
public:
Gate_AND(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_AND_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_BASE.cpp
0,0 → 1,221
#include "Gate_BASE.h"
 
Gate_BASE::Gate_BASE(int gateID, gType gateType,
int numInputs, int gateLevel,
QGraphicsItem *parent) :
QGraphicsObject(parent)
{
setFlags(ItemIsSelectable);
 
auxSelected = false;
 
this->gateID = gateID;
this->gateType = gateType;
this->numInputs = numInputs;
this->gateLevel = gateLevel;
this->enqueued = false;
 
this->xSize = BASE_GATE_SIZE_X + ADDITONAL_INPUTS * qMax(numInputs, 1);
this->ySize = BASE_GATE_SIZE_Y + ADDITONAL_INPUTS * qMax(numInputs, 1);
 
// Create the default pens to draw with
this->defaultPen = QPen(QColor(COLOR_MAIN), DEFAULT_LINE_WIDTH, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
this->defaultBrush = QBrush(Qt::NoBrush);
this->defaultFont = QFont("Consolas", 20);
this->selectedPen = QPen(QColor(COLOR_MAIN_SELECTED), DEFAULT_LINE_WIDTH, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
this->highlightedPen = QPen(QColor(COLOR_MAIN_SELECTED), DEFAULT_LINE_WIDTH, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
 
// Calculate local and global points for inputs
float spacer = float(this->ySize - BORDER_OFFSET * 2) / (numInputs + 1);
for (int i = 0; i < numInputs; i++) {
QPointF point = QPointF(0, this->ySize - BORDER_OFFSET - (spacer * i + spacer));
this->inputPoints.push_back(point);
QPointF scenePoint = QPointF(this->scenePos().x(), this->scenePos().y() - BORDER_OFFSET - (spacer * i + spacer));
this->gateInputPoints.push_back(scenePoint);
}
 
// Output point will always be centered on the right edge
this->outputPoint = QPointF(this->xSize, this->ySize / 2);
this->gateOutputPoint = QPointF(this->scenePos().x() + this->xSize, this->scenePos().y() + this->ySize / 2);
 
// Reset I/O values to 'X'
for (int i = 0; i < numInputs; i++) {
inputValues.append(logicValue_X);
inputFaultyValues.append(logicValue_X);
}
outputValue = logicValue_X;
outputFaultyValue = logicValue_X;
 
#ifdef _DEBUG
this->debugPen = QPen(QColor(COLOR_DEBUG), 1, Qt::DashLine);
this->debugBrush = QBrush(Qt::NoBrush);
this->debugSelectedPen = QPen(QColor(COLOR_DEBUG_SELECTED), 1, Qt::DashLine);
this->debugErrorPen = QPen(QColor(COLOR_DEBUG_ERROR), 2, Qt::DashLine);
#endif
}
 
Gate_BASE::~Gate_BASE()
{
 
}
 
QRectF Gate_BASE::boundingRect() const
{
return QRectF(0, 0, xSize, ySize);
}
 
QPainterPath Gate_BASE::shape() const
{
QPainterPath path;
path.addRect(BORDER_OFFSET, BORDER_OFFSET, xSize - BORDER_OFFSET * 2, ySize - BORDER_OFFSET * 2);
return path;
}
 
/**
* Sets the position of this gate (centered) on the scene
*/
void Gate_BASE::setCanvasPosition(int x, int y)
{
canvasPoint.setX(x);
canvasPoint.setY(y);
 
// Canvas position correlates to the center of the gate
this->setPos(x - xSize / 2, y - ySize / 2);
 
// Calculate points for inputs
float spacer = float(this->ySize - BORDER_OFFSET * 2) / (numInputs + 1);
this->gateInputPoints.clear();
for (int i = 0; i < numInputs; i++) {
QPointF scenePoint = QPointF(this->scenePos().x(), this->scenePos().y() + BORDER_OFFSET + (spacer * i + spacer));
this->gateInputPoints.push_back(scenePoint);
}
 
// Output point will always be centered on the right edge
this->gateOutputPoint = QPointF(this->scenePos().x() + this->xSize, this->scenePos().y() + this->ySize / 2);
}
 
/**
* Sets the color of the drawing pen
*/
void Gate_BASE::setHighlight(bool state, QColor color)
{
auxSelected = state;
if (state) {
highlightedPen.setColor(color);
setZValue(SELECTED_Z);
} else {
setZValue(GATE_DEFAULT_Z);
}
update();
}
 
/**
* Resets the gate's value to unknown 'X'
*/
void Gate_BASE::reset()
{
// Reset I/O values to 'X'
for (int i = 0; i < numInputs; i++) {
inputValues[i] = logicValue_X;
inputFaultyValues[i] = logicValue_X;
}
outputValue = logicValue_X;
outputFaultyValue = logicValue_X;
 
// Reset connected wires
for (int i = 0; i < gateInputWires.size(); i++)
gateInputWires[i]->setValue(logicValue_X, logicValue_X, false);
for (int i = 0; i < gateOutputWires.size(); i++)
gateOutputWires[i]->setValue(logicValue_X, logicValue_X, false);
 
enqueued = false;
update();
}
 
/**
* Sets a specific input to this gate
*/
void Gate_BASE::setInputValue(int input, logicValue value, logicValue faultyValue)
{
// If the input has changed, queue this gate for simulation
if (inputValues[input] != value || inputFaultyValues[input] != faultyValue)
emit enqueueSim(this);
 
inputValues[input] = value;
inputFaultyValues[input] = faultyValue;
}
 
/**
* Sets the output value of this gate
*/
void Gate_BASE::setOutputValue(logicValue value, logicValue faultyValue)
{
outputValue = value;
outputFaultyValue = faultyValue;
}
 
/**
* Updates flag to indicate queued status
*/
void Gate_BASE::setEnqueued(bool value)
{
enqueued = value;
update();
}
 
void Gate_BASE::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
// Update status bar with information on this gate
QString status = QString("Gate %1 ").arg(gateID);
if (fanInGates.size() != 0)
status += "| Input Gates: ";
for (int i = 0; i < fanInGates.size(); i++) {
status += QString("%1 ").arg(fanInGates[i]->gateID);
if (inputValues[i] == logicValue_0) status += "(0/";
else if (inputValues[i] == logicValue_1) status += "(1/";
else status += "(X/";
if (inputFaultyValues[i] == logicValue_0) status += "0) ";
else if (inputFaultyValues[i] == logicValue_1) status += "1) ";
else status += "X) ";
}
if (fanOutGates.size() != 0) {
status += "| Output Gates: ";
for (int i = 0; i < fanOutGates.size(); i++)
status += QString("%1 ").arg(fanOutGates[i]->gateID);
if (outputValue == logicValue_0) status += "(0/";
else if (outputValue == logicValue_1) status += "(1/";
else status += "(X/";
if (outputFaultyValue == logicValue_0) status += "0) ";
else if (outputFaultyValue == logicValue_1) status += "1) ";
else status += "X) ";
}
emit updateStatus(status);
 
// On gate selection, highlight the input and output gates/wires
setZValue(1);
setHighlight(true, QColor(COLOR_MAIN_SELECTED));
for (int i = 0; i < fanInGates.size(); i++)
fanInGates[i]->setHighlight(true, QColor(COLOR_INPUT_SELECTED));
for (int i = 0; i < fanOutGates.size(); i++)
fanOutGates[i]->setHighlight(true, QColor(COLOR_OUTPUT_SELECTED));
for (int i = 0; i < gateInputWires.size(); i++)
gateInputWires[i]->setHighlight(true, QColor(COLOR_INPUT_SELECTED));
for (int i = 0; i < gateOutputWires.size(); i++)
gateOutputWires[i]->setHighlight(true, QColor(COLOR_OUTPUT_SELECTED));
event->accept();
}
 
/*
void Gate_BASE::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
QMenu menu;
menu.addAction(injectValueAction);
menu.exec(event->screenPos());
event->accept();
}
 
void Gate_BASE::createActions()
{
injectValueAction = new QAction("&Inject Value/Fault", this);
}
*/
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_BASE.h
0,0 → 1,127
#ifndef Gate_BASE_H
#define Gate_BASE_H
 
#include "GlobalDefines.h"
#include "Wire.h"
 
#define BASE_GATE_SIZE_X 100
#define BASE_GATE_SIZE_Y 80
#define ADDITONAL_INPUTS 20
#define INPUT_CIRCLE_SIZE qreal(5)
#define BORDER_OFFSET 20
#define DEFAULT_LINE_WIDTH 3
#define ENQUEUED_CIRCLE_WIDTH 20
 
#define COLOR_MAIN 0,0,0,255
#define COLOR_MAIN_SELECTED 200,0,200,255
#define COLOR_INPUT COLOR_MAIN
#define COLOR_INPUT_SELECTED 255,0,0,255
#define COLOR_OUTPUT COLOR_MAIN
#define COLOR_OUTPUT_SELECTED 0,0,255,255
#define COLOR_DEBUG 0,0,0,100
#define COLOR_DEBUG_SELECTED 0,255,0,100
#define COLOR_DEBUG_ERROR 255,0,0,200
 
#define GATE_DEFAULT_Z 0
#define WIRE_DEFAULT_Z 1
#define SELECTED_Z 2
 
class Wire;
 
typedef enum {
gate_UNKNOWN = 0,
gate_INPUT = 1,
gate_OUTPUT = 2,
gate_XOR = 3,
gate_XNOR = 4,
gate_DFF = 5,
gate_AND = 6,
gate_NAND = 7,
gate_OR = 8,
gate_NOR = 9,
gate_NOT = 10,
gate_BUFFER = 11
} gType;
 
/* Generic gate object */
class Gate_BASE : public QGraphicsObject
{
Q_OBJECT
public:
Gate_BASE(int gateID, gType type,
int numInputs, int gateLevel,
QGraphicsItem *parent = 0);
~Gate_BASE();
 
QRectF boundingRect() const;
QPainterPath shape() const;
 
// paint() should be overwritten by child classes
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)=0;
 
void setCanvasPosition(int x, int y);
void setHighlight(bool state, QColor color);
 
void reset(void);
void setInputValue(int input, logicValue value, logicValue faultyValue);
void setOutputValue(logicValue value, logicValue faultyValue);
void setEnqueued(bool value);
 
virtual void simulateToOutput()=0;
 
// Variables
int xSize, ySize;
QPoint canvasPoint;
 
int gateID;
gType gateType;
int numInputs;
int gateLevel;
 
QList<logicValue> inputValues;
QList<logicValue> inputFaultyValues;
logicValue outputValue;
logicValue outputFaultyValue;
 
QList<Gate_BASE*> fanInGates;
QList<Gate_BASE*> fanOutGates;
QList<QPointF> gateInputPoints; // Scene inputs
QPointF gateOutputPoint; // Scene outputs
 
QList<Wire*> gateInputWires;
QList<Wire*> gateOutputWires;
 
signals:
void updateStatus(QString status);
void enqueueSim(Gate_BASE *gate);
 
public slots:
 
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
 
bool auxSelected;
bool enqueued;
 
// 'Local' points for I/O
QList<QPointF> inputPoints;
QPointF outputPoint;
 
QPen defaultPen;
QBrush defaultBrush;
QFont defaultFont;
 
QPen selectedPen;
QPen highlightedPen;
 
QRectF textRect;
 
#ifdef _DEBUG
QPen debugPen;
QBrush debugBrush;
QPen debugSelectedPen;
QPen debugErrorPen;
#endif
};
 
#endif // Gate_BASE_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_BUFFER.cpp
0,0 → 1,89
#include "Gate_BUFFER.h"
 
Gate_BUFFER::Gate_BUFFER(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
// Override base gate to limit to one I/O point only
this->xSize = BASE_GATE_SIZE_X;
this->ySize = BASE_GATE_SIZE_Y + ADDITONAL_INPUTS;
 
QPointF point = QPointF(0, this->ySize / 2);
this->inputPoints[0] = point;
QPointF scenePoint = QPointF(this->scenePos().x(), this->scenePos().y() + this->ySize / 2);
this->gateInputPoints[0] = scenePoint;
 
outputPoint = QPointF(this->xSize, this->ySize / 2);
gateOutputPoint = QPointF(this->scenePos().x() + this->xSize, this->scenePos().y() + this->ySize / 2);
 
textRect = QRectF(BORDER_OFFSET, BORDER_OFFSET, xSize - BORDER_OFFSET * 3, ySize - BORDER_OFFSET * 2);
}
 
void Gate_BUFFER::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs != 1) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
painter->drawEllipse(inputPoints[0], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
QPointF points[3] = {
QPointF(BORDER_OFFSET, BORDER_OFFSET),
QPointF(xSize - BORDER_OFFSET, ySize / 2),
QPointF(BORDER_OFFSET, ySize - BORDER_OFFSET)
};
painter->drawPolygon(points, 3);
 
// Draw I/O lines
painter->drawLine(inputPoints[0], QPointF(inputPoints[0].x() + BORDER_OFFSET, inputPoints[0].y()));
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_BUFFER::simulateToOutput()
{
// Save initial values to compare to later
logicValue initValue = outputValue;
logicValue initFaultyValue = outputFaultyValue;
 
// Compute new output values
outputValue = inputValues[0];
outputFaultyValue = inputFaultyValues[0];
 
// If outputs have changed, queue the connected gate for simulation
if (outputValue != initValue || outputFaultyValue != initFaultyValue)
emit enqueueSim(this);
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_BUFFER.h
0,0 → 1,17
#ifndef GATE_BUFFER_H
#define GATE_BUFFER_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_BUFFER : public Gate_BASE
{
public:
Gate_BUFFER(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_BUFFER_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_DFF.cpp
0,0 → 1,89
#include "Gate_DFF.h"
 
Gate_DFF::Gate_DFF(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
// Override base gate to limit to one I/O point only
this->xSize = BASE_GATE_SIZE_X + ADDITONAL_INPUTS;
this->ySize = BASE_GATE_SIZE_Y + ADDITONAL_INPUTS * 2;
 
QPointF point = QPointF(0, ADDITONAL_INPUTS * 2);
this->inputPoints[0] = point;
QPointF scenePoint = QPointF(this->scenePos().x(), this->scenePos().y() + ADDITONAL_INPUTS * 2);
this->gateInputPoints[0] = scenePoint;
 
outputPoint = QPointF(this->xSize, ADDITONAL_INPUTS * 2);
gateOutputPoint = QPointF(this->scenePos().x() + this->xSize, this->scenePos().y() + ADDITONAL_INPUTS * 2);
 
textRect = QRectF(BORDER_OFFSET, BORDER_OFFSET * 2, xSize - BORDER_OFFSET * 2, ySize - BORDER_OFFSET * 3);
}
 
void Gate_DFF::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs != 1) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
painter->drawEllipse(inputPoints[0], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
QRectF rect = QRectF(BORDER_OFFSET, BORDER_OFFSET, xSize - BORDER_OFFSET * 2, ySize - BORDER_OFFSET * 2);
painter->drawRect(rect);
 
painter->setFont(QFont("Consolas", 20));
painter->drawText(QPointF(BORDER_OFFSET * 1.5, BORDER_OFFSET * 2.5), "D");
painter->drawText(QPointF(xSize - BORDER_OFFSET * 2.5, BORDER_OFFSET * 2.5), "Q");
 
// Draw I/O lines
painter->drawLine(inputPoints[0], QPointF(inputPoints[0].x() + BORDER_OFFSET, inputPoints[0].y()));
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_DFF::simulateToOutput()
{
// Save initial values to compare to later
logicValue initValue = outputValue;
logicValue initFaultyValue = outputFaultyValue;
 
// Compute new output values
outputValue = inputValues[0];
outputFaultyValue = inputFaultyValues[0];
 
// If outputs have changed, queue the connected gate for simulation
if (outputValue != initValue || outputFaultyValue != initFaultyValue)
emit enqueueSim(this);
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_DFF.h
0,0 → 1,17
#ifndef GATE_DFF_H
#define GATE_DFF_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_DFF : public Gate_BASE
{
public:
Gate_DFF(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_DFF_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_INPUT.cpp
0,0 → 1,146
#include "Gate_INPUT.h"
 
Gate_INPUT::Gate_INPUT(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
// Override base gate to limit to one output point only
this->xSize = BASE_GATE_SIZE_X + ADDITONAL_INPUTS;
this->ySize = BASE_GATE_SIZE_Y + ADDITONAL_INPUTS;
 
outputPoint = QPointF(this->xSize, this->ySize / 2);
gateOutputPoint = QPointF(this->scenePos().x() + this->xSize, this->scenePos().y() + this->ySize / 2);
 
textRect = QRectF(BORDER_OFFSET, BORDER_OFFSET, xSize - BORDER_OFFSET * 3, ySize - BORDER_OFFSET * 2);
 
createActions();
}
 
void Gate_INPUT::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs != 0) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
QPointF points[5] = {
QPointF(BORDER_OFFSET, BORDER_OFFSET),
QPointF(xSize - BORDER_OFFSET * 2, BORDER_OFFSET),
QPointF(xSize - BORDER_OFFSET, ySize / 2),
QPointF(xSize - BORDER_OFFSET * 2, ySize - BORDER_OFFSET),
QPointF(BORDER_OFFSET, ySize - BORDER_OFFSET)
};
painter->drawPolygon(points, 5);
 
// Draw I/O lines
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_INPUT::simulateToOutput()
{
// Do nothing
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
 
void Gate_INPUT::promptValue()
{
// Prompt for the input value
bool ok;
QStringList options;
options << "0" << "1" << "X";
QString sel = QInputDialog::getItem(0, "Choose Value", "Enter Value:", options, 0, false, &ok);
if (ok && !sel.isEmpty()) {
if (sel == "0") {
outputValue = logicValue_0;
outputFaultyValue = logicValue_0;
} else if (sel == "1") {
outputValue = logicValue_1;
outputFaultyValue = logicValue_1;
} else {
outputValue = logicValue_X;
outputFaultyValue = logicValue_X;
}
}
 
// Propogate to connected wires
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
 
void Gate_INPUT::promptFaultyValue()
{
// Prompt for the fault value
bool ok;
QStringList options;
options << "0" << "1" << "X";
QString sel = QInputDialog::getItem(0, "Choose Value", "Enter Value:", options, 0, false, &ok);
if (ok && !sel.isEmpty()) {
if (sel == "0") {
outputValue = logicValue_1;
outputFaultyValue = logicValue_0;
} else if (sel == "1") {
outputValue = logicValue_0;
outputFaultyValue = logicValue_1;
} else {
outputValue = logicValue_X;
outputFaultyValue = logicValue_X;
}
}
 
// Propogate to connected wires
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
 
void Gate_INPUT::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
QMenu menu;
menu.addAction(setInputValueAction);
menu.addAction(setFaultValueAction);
menu.exec(event->screenPos());
event->accept();
}
 
void Gate_INPUT::createActions()
{
setInputValueAction = new QAction("&Set Value", this);
connect(setInputValueAction, SIGNAL(triggered()), this, SLOT(promptValue()));
 
setFaultValueAction = new QAction("&Inject Fault", this);
connect(setFaultValueAction, SIGNAL(triggered()), this, SLOT(promptFaultyValue()));
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_INPUT.h
0,0 → 1,33
#ifndef Gate_INPUT_H
#define Gate_INPUT_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_INPUT : public Gate_BASE
{
Q_OBJECT
public:
Gate_INPUT(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
 
signals:
 
public slots:
void promptValue();
void promptFaultyValue();
 
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
 
private:
void createActions();
QAction *setInputValueAction;
QAction *setFaultValueAction;
 
};
 
#endif // Gate_INPUT_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_NAND.cpp
0,0 → 1,101
#include "Gate_NAND.h"
 
Gate_NAND::Gate_NAND(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
textRect = QRectF(BORDER_OFFSET, BORDER_OFFSET, xSize - BORDER_OFFSET * 3, ySize - BORDER_OFFSET * 2);
}
 
void Gate_NAND::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs < 2) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
for (int i = 0; i < numInputs; i++) {
painter->drawEllipse(inputPoints[i], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
}
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
painter->drawLine(BORDER_OFFSET, BORDER_OFFSET, BORDER_OFFSET, ySize - BORDER_OFFSET);
painter->drawLine(BORDER_OFFSET, BORDER_OFFSET, xSize - (BORDER_OFFSET * (numInputs + 1.5)) - BORDER_OFFSET, BORDER_OFFSET);
painter->drawLine(BORDER_OFFSET, ySize - BORDER_OFFSET, xSize - (BORDER_OFFSET * (numInputs + 1.5)) - BORDER_OFFSET, ySize - BORDER_OFFSET);
 
QRect arcBox(xSize - BORDER_OFFSET * (numInputs + 1) * 2 - BORDER_OFFSET, BORDER_OFFSET, BORDER_OFFSET * (numInputs + 1) * 2 - BORDER_OFFSET, ySize - BORDER_OFFSET * 2);
painter->drawArc(arcBox, -90 * 16, 180 * 16);
 
painter->drawEllipse(QPoint(xSize - BORDER_OFFSET - BORDER_OFFSET / 2, ySize / 2), BORDER_OFFSET / 2, BORDER_OFFSET / 2);
 
// Draw I/O lines
for (int i = 0; i < numInputs; i++) {
painter->drawLine(inputPoints[i], QPointF(inputPoints[i].x() + BORDER_OFFSET, inputPoints[i].y()));
}
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_NAND::simulateToOutput()
{
// Save initial values to compare to later
logicValue initValue = outputValue;
logicValue initFaultyValue = outputFaultyValue;
 
// Compute new output values
bool undefined = false, undefinedFaulty = false;
bool allOnes = true, allOnesFaulty = true;
bool allZeros = true, allZerosFaulty = true;
for (int i = 0; i < numInputs; i++) {
if (inputValues[i] == logicValue_X) undefined = true;
if (inputValues[i] == logicValue_0) allOnes = false;
if (inputValues[i] == logicValue_1) allZeros = false;
 
if (inputFaultyValues[i] == logicValue_X) undefinedFaulty = true;
if (inputFaultyValues[i] == logicValue_0) allOnesFaulty = false;
if (inputFaultyValues[i] == logicValue_1) allZerosFaulty = false;
}
 
if (undefined) outputValue = logicValue_X;
else if (allOnes) outputValue = logicValue_0;
else outputValue = logicValue_1;
 
if (undefinedFaulty) outputFaultyValue = logicValue_X;
else if (allOnesFaulty) outputFaultyValue = logicValue_0;
else outputFaultyValue = logicValue_1;
 
// If outputs have changed, queue the connected gate for simulation
if (outputValue != initValue || outputFaultyValue != initFaultyValue)
emit enqueueSim(this);
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_NAND.h
0,0 → 1,17
#ifndef GATE_NAND_H
#define GATE_NAND_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_NAND : public Gate_BASE
{
public:
Gate_NAND(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_NAND_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_NOR.cpp
0,0 → 1,109
#include "Gate_NOR.h"
 
Gate_NOR::Gate_NOR(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
textRect = QRectF(BORDER_OFFSET * 1.2, BORDER_OFFSET, xSize - BORDER_OFFSET * 3, ySize - BORDER_OFFSET * 2);
}
 
void Gate_NOR::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs < 2) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
for (int i = 0; i < numInputs; i++) {
painter->drawEllipse(inputPoints[i], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
}
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
QRectF leftArcBox = QRectF(0, BORDER_OFFSET, BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2), ySize - BORDER_OFFSET * 2);
leftArcBox.translate(BORDER_OFFSET - (BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2)) / 2, 0);
painter->drawArc(leftArcBox, -90 * 16, 180 * 16);
 
QRectF rightArcBox = QRectF(0, BORDER_OFFSET, 2 * (xSize - (BORDER_OFFSET * 2)) - BORDER_OFFSET * 2, ySize - (BORDER_OFFSET * 2));
rightArcBox.translate(-xSize + BORDER_OFFSET * 4, 0);
painter->drawArc(rightArcBox, 0, 90 * 16);
painter->drawArc(rightArcBox, -90 * 16, 90 * 16);
 
painter->drawEllipse(QPoint(xSize - BORDER_OFFSET - BORDER_OFFSET / 2, ySize / 2), BORDER_OFFSET / 2, BORDER_OFFSET / 2);
 
// Draw I/O lines
int a = leftArcBox.width() / 2;
int b = leftArcBox.height() / 2;
QPointF arcCenter = leftArcBox.center();
for (int i = 0; i < numInputs; i++) {
float xPt = sqrt((1 - pow(inputPoints[i].y() - arcCenter.y(), 2) / (b * b)) * (a * a)) + arcCenter.x();
painter->drawLine(inputPoints[i], QPointF(xPt, inputPoints[i].y()));
}
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_NOR::simulateToOutput()
{
// Save initial values to compare to later
logicValue initValue = outputValue;
logicValue initFaultyValue = outputFaultyValue;
 
// Compute new output values
bool undefined = false, undefinedFaulty = false;
bool allOnes = true, allOnesFaulty = true;
bool allZeros = true, allZerosFaulty = true;
for (int i = 0; i < numInputs; i++) {
if (inputValues[i] == logicValue_X) undefined = true;
if (inputValues[i] == logicValue_0) allOnes = false;
if (inputValues[i] == logicValue_1) allZeros = false;
 
if (inputFaultyValues[i] == logicValue_X) undefinedFaulty = true;
if (inputFaultyValues[i] == logicValue_0) allOnesFaulty = false;
if (inputFaultyValues[i] == logicValue_1) allZerosFaulty = false;
}
 
if (!allZeros) outputValue = logicValue_0;
else if (allZeros && undefined) outputValue = logicValue_X;
else if (allZeros) outputValue = logicValue_1;
else outputValue = logicValue_X;
 
if (!allZerosFaulty) outputFaultyValue = logicValue_0;
else if (allZerosFaulty && undefinedFaulty) outputFaultyValue = logicValue_X;
else if (allZerosFaulty) outputFaultyValue = logicValue_1;
else outputFaultyValue = logicValue_X;
 
// If outputs have changed, queue the connected gate for simulation
if (outputValue != initValue || outputFaultyValue != initFaultyValue)
emit enqueueSim(this);
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_NOR.h
0,0 → 1,17
#ifndef GATE_NOR_H
#define GATE_NOR_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_NOR : public Gate_BASE
{
public:
Gate_NOR(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_NOR_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_NOT.cpp
0,0 → 1,93
#include "Gate_NOT.h"
 
Gate_NOT::Gate_NOT(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
// Override base gate to limit to one I/O point only
this->xSize = BASE_GATE_SIZE_X + ADDITONAL_INPUTS;
this->ySize = BASE_GATE_SIZE_Y + ADDITONAL_INPUTS;
 
QPointF point = QPointF(0, this->ySize / 2);
this->inputPoints[0] = point;
QPointF scenePoint = QPointF(this->scenePos().x(), this->scenePos().y() - this->ySize / 2);
this->gateInputPoints[0] = scenePoint;
 
outputPoint = QPointF(this->xSize, this->ySize / 2);
gateOutputPoint = QPointF(this->scenePos().x() + this->xSize, this->scenePos().y() + this->ySize / 2);
 
textRect = QRectF(BORDER_OFFSET, BORDER_OFFSET, xSize - BORDER_OFFSET * 4, ySize - BORDER_OFFSET * 2);
}
 
void Gate_NOT::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs != 1) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
painter->drawEllipse(inputPoints[0], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
QPointF points[3] = {
QPointF(BORDER_OFFSET, BORDER_OFFSET),
QPointF(xSize - BORDER_OFFSET * 2, ySize / 2),
QPointF(BORDER_OFFSET, ySize - BORDER_OFFSET)
};
painter->drawPolygon(points, 3);
painter->drawEllipse(QPoint(xSize - BORDER_OFFSET - BORDER_OFFSET / 2, ySize / 2), BORDER_OFFSET / 2, BORDER_OFFSET / 2);
 
// Draw I/O lines
painter->drawLine(inputPoints[0], QPointF(inputPoints[0].x() + BORDER_OFFSET, inputPoints[0].y()));
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_NOT::simulateToOutput()
{
// Save initial values to compare to later
logicValue initValue = outputValue;
logicValue initFaultyValue = outputFaultyValue;
 
// Compute new output values
if (inputValues[0] == logicValue_0) outputValue = logicValue_1;
else if (inputValues[0] == logicValue_1) outputValue = logicValue_0;
 
if (inputFaultyValues[0] == logicValue_0) outputFaultyValue = logicValue_1;
else if (inputFaultyValues[0] == logicValue_1) outputFaultyValue = logicValue_0;
 
// If outputs have changed, queue the connected gate for simulation
if (outputValue != initValue || outputFaultyValue != initFaultyValue)
emit enqueueSim(this);
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_NOT.h
0,0 → 1,17
#ifndef GATE_NOT_H
#define GATE_NOT_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_NOT : public Gate_BASE
{
public:
Gate_NOT(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_NOT_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_OR.cpp
0,0 → 1,107
#include "Gate_OR.h"
 
Gate_OR::Gate_OR(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
textRect = QRectF(BORDER_OFFSET * 1.5, BORDER_OFFSET, xSize - BORDER_OFFSET * 3, ySize - BORDER_OFFSET * 2);
}
 
void Gate_OR::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs < 2) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
for (int i = 0; i < numInputs; i++) {
painter->drawEllipse(inputPoints[i], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
}
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
QRectF leftArcBox = QRectF(0, BORDER_OFFSET, BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2), ySize - BORDER_OFFSET * 2);
leftArcBox.translate(BORDER_OFFSET - (BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2)) / 2, 0);
painter->drawArc(leftArcBox, -90 * 16, 180 * 16);
 
QRectF rightArcBox = QRectF(0, BORDER_OFFSET, 2 * (xSize - (BORDER_OFFSET * 2)), ySize - (BORDER_OFFSET * 2));
rightArcBox.translate(-xSize + BORDER_OFFSET * 3, 0);
painter->drawArc(rightArcBox, 0, 90 * 16);
painter->drawArc(rightArcBox, -90 * 16, 90 * 16);
 
// Draw I/O lines
int a = leftArcBox.width() / 2;
int b = leftArcBox.height() / 2;
QPointF arcCenter = leftArcBox.center();
for (int i = 0; i < numInputs; i++) {
float xPt = sqrt((1 - pow(inputPoints[i].y() - arcCenter.y(), 2) / (b * b)) * (a * a)) + arcCenter.x();
painter->drawLine(inputPoints[i], QPointF(xPt, inputPoints[i].y()));
}
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_OR::simulateToOutput()
{
// Save initial values to compare to later
logicValue initValue = outputValue;
logicValue initFaultyValue = outputFaultyValue;
 
// Compute new output values
bool undefined = false, undefinedFaulty = false;
bool allOnes = true, allOnesFaulty = true;
bool allZeros = true, allZerosFaulty = true;
for (int i = 0; i < numInputs; i++) {
if (inputValues[i] == logicValue_X) undefined = true;
if (inputValues[i] == logicValue_0) allOnes = false;
if (inputValues[i] == logicValue_1) allZeros = false;
 
if (inputFaultyValues[i] == logicValue_X) undefinedFaulty = true;
if (inputFaultyValues[i] == logicValue_0) allOnesFaulty = false;
if (inputFaultyValues[i] == logicValue_1) allZerosFaulty = false;
}
 
if (!allZeros) outputValue = logicValue_1;
else if (allZeros && undefined) outputValue = logicValue_X;
else if (allZeros) outputValue = logicValue_0;
else outputValue = logicValue_X;
 
if (!allZerosFaulty) outputFaultyValue = logicValue_1;
else if (allZerosFaulty && undefinedFaulty) outputFaultyValue = logicValue_X;
else if (allZerosFaulty) outputFaultyValue = logicValue_0;
else outputFaultyValue = logicValue_X;
 
// If outputs have changed, queue the connected gate for simulation
if (outputValue != initValue || outputFaultyValue != initFaultyValue)
emit enqueueSim(this);
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_OR.h
0,0 → 1,17
#ifndef GATE_OR_H
#define GATE_OR_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_OR : public Gate_BASE
{
public:
Gate_OR(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_OR_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_OUTPUT.cpp
0,0 → 1,71
#include "Gate_OUTPUT.h"
 
Gate_OUTPUT::Gate_OUTPUT(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
// Override base gate to limit to one input point only
this->xSize = BASE_GATE_SIZE_X + ADDITONAL_INPUTS;
this->ySize = BASE_GATE_SIZE_Y + ADDITONAL_INPUTS;
 
QPointF point = QPointF(0, this->ySize / 2);
this->inputPoints[0] = point;
QPointF scenePoint = QPointF(this->scenePos().x(), this->scenePos().y() + this->ySize / 2);
this->gateInputPoints[0] = scenePoint;
 
textRect = QRectF(BORDER_OFFSET * 2, BORDER_OFFSET, xSize - BORDER_OFFSET * 3, ySize - BORDER_OFFSET * 2);
}
 
void Gate_OUTPUT::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs != 1) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
painter->drawEllipse(inputPoints[0], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
QPointF points[5] = {
QPointF(BORDER_OFFSET, ySize / 2),
QPointF(BORDER_OFFSET * 2, BORDER_OFFSET),
QPointF(xSize - BORDER_OFFSET, BORDER_OFFSET),
QPointF(xSize - BORDER_OFFSET, ySize - BORDER_OFFSET),
QPointF(BORDER_OFFSET * 2, ySize - BORDER_OFFSET)
};
painter->drawPolygon(points, 5);
 
// Draw I/O lines
painter->drawLine(inputPoints[0], QPointF(inputPoints[0].x() + BORDER_OFFSET, inputPoints[0].y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_OUTPUT::simulateToOutput()
{
// Do nothing
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_OUTPUT.h
0,0 → 1,17
#ifndef GATE_OUTPUT_H
#define GATE_OUTPUT_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_OUTPUT : public Gate_BASE
{
public:
Gate_OUTPUT(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_OUTPUT_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_XNOR.cpp
0,0 → 1,111
#include "Gate_XNOR.h"
 
Gate_XNOR::Gate_XNOR(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
textRect = QRectF(BORDER_OFFSET * 1.9, BORDER_OFFSET, xSize - BORDER_OFFSET * 3, ySize - BORDER_OFFSET * 2);
}
 
void Gate_XNOR::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs < 2) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
for (int i = 0; i < numInputs; i++) {
painter->drawEllipse(inputPoints[i], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
}
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
QRectF leftArcBox = QRectF(0, BORDER_OFFSET, BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2), ySize - BORDER_OFFSET * 2);
leftArcBox.translate(BORDER_OFFSET - (BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2)) / 2, 0);
painter->drawArc(leftArcBox, -90 * 16, 180 * 16);
 
QRectF leftArcBox2 = QRectF(0, BORDER_OFFSET, BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2), ySize - BORDER_OFFSET * 2);
leftArcBox2.translate(BORDER_OFFSET * 2 - (BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2)) / 2, 0);
painter->drawArc(leftArcBox2, -90 * 16, 180 * 16);
 
QRectF rightArcBox = QRectF(0, BORDER_OFFSET, 2 * (xSize - (BORDER_OFFSET * 2)) - BORDER_OFFSET * 4, ySize - (BORDER_OFFSET * 2));
rightArcBox.translate(-xSize + BORDER_OFFSET * 6, 0);
painter->drawArc(rightArcBox, 0, 90 * 16);
painter->drawArc(rightArcBox, -90 * 16, 90 * 16);
 
painter->drawEllipse(QPoint(xSize - BORDER_OFFSET - BORDER_OFFSET / 2, ySize / 2), BORDER_OFFSET / 2, BORDER_OFFSET / 2);
 
// Draw I/O lines
int a = leftArcBox.width() / 2;
int b = leftArcBox.height() / 2;
QPointF arcCenter = leftArcBox.center();
for (int i = 0; i < numInputs; i++) {
float xPt = sqrt((1 - pow(inputPoints[i].y() - arcCenter.y(), 2) / (b * b)) * (a * a)) + arcCenter.x();
painter->drawLine(inputPoints[i], QPointF(xPt, inputPoints[i].y()));
}
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_XNOR::simulateToOutput()
{
// Save initial values to compare to later
logicValue initValue = outputValue;
logicValue initFaultyValue = outputFaultyValue;
 
// Compute new output values
bool undefined = false, undefinedFaulty = false;
bool allOnes = true, allOnesFaulty = true;
bool allZeros = true, allZerosFaulty = true;
for (int i = 0; i < numInputs; i++) {
if (inputValues[i] == logicValue_X) undefined = true;
if (inputValues[i] == logicValue_0) allOnes = false;
if (inputValues[i] == logicValue_1) allZeros = false;
 
if (inputFaultyValues[i] == logicValue_X) undefinedFaulty = true;
if (inputFaultyValues[i] == logicValue_0) allOnesFaulty = false;
if (inputFaultyValues[i] == logicValue_1) allZerosFaulty = false;
}
 
if (!allOnes && !allZeros) outputValue = logicValue_0;
else if ((allOnes || allZeros) && !undefined) outputValue = logicValue_1;
else outputValue = logicValue_X;
 
if (!allOnesFaulty && !allZerosFaulty) outputFaultyValue = logicValue_0;
else if ((allOnesFaulty || allZerosFaulty) && !undefinedFaulty) outputFaultyValue = logicValue_1;
else outputFaultyValue = logicValue_X;
 
// If outputs have changed, queue the connected gate for simulation
if (outputValue != initValue || outputFaultyValue != initFaultyValue)
emit enqueueSim(this);
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_XNOR.h
0,0 → 1,17
#ifndef GATE_XNOR_H
#define GATE_XNOR_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_XNOR : public Gate_BASE
{
public:
Gate_XNOR(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_XNOR_H
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_XOR.cpp
0,0 → 1,109
#include "Gate_XOR.h"
 
Gate_XOR::Gate_XOR(int gateID, gType type, int numInputs, int gateLevel)
: Gate_BASE(gateID, type, numInputs, gateLevel)
{
textRect = QRectF(BORDER_OFFSET * 2.2, BORDER_OFFSET, xSize - BORDER_OFFSET * 3, ySize - BORDER_OFFSET * 2);
}
 
void Gate_XOR::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(0, 0, xSize, ySize);
painter->drawRect(textRect);
if (numInputs < 2) {
painter->setPen(debugErrorPen);
painter->drawLine(0, 0, xSize, ySize);
painter->drawLine(xSize, 0, 0, ySize);
}
painter->restore();
#endif
 
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw circles indicating I/O points
for (int i = 0; i < numInputs; i++) {
painter->drawEllipse(inputPoints[i], INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
}
painter->drawEllipse(outputPoint, INPUT_CIRCLE_SIZE, INPUT_CIRCLE_SIZE);
 
// Draw gate outline
QRectF leftArcBox = QRectF(0, BORDER_OFFSET, BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2), ySize - BORDER_OFFSET * 2);
leftArcBox.translate(BORDER_OFFSET - (BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2)) / 2, 0);
painter->drawArc(leftArcBox, -90 * 16, 180 * 16);
 
QRectF leftArcBox2 = QRectF(0, BORDER_OFFSET, BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2), ySize - BORDER_OFFSET * 2);
leftArcBox2.translate(BORDER_OFFSET * 2 - (BORDER_OFFSET + (numInputs * BORDER_OFFSET / 2)) / 2, 0);
painter->drawArc(leftArcBox2, -90 * 16, 180 * 16);
 
QRectF rightArcBox = QRectF(0, BORDER_OFFSET, 2 * (xSize - (BORDER_OFFSET * 2)) - BORDER_OFFSET * 2, ySize - (BORDER_OFFSET * 2));
rightArcBox.translate(-xSize + BORDER_OFFSET * 5, 0);
painter->drawArc(rightArcBox, 0, 90 * 16);
painter->drawArc(rightArcBox, -90 * 16, 90 * 16);
 
// Draw I/O lines
int a = leftArcBox.width() / 2;
int b = leftArcBox.height() / 2;
QPointF arcCenter = leftArcBox.center();
for (int i = 0; i < numInputs; i++) {
float xPt = sqrt((1 - pow(inputPoints[i].y() - arcCenter.y(), 2) / (b * b)) * (a * a)) + arcCenter.x();
painter->drawLine(inputPoints[i], QPointF(xPt, inputPoints[i].y()));
}
painter->drawLine(outputPoint, QPointF(outputPoint.x() - BORDER_OFFSET, outputPoint.y()));
 
// Draw text showing gate ID
painter->setPen(defaultPen);
painter->setFont(defaultFont);
painter->drawText(textRect, Qt::AlignCenter, QString::number(gateID));
 
// If enqueued, draw circle around gate ID
if (enqueued) {
painter->drawEllipse(textRect.center(), ENQUEUED_CIRCLE_WIDTH, ENQUEUED_CIRCLE_WIDTH);
}
}
 
void Gate_XOR::simulateToOutput()
{
// Save initial values to compare to later
logicValue initValue = outputValue;
logicValue initFaultyValue = outputFaultyValue;
 
// Compute new output values
bool undefined = false, undefinedFaulty = false;
bool allOnes = true, allOnesFaulty = true;
bool allZeros = true, allZerosFaulty = true;
for (int i = 0; i < numInputs; i++) {
if (inputValues[i] == logicValue_X) undefined = true;
if (inputValues[i] == logicValue_0) allOnes = false;
if (inputValues[i] == logicValue_1) allZeros = false;
 
if (inputFaultyValues[i] == logicValue_X) undefinedFaulty = true;
if (inputFaultyValues[i] == logicValue_0) allOnesFaulty = false;
if (inputFaultyValues[i] == logicValue_1) allZerosFaulty = false;
}
 
if (!allOnes && !allZeros) outputValue = logicValue_1;
else if ((allOnes || allZeros) && !undefined) outputValue = logicValue_0;
else outputValue = logicValue_X;
 
if (!allOnesFaulty && !allZerosFaulty) outputFaultyValue = logicValue_1;
else if ((allOnesFaulty || allZerosFaulty) && !undefinedFaulty) outputFaultyValue = logicValue_0;
else outputFaultyValue = logicValue_X;
 
// If outputs have changed, queue the connected gate for simulation
if (outputValue != initValue || outputFaultyValue != initFaultyValue)
emit enqueueSim(this);
 
// Update connected wire values
for (int i = 0; i < gateOutputWires.size(); i++) {
gateOutputWires[i]->setValue(outputValue, outputFaultyValue, false);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Gate_XOR.h
0,0 → 1,17
#ifndef GATE_XOR_H
#define GATE_XOR_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
class Gate_XOR : public Gate_BASE
{
public:
Gate_XOR(int gateID, gType type,
int numInputs, int gateLevel);
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void simulateToOutput();
};
 
#endif // GATE_XOR_H
/Classwork/ECE5505 - Test and Verification/Final Project/GlobalDefines.h
0,0 → 1,12
#ifndef GLOBALDEFINES_H
#define GLOBALDEFINES_H
 
#include <QtWidgets>
 
typedef enum {
logicValue_X,
logicValue_0,
logicValue_1,
} logicValue;
 
#endif // GLOBALDEFINES_H
/Classwork/ECE5505 - Test and Verification/Final Project/MainWindow.cpp
0,0 → 1,136
#include "MainWindow.h"
 
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
// Variable initialization
circuit = new Circuit();
 
// Zoom slider and text
zoomValue = new QLabel;
zoomValue->setAlignment(Qt::AlignCenter);
zoomSlider = new QSlider;
zoomSlider->setMinimum(0);
zoomSlider->setMaximum(200);
zoomSlider->setValue(100);
zoomSlider->setTickPosition(QSlider::TicksBothSides);
zoomSlider->setTickInterval(10);
 
// Canvas
canvas = new Canvas;
 
// Zoom slider and text layout
QVBoxLayout *zoomLayout = new QVBoxLayout();
zoomLayout->addWidget(zoomValue);
zoomLayout->addWidget(zoomSlider);
canvas->zoomCanvas(100);
updateZoomValue(100);
 
// Top-level layout and widget
QHBoxLayout *mainLayout = new QHBoxLayout();
mainLayout->addWidget(canvas);
mainLayout->addLayout(zoomLayout);
 
QWidget *mainWidget = new QWidget();
mainWidget->setLayout(mainLayout);
setCentralWidget(mainWidget);
 
// Connect signals
connect(zoomSlider, SIGNAL(valueChanged(int)), canvas, SLOT(zoomCanvas(int)));
connect(zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(updateZoomValue(int)));
connect(canvas, SIGNAL(updateZoomSlider(int)), zoomSlider, SLOT(setValue(int)));
connect(canvas, SIGNAL(updateStatus(QString)), this, SLOT(updateStatus(QString)));
connect(circuit, SIGNAL(updateStatus(QString)), this, SLOT(updateStatus(QString)));
 
setWindowTitle("Circuit Visualizer");
updateStatus("Waiting to load circuit file...");
 
createActions();
createMenus();
}
 
MainWindow::~MainWindow() {
 
}
 
void MainWindow::updateZoomValue(int value)
{
zoomValue->setText(QString::number(value));
}
 
void MainWindow::updateStatus(QString string)
{
statusBar()->showMessage(string);
}
 
void MainWindow::loadCircuit()
{
static QString lastKnownFilePath = ".";
 
QString file = QFileDialog::getOpenFileName(this, "Circuit (lev) File", lastKnownFilePath, "Vector File (*.lev)");
QCoreApplication::processEvents(); // Close file dialog before proceeding
 
if (file.size() == 0) return;
 
// If file was selected, save directory for next time dialog is opened
QFileInfo fileInfo = QFileInfo(file);
lastKnownFilePath = fileInfo.absolutePath();
 
if (circuit->readGates(file)) {
statusBar()->showMessage(circuit->getLastError());
return;
}
 
canvas->drawCircuit(circuit);
loadCircuitFileAction->setEnabled(false);
showSimControllerAction->setEnabled(true);
resetCircuitAction->setEnabled(true);
}
 
void MainWindow::showHelp()
{
QMessageBox msg;
msg.setWindowTitle("Help");
msg.setText("- Hold down CTRL to pan"
"\n- Zoom with mouse wheel"
"\n- Circled gates are queued");
msg.exec();
}
 
void MainWindow::createActions()
{
loadCircuitFileAction = new QAction("Load &Circuit", this);
loadCircuitFileAction->setStatusTip("Loads a new circuit from file");
connect(loadCircuitFileAction, SIGNAL(triggered()), this, SLOT(loadCircuit()));
 
showHelpAction = new QAction("&About", this);
showHelpAction->setStatusTip("Instructions on program usage");
connect(showHelpAction, SIGNAL(triggered()), this, SLOT(showHelp()));
 
resetCircuitAction = new QAction("&Reset Circuit", this);
resetCircuitAction->setStatusTip("Resets circuit to default values");
resetCircuitAction->setEnabled(false);
connect(resetCircuitAction, SIGNAL(triggered()), circuit, SLOT(reset()));
 
showSimControllerAction = new QAction("&Begin Simulator", this);
showSimControllerAction->setStatusTip("Shows simulation controller");
showSimControllerAction->setEnabled(false);
connect(showSimControllerAction, SIGNAL(triggered()), circuit, SLOT(showSimController()));
 
toggleWireValuesAction = new QAction("Toggle &Wire Values", this);
toggleWireValuesAction->setStatusTip("Show/hide values on wires");
connect(toggleWireValuesAction, SIGNAL(triggered()), circuit, SIGNAL(toggleShowWireValues()));
}
 
void MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu("&File");
fileMenu->addAction(loadCircuitFileAction);
 
circuitMenu = menuBar()->addMenu("&Circuit");
circuitMenu->addAction(resetCircuitAction);
circuitMenu->addAction(showSimControllerAction);
circuitMenu->addAction(toggleWireValuesAction);
 
helpMenu = menuBar()->addMenu("&Help");
helpMenu->addAction(showHelpAction);
}
/Classwork/ECE5505 - Test and Verification/Final Project/MainWindow.h
0,0 → 1,45
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
 
#include "GlobalDefines.h"
#include "Canvas.h"
#include "Circuit.h"
 
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
 
signals:
void zoomCanvas(int);
 
private slots:
void updateZoomValue(int);
void updateStatus(QString status);
void loadCircuit(void);
void showHelp(void);
 
private:
void createActions(void);
void createMenus(void);
 
Canvas *canvas;
QSlider *zoomSlider;
QLabel *zoomValue;
 
Circuit *circuit;
 
QMenu *fileMenu;
QMenu *helpMenu;
QMenu *circuitMenu;
QAction *loadCircuitFileAction;
QAction *showHelpAction;
QAction *resetCircuitAction;
QAction *showSimControllerAction;
QAction *toggleWireValuesAction;
 
};
 
#endif // MAINWINDOW_H
/Classwork/ECE5505 - Test and Verification/Final Project/Project.pro
0,0 → 1,63
#-------------------------------------------------
#
# Project created by QtCreator 2014-11-04T14:50:30
#
#-------------------------------------------------
 
QT += core gui
 
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
TARGET = Project
TEMPLATE = app
 
# Set some debug flags
CONFIG(debug, debug|release) {
message(DEBUG MODE)
DEFINES += _DEBUG
} else {
message(RELEASE MODE)
DEFINES -= _DEBUG
}
 
SOURCES += main.cpp\
MainWindow.cpp \
Canvas.cpp \
Gate_AND.cpp \
Gate_OR.cpp \
Gate_INPUT.cpp \
Gate_OUTPUT.cpp \
Gate_BASE.cpp \
Gate_BUFFER.cpp \
Gate_NOT.cpp \
Gate_NAND.cpp \
Gate_NOR.cpp \
Gate_XOR.cpp \
Gate_XNOR.cpp \
Gate_DFF.cpp \
Circuit.cpp \
Wire.cpp \
Simulator.cpp \
SimController.cpp
 
HEADERS += MainWindow.h \
Canvas.h \
GlobalDefines.h \
Gate_AND.h \
Gate_OR.h \
Gate_INPUT.h \
Gate_OUTPUT.h \
Gate_BASE.h \
Gate_BUFFER.h \
Gate_NOT.h \
Gate_NAND.h \
Gate_NOR.h \
Gate_XOR.h \
Gate_XNOR.h \
Gate_DFF.h \
Circuit.h \
Wire.h \
Simulator.h \
SimController.h
 
FORMS +=
/Classwork/ECE5505 - Test and Verification/Final Project/Project.pro.user
0,0 → 1,464
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.2.1, 2014-12-26T18:03:44. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{739b1006-f22a-4cb7-9aed-d7d8d9de7c70}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.3 GCC 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.3 GCC 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.53.gcc_64_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kevin/Documents/School/VTech/Fall 2014/ECE 5505/Final Project/build-Project-Desktop_Qt_5_3_GCC_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kevin/Documents/School/VTech/Fall 2014/ECE 5505/Final Project/build-Project-Desktop_Qt_5_3_GCC_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Project</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/kevin/Documents/School/VTech/Fall 2014/ECE 5505/Final Project/Project/Project.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">Project.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.1</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Static</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Static</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{6236aba3-7976-4023-80ae-71d56b652cca}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kevin/Documents/School/VTech/Fall 2014/ECE 5505/Final Project/build-Project-Static-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kevin/Documents/School/VTech/Fall 2014/ECE 5505/Final Project/build-Project-Static-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Project</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/kevin/Documents/School/VTech/Fall 2014/ECE 5505/Final Project/Project/Project.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">Project.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">2</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">16</value>
</data>
<data>
<variable>Version</variable>
<value type="int">16</value>
</data>
</qtcreator>
/Classwork/ECE5505 - Test and Verification/Final Project/SimController.cpp
0,0 → 1,25
#include "SimController.h"
 
SimController::SimController(QWidget *parent) :
QWidget(parent)
{
setWindowFlags(Qt::WindowStaysOnTopHint);
 
singleStepBtn = new QPushButton;
singleStepBtn->setText("Single Step");
 
autoStepBtn = new QPushButton;
autoStepBtn->setText("Auto Step");
 
QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->addWidget(singleStepBtn);
mainLayout->addWidget(autoStepBtn);
 
this->setFixedSize(160,80);
 
setLayout(mainLayout);
setWindowTitle("Sim Controller");
 
connect(singleStepBtn, SIGNAL(clicked()), this, SIGNAL(singleStep()));
connect(autoStepBtn, SIGNAL(clicked()), this, SIGNAL(autoStep()));
}
/Classwork/ECE5505 - Test and Verification/Final Project/SimController.h
0,0 → 1,23
#ifndef SIMCONTROLLER_H
#define SIMCONTROLLER_H
 
#include "GlobalDefines.h"
 
class SimController : public QWidget
{
Q_OBJECT
public:
SimController(QWidget *parent = 0);
 
signals:
void singleStep(void);
void autoStep(void);
 
public slots:
 
private:
QPushButton *singleStepBtn;
QPushButton *autoStepBtn;
};
 
#endif // SIMCONTROLLER_H
/Classwork/ECE5505 - Test and Verification/Final Project/Simulator.cpp
0,0 → 1,43
#include "Simulator.h"
 
Simulator::Simulator(Circuit *c, QObject *parent) :
QObject(parent)
{
this->circuit = c;
}
 
void Simulator::singleStep()
{
// Iterate through and simulate gates in the queue
currQueue = nextQueue;
nextQueue.clear();
while (!currQueue.isEmpty()) {
Gate_BASE *g = currQueue.first();
g->simulateToOutput();
g->setEnqueued(false);
currQueue.removeFirst();
}
}
 
void Simulator::autoStep()
{
// Continuously simulate until no more gates are queued
currQueue = nextQueue;
nextQueue.clear();
do {
while (!currQueue.isEmpty()) {
Gate_BASE *g = currQueue.first();
g->simulateToOutput();
g->setEnqueued(false);
currQueue.removeFirst();
}
currQueue = nextQueue;
nextQueue.clear();
} while (!currQueue.isEmpty());
}
 
void Simulator::enqueueGate(Gate_BASE *gate)
{
gate->setEnqueued(true);
nextQueue.enqueue(gate);
}
/Classwork/ECE5505 - Test and Verification/Final Project/Simulator.h
0,0 → 1,34
#ifndef SIMULATOR_H
#define SIMULATOR_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
#include "Circuit.h"
 
class Circuit;
 
class Simulator : public QObject
{
Q_OBJECT
public:
Simulator(Circuit *c, QObject *parent = 0);
 
signals:
void updateStatus(QString status);
 
public slots:
void singleStep(void);
void autoStep(void);
void enqueueGate(Gate_BASE *gate);
 
private:
 
Circuit *circuit;
 
QQueue<Gate_BASE*> currQueue;
QQueue<Gate_BASE*> nextQueue;
 
 
};
 
#endif // SIMULATOR_H
/Classwork/ECE5505 - Test and Verification/Final Project/Wire.cpp
0,0 → 1,268
#include "Wire.h"
 
Wire::Wire(QGraphicsItem *parent) :
QGraphicsObject(parent)
{
setFlags(ItemIsSelectable);
 
createActions();
 
this->auxSelected = false;
this->showValues = true;
 
// Create the default pens to draw with
this->defaultPen = QPen(QColor(COLOR_MAIN), DEFAULT_LINE_WIDTH, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
this->defaultBrush = QBrush(Qt::NoBrush);
this->selectedPen = QPen(QColor(COLOR_MAIN_SELECTED), DEFAULT_LINE_WIDTH, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
this->highlightedPen = QPen(QColor(COLOR_MAIN_SELECTED), DEFAULT_LINE_WIDTH, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
this->defaultFont = QFont("Consolas", 20);
 
this->wireValue = logicValue_X;
this->wireFaultyValue = logicValue_X;
this->valueString = "X/X";
 
#ifdef _DEBUG
this->debugPen = QPen(QColor(COLOR_DEBUG), 1, Qt::DashLine);
this->debugBrush = QBrush(Qt::NoBrush);
this->debugSelectedPen = QPen(QColor(COLOR_DEBUG_SELECTED), 1, Qt::DashLine);
this->debugErrorPen = QPen(QColor(COLOR_DEBUG_ERROR), 2, Qt::DashLine);
#endif
}
 
Wire::~Wire()
{
 
}
 
QRectF Wire::boundingRect() const
{
QMargins margin(SELECTION_WIDTH, SELECTION_WIDTH, SELECTION_WIDTH, SELECTION_WIDTH);
return bRect + margin;
}
 
QPainterPath Wire::shape() const
{
return shapeArea;
}
 
void Wire::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
 
#ifdef _DEBUG
painter->save();
painter->setPen((auxSelected) ? debugSelectedPen : debugPen);
painter->setBrush(debugBrush);
painter->drawRect(this->boundingRect());
painter->drawPath(shapeArea);
painter->restore();
#endif
 
// Set line color accordingly
if (auxSelected) painter->setPen(highlightedPen);
else painter->setPen(defaultPen);
painter->setBrush(defaultBrush);
 
// Draw the line
painter->drawPath(line);
 
QPainterPath textBox;
textBox.addText(0, 0, defaultFont, valueString);
 
// Draw the text (wire value)
if (showValues) {
QPainterPath text;
text.addText(bRect.center().x() - (textBox.boundingRect().width() / 2),
bRect.center().y() + (textBox.boundingRect().height() / 2) - 2,
defaultFont, valueString);
 
QPainterPathStroker stroker;
stroker.setCapStyle(Qt::RoundCap);
stroker.setJoinStyle(Qt::RoundJoin);
stroker.setWidth(10);
QPainterPath textOutline = stroker.createStroke(text);
painter->save();
painter->setPen(QPen(Qt::white));
painter->setBrush(QBrush(Qt::white));
painter->drawPath(textOutline);
painter->restore();
 
painter->drawPath(text);
}
}
 
/**
* Draw line from given point to point
*/
void Wire::setPoints(Gate_BASE *source, Gate_BASE *sink, int sinkID)
{
this->gateOutput = source;
this->gateInput = sink;
this->gateInputID = sinkID;
 
// Calculate the bounding box of this line (normalized)
bRect = QRectF(gateOutput->gateOutputPoint, gateInput->gateInputPoints[gateInputID]).normalized();
 
// Move box to center of object
QPointF center = bRect.center();
bRect.translate(- center.x(), - center.y());
 
// Calculate new I/O points in local coordinates
QPointF tOutput = gateOutput->gateOutputPoint - center;
QPointF tInput = gateInput->gateInputPoints[gateInputID] - center;
 
// Draw the line
linePoints.append(tOutput);
linePoints.append(QPointF(bRect.center().x(), tOutput.y()));
linePoints.append(QPointF(bRect.center().x(), tInput.y()));
linePoints.append(tInput);
line.moveTo(linePoints[0]);
for (int i = 1; i < linePoints.size(); i++) {
line.lineTo(linePoints[i]);
}
 
// Stroke the line to allow for selection
QPainterPathStroker stroke;
stroke.setWidth(SELECTION_WIDTH);
shapeArea = stroke.createStroke(line);
 
// Move wire on canvas to proper location
this->setPos(center.x(), center.y());
prepareGeometryChange();
}
 
/**
* Sets the color of the pen drawing the line
*/
void Wire::setPenColor(QColor color)
{
this->defaultPen.setColor(color);
}
 
/**
* Sets the highlight color when wire is selected
*/
void Wire::setHighlight(bool state, QColor color)
{
auxSelected = state;
if (state) {
highlightedPen.setColor(color);
setZValue(SELECTED_Z);
} else {
setZValue(WIRE_DEFAULT_Z);
}
update();
}
 
/**
* Resets the value of the wire to unknown 'X'
*/
void Wire::reset()
{
setValue(logicValue_X, logicValue_X);
update();
}
 
/**
* Toggles if wire values should be shown
*/
void Wire::toggleShowValues()
{
showValues = !showValues;
update();
}
 
/**
* Sets the value of the wire
*/
void Wire::setValue(logicValue value, logicValue faultyValue, bool recurse)
{
wireValue = value;
wireFaultyValue = faultyValue;
 
// Compute the status string
valueString = "";
if (wireValue == logicValue_0) valueString += "0";
else if (wireValue == logicValue_1) valueString += "1";
else valueString += "X";
valueString += "/";
if (wireFaultyValue == logicValue_0) valueString += "0";
else if (wireFaultyValue == logicValue_1) valueString += "1";
else valueString += "X";
 
// Propogate value to sink/source gates
gateInput->setInputValue(gateInputID, wireValue, wireFaultyValue);
gateInput->setOutputValue(wireValue, wireFaultyValue);
 
// Propogate to gates if necessary
if (recurse) {
for (int i = 0; i < gateOutput->gateOutputWires.size(); i++) {
gateOutput->gateOutputWires[i]->setValue(wireValue, wireFaultyValue, false);
}
}
 
update();
}
 
void Wire::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QString status = QString("Wire Source: Gate %1 | Sink: Gate %2 | Value: ").arg(gateOutput->gateID).arg(gateInput->gateID);
status += valueString;
emit updateStatus(status);
 
// On selection, highlight sink and source gates
setZValue(1);
setHighlight(true, QColor(COLOR_MAIN_SELECTED));
gateOutput->setHighlight(true, QColor(COLOR_OUTPUT_SELECTED));
gateInput->setHighlight(true, QColor(COLOR_INPUT_SELECTED));
event->accept();
}
 
void Wire::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
QMenu menu;
menu.addAction(injectValueAction);
menu.addAction(injectFaultAction);
menu.addAction(resetValuesAction);
menu.exec(event->screenPos());
event->accept();
}
 
void Wire::createActions()
{
injectValueAction = new QAction("&Set Value", this);
connect(injectValueAction, SIGNAL(triggered()), this, SLOT(promptValue()));
 
injectFaultAction = new QAction("&Inject Fault", this);
connect(injectFaultAction, SIGNAL(triggered()), this, SLOT(promptFaultyValue()));
 
resetValuesAction = new QAction("&Reset Values", this);
connect(resetValuesAction, SIGNAL(triggered()), this, SLOT(reset()));
}
 
void Wire::promptValue()
{
bool ok;
QStringList options;
options << "0" << "1";
QString sel = QInputDialog::getItem(0, "Choose Value", "Enter Value:", options, 0, false, &ok);
if (ok && !sel.isEmpty()) {
if (sel == "0") setValue(logicValue_0, logicValue_0);
else if (sel == "1") setValue(logicValue_1, logicValue_1);
else setValue(logicValue_X, logicValue_X);
}
}
 
void Wire::promptFaultyValue()
{
bool ok;
QStringList options;
options << "0" << "1";
QString sel = QInputDialog::getItem(0, "Choose Value", "Enter Faulty Value:", options, 0, false, &ok);
if (ok && !sel.isEmpty()) {
if (sel == "0") setValue(logicValue_1, logicValue_0);
else if (sel == "1") setValue(logicValue_0, logicValue_1);
else setValue(logicValue_X, logicValue_X);
}
}
/Classwork/ECE5505 - Test and Verification/Final Project/Wire.h
0,0 → 1,82
#ifndef WIRE_H
#define WIRE_H
 
#include "GlobalDefines.h"
#include "Gate_BASE.h"
 
#define SELECTION_WIDTH 10
 
class Gate_BASE;
class Canvas;
 
class Wire : public QGraphicsObject
{
Q_OBJECT
public:
Wire(QGraphicsItem *parent = 0);
~Wire();
 
QRectF boundingRect() const;
QPainterPath shape() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
 
void setPoints(Gate_BASE *source, Gate_BASE *sink, int sinkID);
void setPenColor(QColor color);
void setHighlight(bool state, QColor color);
 
void setValue(logicValue value, logicValue faultyValue, bool recurse = true);
 
Gate_BASE *gateOutput;
Gate_BASE *gateInput;
int gateInputID;
 
logicValue wireValue;
logicValue wireFaultyValue;
 
signals:
void updateStatus(QString status);
 
public slots:
void promptValue();
void promptFaultyValue();
void reset();
void toggleShowValues();
 
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
 
private:
void createActions();
QAction *injectValueAction;
QAction *injectFaultAction;
QAction *resetValuesAction;
 
QString valueString;
 
bool auxSelected;
bool showValues;
 
QPen defaultPen;
QBrush defaultBrush;
 
QPen selectedPen;
QPen highlightedPen;
 
QFont defaultFont;
QRectF textRect;
 
QRectF bRect;
QPainterPath shapeArea;
QPainterPath line;
QList<QPointF> linePoints;
 
#ifdef _DEBUG
QPen debugPen;
QBrush debugBrush;
QPen debugSelectedPen;
QPen debugErrorPen;
#endif
};
 
#endif // WIRE_H
/Classwork/ECE5505 - Test and Verification/Final Project/main.cpp
0,0 → 1,11
#include "MainWindow.h"
#include <QApplication>
 
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
 
return a.exec();
}