Using shift registers to implement a stack

Thread Starter

El3

Joined Sep 13, 2014
37
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?
 

Attachments

Thread Starter

El3

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

alfacliff

Joined Dec 13, 2013
2,458
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.
 

Thread Starter

El3

Joined Sep 13, 2014
37
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.
 

alfacliff

Joined Dec 13, 2013
2,458
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.
 

ErnieM

Joined Apr 24, 2011
8,377
Unfortunately I can't use any other shift registers, I have to use these ones. But will it work like I wrote?
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.
 

WBahn

Joined Mar 31, 2012
30,058
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.
 

Anas1010

Joined Jun 13, 2021
2
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.
Hey !!
Can you please explain how to make stack with the parallel sfiht register as you said in above reply ?
 

Anas1010

Joined Jun 13, 2021
2
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?
Hey !!
Can you please share that stack project if possible ?
 

Papabravo

Joined Feb 24, 2006
21,225
Hey!!
This is an old thread. The last post was almost 7 years ago. The Thread starter has not been here for over 6 years. You can yell all you want, but an answer will not likely be forth coming from any of the participants.
 
Top