0
\$\begingroup\$

My Counter for my cpu stack is given the up signal at the same time it is given the clock pulse to advance. This happens on the pull from stack instruction so the counter goes back up the stack one and gets th right address..

But here is the thing, even though the clock and up signal are both true at the same time it alternates between counting up one and counting down one. i'm not sure why as it works when testing it normally with a constant 1 for up and ticking the clock myself.

EDIT: Just tested the instruction in the chip. and for some reason i get a different thing happening. When setting the first 8 bits of FP to 00001110 (Pull from stack) the counter counts down to FFFF, but then the next time i set 00001110 it jumps to 2 for no reason and to 1 and to 0 then to ffff and repeat. there is no way this is not a bug in circuitverse... plus it should be going up not down.

Here is a link to the sim if you wanna look at it. https://circuitverse.org/users/17603 The chip is called "Stack".

Here is a image of the systemm enter image description here

enter image description here

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Are you violating setup or hold timing constraints on the Up/Down input? \$\endgroup\$
    – user16324
    Commented Feb 23, 2020 at 21:30
  • \$\begingroup\$ I'm going to be honest. I'm not sure what you mean. Just tested the instruction in the chip. and for some reason i get a different thing happening. When setting the first 8 bits of FP to 00001110 (Pull from stack) the counter counts down to FFFF, but then the next time i set 00001110 it jumps to 2 for no reason and to 1 and to 0 then to ffff and repeat. there is no way this is not a bug in circuitverse... plus it should be going up not down. \$\endgroup\$ Commented Feb 23, 2020 at 21:38
  • \$\begingroup\$ ok now i wrote something to the stack it, so it counted down. but when i tried to read it back a few times it just jumps between 1 and 2 and should be going down. there is no way the counter should be doing this at all. i really don't get it. it seems like a bug. \$\endgroup\$ Commented Feb 23, 2020 at 21:42
  • 1
    \$\begingroup\$ You really need to figure out what the setup and hold constraints are for your counter and make sure you are not violating them. There is not much point in further discussion until you address that issue. \$\endgroup\$ Commented Feb 23, 2020 at 21:52
  • \$\begingroup\$ ok let me do some research. I'm not a circuits guy i learned circuit logic from minecraft so please bear with me as i learn this stuff. But I will post the solution and a source here in a bit \$\endgroup\$ Commented Feb 23, 2020 at 22:44

1 Answer 1

1
\$\begingroup\$

Are you violating setup or hold timing constraints on the Up/Down input?

If U/D is changing at the same time as clk, you can't be sure if the old or the new value of U/D is seen - it is even possible that part of the counter sees Up and the rest sees Down. As you can imagine, the counter won't work reliably if that happens.

You need to setup U/D some finite time BEFORE the clock edge and hold it at that same level for some finite time AFTER, to guarantee seeing the right level when the clock actually happens.. Failing to do these is called "setup and hold violations".

What the correct setup and hold times are, I can't tell you. For old fashioned TTL logic there was a fat book with a bright orange cover called "The TTL Databook", with about a thousand pages of setup and hold timings and other data for every logic IC that Texas made.

You'll need to find out what the equivalent timing parameters are for this system, and keep U/D stable throughout this time window. You can change it at any other time.

In FPGAs, the timing analysis tools do a very good job of warning if you have accidentally violated one of these timings, but you still have to fix it yourself. There are a basic set of "synchronous design rules" that help avoid almost all of these problems : they all basically come down to "don't do that" (clock and other signals at the same time).

In your system I have no idea how that all works; hopefully now you know you're looking for such a thing, it'll be easy to find.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks so much that actually did help. now i set the up down state before the clock pulse instead of on it! Thanks! \$\endgroup\$ Commented Feb 23, 2020 at 23:15
  • \$\begingroup\$ ... and does it work any more consistently? \$\endgroup\$
    – user16324
    Commented Feb 23, 2020 at 23:47
  • \$\begingroup\$ Why indeed it does good sir. thanks. My fault. I'm still 24 and learned circuit logic from minecraft. I have a ways to go but this let me move forward :D. thanks again :) Also that project is now the #1 editors pick on circuit verse, and the first 16 bit computer made on there! \$\endgroup\$ Commented Mar 26, 2020 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.