Nios/7seg

From ASMBits

nios/hexstrPrevious

Write a function that will compute a 7-bit value suitable for displaying one hexadecimal digit (0 to f) on a seven-segment display. Each of the display's segments maps to one bit of the number, as indicated in the diagram below (1=on, 0=off). Because the display has 7 segments, only the lowest 7 bits are used. Set the upper bits to zero.

Your function will be passed one parameter: The number to be displayed (guaranteed to be 0 to 15). Return the appropriate bit pattern.

7seg.png

Expected solution length: Around 5 lines.

Sample Input

r4=8

Sample Output

r2=0x7f

Write your solution here

Upload a source file...