This package provides a fixed-size LIFO stack in Livt for small byte-oriented storage needs.
This repository is intentionally small, so the core design rationale is captured directly in this README rather than a separate design note.
The current package is organized around one main component:
Stackstores up to 32 entries oflogic[8]and returns values in last-in, first-out order.
The stack is currently fixed to:
- 32 elements of storage
- 8-bit
logic[8]stack entries
The public API is intentionally small and centered on predictable LIFO behavior:
Push()appends to the top of the stack when space is available.Pop()removes and returns the newest stacked element.Peek()reads the newest stacked element without removing it.IsEmpty(),IsFull(), andGetPosition()expose stack state.Clear()resets the stack to an empty state.
.
├── src/
│ └── Stack.lvt
├── tests/
│ └── StackTest.lvt
├── LICENSE
├── README.md
└── livt.toml
Build the package with:
livt buildThe package configuration is defined in livt.toml. The current
project name there is Stack.
Run the full test suite with:
livt testConfigured test components:
StackTest
Small fixed-size LIFO stack in the Livt.Collections namespace.
Features:
- array-backed storage
- LIFO pop order
- explicit empty and full state checks
- defined empty-stack return value for
Peek()andPop()
Public methods:
Push(value: logic[8])Pop() logic[8]Peek() logic[8]IsEmpty() boolIsFull() boolGetPosition() intClear()
Push() is ignored when the stack is full. Pop() and Peek() return
0b0000_0000 when the stack is empty.
using Livt.Collections
component Example
{
stack: Stack
new()
{
this.stack = new Stack()
}
public fn PushAndPop(value: logic[8]) logic[8]
{
this.stack.Push(value)
return this.stack.Pop()
}
}
This package does not currently expose configurable width or depth parameters.
To change the stack shape today, update the fixed constants and storage type in:
If the stack contract changes, the expected behavior should also be updated in:
- The package is intentionally minimal and focused on predictable LIFO behavior.
- The stack implementation uses an array and a position counter.
- The empty-stack fallback value is currently fixed to
0b0000_0000.
Contributions are welcome. Areas that would be natural extensions for this package include:
- configurable stack depth
- configurable entry width
- explicit overflow reporting for rejected
Push()calls - alternative empty-read behavior beyond returning
0b0000_0000 - convenience wrappers for common storage patterns
This project is licensed under the MIT License. See LICENSE.