SpinalHDL
1 / 1
Description
Tidy Numbers
Design a hardware module that finds the largest "tidy" number ≤ N. A tidy number has non-decreasing digits when read left to right.
Input is provided as 4 BCD digits (4 bits each, most significant digit first), representing numbers from 0 to 9,999. Output should also be 4 BCD digits.
Example: For N=[1,0,0,0] (1000), output [0,9,9,9] (999).
For N=[0,1,3,2] (132), output [0,1,2,9] (129).
Source: Google Code Jam 2017 Qualification Round - Problem B: Tidy Numbers
Input
n
Vec of 4 4-bit Unsigned IntegerInput number as 4 BCD digits (most significant first).
Output
Vec of 4 4-bit Unsigned Integer
Largest tidy number ≤ N as 4 BCD digits.