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/AsyncFifoReadMonitor.lvt

namespace Livt.Collections.Tests

using Livt.Collections

/**
 * Observes read responses in the read clock domain. Test-only helper.
 * Clearing resets the scoreboard independently of construction state.
 */
component AsyncFifoReadMonitor
{
	// Read-domain observation inputs and explicit scoreboard initialization.
	clear: bool
	valid: bool
	data: byte

	// Scoreboard state owned only by Observe.
	count: uint
	badData: bool

	/**
	 * Borrows read-domain signals and binds the observer to their context.
	 */
	new(
		domain: IContext,
		clear: bool,
		valid: bool,
		data: byte
	)
	{
		this.clear = clear
		context = domain
		this.valid = valid
		this.data = data
	}

	/**
	 * Clears or checks each registered response once per read edge.
	 */
	process Observe()
	{
		state {
			if (clear) {
				count = 0
				badData = false
			} elif (valid) {
				count = count + 1

				if (data != 0xA5) {
					badData = true
				}
			}
		}
	}

	/**
	 * Returns the number of responses observed since the latest clear.
	 */
	public fn GetCount() uint
	{
		return count
	}

	/**
	 * Reports whether any response since clear had an unexpected payload.
	 */
	public fn HasBadData() bool
	{
		return badData
	}
}