Home › Practice › RTL Design › Light up a clock digit
Light up a clock digit
EasyRTLcombinational
The digits on a microwave clock are made of seven small bars. To show a number, the chip decides which bars to light.
Concept first. Name the bars a to g: a is the top bar, b top-right, c bottom-right, d bottom, e bottom-left, f top-left and g the middle. The digit 1 lights b and c only; the digit 8 lights all seven. A decoder is a lookup: for each possible 4-bit input there is one fixed pattern of lit bars. Because the table is just "input number, then pattern", the natural way to write it in Verilog is a case statement, one line per digit. Inputs above 9 are not digits.
What to build.
seg7(bcd):bcdis a 4-bit number.- Output
seg[6:0] = {g, f, e, d, c, b, a}, where 1 means the bar is lit. Soseg[0]is bar a andseg[6]is bar g. - Use the usual clock-digit shapes: 6 has the top bar a, 9 has the bottom bar d, and 7 lights only a, b and c.
- Inputs 10 to 15: all bars off.
- No clock.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.