SpinalHDL
1 / 1
View past submissionsLeaderboard

Description

Histogram

Design a hardware module for the Histogram problem.

Given a stream of 4-bit values, count how many times each value from 0 through 15 appears.

After the entire input stream has been processed, output the 16 bin counts in order.

Hardware I/O Encoding

  • stream is a one-dimensional stream of unsigned 4-bit integers
  • the output is a one-dimensional stream of unsigned 12-bit integers
  • output position i is the final count for value i
  • the output stream always has length 16

Examples

Example 1

  • input stream = [0, 1, 0, 2, 1, 0, 15]
  • output: [3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]

Example 2

  • input stream = [4, 4, 4]
  • output: [0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Input

stream

Stream of 4-bit Unsigned Integer (up to 1410 elements)
Stream of 4-bit values.

Output

Stream of 12-bit Unsigned Integer
Final count for each of the 16 histogram bins, emitted in order from 0 to 15.