Using shift registers to implement a stack

Discussion in 'Homework Help' started by El3, Nov 19, 2014.

  1. El3

    Thread Starter Member

    Sep 13, 2014
    37
    0
    I want to implement a LIFO-stack (LIFO) with 4 cells using shift registers. I want to be able to do the following operations:
    • Push - put in one element at the top of the stack, so that the others get pushed down one cell each (the element in the bottom cell disappears)
    • Pop - pull out one element out from the top of the stack, and add one at the bottom
    • Clear - set all cell elements to zero
    • Change - change only the element in the top cell (other cell elements are unchanged)
    I have the shift registers 74HC194. The datasheet for those can be found here: http://www.ti.com/lit/ds/symlink/sn54s194.pdf and I have uploaded the data sheet here.

    I'm not sure how to do this yet, but I'm thinking it might work to connect the shift registers in series. I.e. connect outputs QA-QD from the first shift register to inputs A-D on the next, and so on. What do you think, could this work?
     
  2. alfacliff

    Well-Known Member

    Dec 13, 2013
    2,449
    428
    that is a four bit serial shift register, get an 8 bit paralel register, it will be much easier to use.
     
  3. El3

    Thread Starter Member

    Sep 13, 2014
    37
    0
    Unfortunately I can't use any other shift registers, I have to use these ones. But will it work like I wrote?
     
  4. alfacliff

    Well-Known Member

    Dec 13, 2013
    2,449
    428
    only through a lot of trouble, that register chip is made to do left shift, riht shift and such you will have to put several of them in line and keep track of what is in each register so you can manipulate the bits to emulate a register stack. kind of like a turing machine.
     
  5. El3

    Thread Starter Member

    Sep 13, 2014
    37
    0
    Do I really have to keep track of what is in each register? I mean for all operations it seems I only have to keep check on what is in the first register (top cell of the stack).

    Maybe I should explain: this stack circuit will later be part of a calculator ("HP" type, i.e. calculators that use "Reverse Polish notation") that should have the ability to make some arithmetic and logic operations on the first cell on the stack and a 4bit number that is given in another input (not connected to the numbers in the shift registers). So I think we only need to keep check on the top cell then?

    At least that's how I reason so far. But I would like inputs and thoughts about this! If you have some thoughts about this, please share them.
     
  6. alfacliff

    Well-Known Member

    Dec 13, 2013
    2,449
    428
    if you want to do push up or down, you will have to keep track of the bits position to rotate them through the registers and keep track of the results. a paralel register would be easier, you just do one move from register to register.which is only one clock cycle. the serial method takes quite a few more clock cycles. these days the stack is just a block of memory.
     
  7. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Possibly... if you use lots of support gates and possibly many more of these then you thing (like 4-8 times).

    It really is a very poor choice of shift register. Put it this way: instead of shifting byte A into byte B into byte C it is shifting just the bits of A,so bit A1 goes to bit A2, bit A2 goes to bit A3, and so on.
     
  8. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Guys, it would seem that the obvious way to do it would be to use one 4-bit shift register for each bit slice of the data values. The left-shift and right-shift then directly become push-pop and it is a perfect match for a 4-level stack.
     
  9. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    I have a feeling this should be in Homework Help.
     
Loading...