added seven segment display logic / seconds counter
All checks were successful
ci/woodpecker/push/test-workflow Pipeline was successful

This commit is contained in:
dilanthi 2025-05-17 20:38:52 -07:00
parent 423f89a665
commit 4b041651d4
2 changed files with 85 additions and 6 deletions

View File

@ -0,0 +1,60 @@
/**
* display_converter.sv - decodes a 5 bit digit input into its seven segment
* display equivalent using a lookup table. Display can
* do 0 - 9, A - F, individual segmentsm and special
* characters.
* @author: Dilanthi Prentice, Waylon Cude
* @date: [not sure when its due yet]
*
*
****/
module display_converter(
input logic [4:0] digit,
output logic [6:0] segment
);
localparam ROM_SIZE=32;
//ROM lookup table for seven segment display
localparam logic [6:0] segment_rom [0:ROM_SIZE-1] = '{
7'b1111110, //0
7'b0000110, //1
7'b1101101, //2
7'b1111001, //3
7'b1011011, //4
7'b1011011, //5
7'b1011111, //6
7'b1110000, //7
7'b1111111, //8
7'b1111011, //9
7'b1110111, //A
7'b0011111, //B
7'b1001110, //C
7'b0111101, //D
7'b1001111, //E
7'b1000111, //F
7'b1000000, //segment a
7'b0100000, //segment b
7'b0010000, //segment c
7'b0001000, //segment d
7'b0000100, //segment e
7'b0000001, //segment f
7'b0110111, //H
7'b0001110, //L
7'b1110111, //R
7'b0000110, //l
7'b0000101, //r
7'b0000000, //blank
7'b0000000, //blank
7'b0000000, //blank
7'b0000000, //blank
7'b0000000 //blank
};
//use digit input to index segment_rom lookup table.
assign segment = segment_rom[digit];
endmodule

View File

@ -1,10 +1,29 @@
module seconds_display(
input logic clk,
input logic reset,
input [$clog2(60)-1:0] counter,
output [7:0] display_tens,
output [7:0] display_ones
/***
* seconds_display.sv - convert a seconds counter to a seven segement display.
*
* @author: Dilanthi Prentice, Waylon Cude
* @date:[unsure of due date]
*
*/
module seconds_display
(
input [$clog2(60)-1:0] seconds,
output [6:0] display_tens,
output [6:0] display_ones
);
logic [4:0] ones_digit;
logic [4:0] tens_digit;
always_comb
begin
ones_digit = seconds % 10;
tens_digit = seconds / 10;
end
//instantiate the display_converter to convert the counter
//to a seven segment display number
display_converter ones (ones_digit, display_ones);
display_converter tens (tens_digit, display_tens);
endmodule