Skip to content

Commit

Permalink
Push
Browse files Browse the repository at this point in the history
  • Loading branch information
clecat committed Mar 5, 2017
1 parent 4c8060c commit ae633d8
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 7 deletions.
1 change: 1 addition & 0 deletions include/c4017.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace nts

private:
int value;
int changed;
Tristate prevClock0;
Tristate prevClock1;
};
Expand Down
Empty file added nres
Empty file.
Empty file added result
Empty file.
100 changes: 100 additions & 0 deletions samples/tmp2
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
simulate
display
20 changes: 13 additions & 7 deletions src/components/c4017.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace nts
{
c4017::c4017(const std::string &) : value(0), prevClock0(FALSE), prevClock1(FALSE)
c4017::c4017(const std::string &) : value(0), changed(0), prevClock0(FALSE), prevClock1(FALSE)
{
this->name = "4017";
this->type = nts::AComponent::Type::C;
Expand All @@ -27,24 +27,30 @@ namespace nts
nts::Tristate c4017::Compute(std::size_t pin_num_this)
{
if (pin_num_this == 0)
{
this->changed = 0;
return (this->reset_pins());
}
if (pin_num_this < 1 || pin_num_this > 15 || pin_num_this == 8)
throw Error ("Attempt to compute an invalid pin number", this->name + " " + std::to_string(pin_num_this));
pin_num_this--;
if (this->pins[pin_num_this].getMode() == Pin::I)
return (this->pins[pin_num_this].compute());
Tristate C0 = this->pins[13].compute();
Tristate C1 = this->pins[12].compute();
// Tristate C0 = this->pins[12].compute();
Tristate C1 = this->pins[13].compute();
Tristate MR = this->pins[14].compute();
if (C0 == UNDEFINED || C1 == UNDEFINED || MR == UNDEFINED)
if (/*C0 == UNDEFINED || */C1 == UNDEFINED || MR == UNDEFINED)
return (UNDEFINED);
else if (MR == TRUE)
this->value = 0;
else if (C1 == FALSE && C0 == TRUE && (this->prevClock0 == FALSE || this->prevClock1 == TRUE))
else if (C1 == TRUE && /*C0 == FALSE && */(/*this->prevClock0 == TRUE || */this->prevClock1 == FALSE) && !this->changed)
{
this->changed = 1;
this->value = (this->value + 1) % 10;
this->prevClock0 = C0;
}
// this->prevClock0 = C0;
this->prevClock1 = C1;
std::vector<int> values = {{5, 1, 0, 2, 6, 7, 3, 0, 8, 4, 9}};
std::vector<int> values = {{5, 1, 0, 2, 6, 7, 3, 0, 8, 4, 9, 0, 0}};
if (values[pin_num_this] == this->value || (pin_num_this == 11 && this->value < 5))
return (TRUE);
else
Expand Down

0 comments on commit ae633d8

Please sign in to comment.