Description

Priority Queue

Design a hardware module that maintains the K smallest values from an input stream. After processing each input value, output the current K smallest values in sorted order. If fewer than K values have been seen, output all values seen so far, padded with maximum values (0xFFFF).

Example: For stream [5, 3, 8, 1, 9] with K=3, after processing all inputs, output [1, 3, 5].

Input

stream

Stream of 16-bit Unsigned Integer
Input stream.

k

4-bit Unsigned Integer
Number of smallest values to maintain.

Output

2D Array of 16-bit Unsigned Integer
K smallest values after each input.