Livt packages
Livt.Collections
Version 1.4.5
Fixed-capacity FIFOs, queues, stacks, circular buffers, lists, and bit sets for Livt hardware.
Published files (69)
tests/fifo/AsyncFifoTest.lvt
namespace Livt.Collections.Tests
using Livt.Collections
/**
* Checks two-context wiring, fill/drain and reuse through the Livt test runner.
*/
@Test
@Context(ClockFrequency = 25MHz)
component AsyncFifoTest
{
// Independent read clock borrowed by the FIFO and monitor.
@Context(ClockFrequency = 50MHz)
readContext: IContext
// Owned subject and read-domain scoreboard.
fifo: AsyncFifo<byte, 4>
monitor: AsyncFifoReadMonitor
// Test stimuli held stable across both domains.
clearBoth: bool
push: bool
pop: bool
/**
* Wires the subject and observer to distinct write/read contexts.
*/
new()
{
clearBoth = true
fifo = new AsyncFifo<byte, 4>(
context,
readContext,
clearBoth,
clearBoth,
push,
0xA5,
pop
)
monitor = new AsyncFifoReadMonitor(
readContext,
clearBoth,
fifo.popValid,
fifo.popData
)
}
/**
* Checks fill, drain and reuse after coordinated clear across two clocks.
*/
@Test
fn FillDrainAndReuseAcrossContexts()
{
push = false
pop = false
clearBoth = true
Simulation.Wait(20)
assert fifo.writeCleared
assert fifo.readCleared
clearBoth = false
Simulation.Wait(20)
push = true
Simulation.Wait(40)
assert fifo.full
push = false
Simulation.Wait(20)
pop = true
Simulation.Wait(60)
pop = false
Simulation.Wait(20)
assert fifo.empty
var first = sync monitor.GetCount()
assert first == 4
var firstBadData = sync monitor.HasBadData()
assert !firstBadData
clearBoth = true
Simulation.Wait(20)
clearBoth = false
Simulation.Wait(20)
push = true
Simulation.Wait(40)
push = false
Simulation.Wait(20)
pop = true
Simulation.Wait(60)
pop = false
Simulation.Wait(20)
var second = sync monitor.GetCount()
assert second == 4
var bad = sync monitor.HasBadData()
assert !bad
}
}