2018-08-13 22:17:36 +00:00
|
|
|
|
2018-02-07 00:07:40 +00:00
|
|
|
`ifndef DIGITS10_H
|
|
|
|
`define DIGITS10_H
|
|
|
|
|
2017-11-18 19:51:25 +00:00
|
|
|
`include "hvsync_generator.v"
|
|
|
|
|
2018-07-31 18:41:27 +00:00
|
|
|
// module for 10-digit bitmap ROM
|
2018-02-07 00:07:40 +00:00
|
|
|
module digits10_case(digit, yofs, bits);
|
|
|
|
|
2018-07-31 18:41:27 +00:00
|
|
|
input [3:0] digit; // digit 0-9
|
|
|
|
input [2:0] yofs; // vertical offset (0-4)
|
|
|
|
output reg [4:0] bits; // output (5 bits)
|
2018-02-07 00:07:40 +00:00
|
|
|
|
2018-07-31 18:41:27 +00:00
|
|
|
// combine {digit,yofs} into single ROM address
|
2017-11-18 19:51:25 +00:00
|
|
|
wire [6:0] caseexpr = {digit,yofs};
|
2018-02-19 00:19:20 +00:00
|
|
|
|
2017-11-18 19:51:25 +00:00
|
|
|
always @(*)
|
2017-11-21 16:15:08 +00:00
|
|
|
case (caseexpr)/*{w:5,h:5,count:10}*/
|
2017-11-18 19:51:25 +00:00
|
|
|
7'o00: bits = 5'b11111;
|
|
|
|
7'o01: bits = 5'b10001;
|
|
|
|
7'o02: bits = 5'b10001;
|
|
|
|
7'o03: bits = 5'b10001;
|
|
|
|
7'o04: bits = 5'b11111;
|
|
|
|
|
|
|
|
7'o10: bits = 5'b01100;
|
|
|
|
7'o11: bits = 5'b00100;
|
|
|
|
7'o12: bits = 5'b00100;
|
|
|
|
7'o13: bits = 5'b00100;
|
|
|
|
7'o14: bits = 5'b11111;
|
|
|
|
|
|
|
|
7'o20: bits = 5'b11111;
|
|
|
|
7'o21: bits = 5'b00001;
|
|
|
|
7'o22: bits = 5'b11111;
|
|
|
|
7'o23: bits = 5'b10000;
|
|
|
|
7'o24: bits = 5'b11111;
|
|
|
|
|
|
|
|
7'o30: bits = 5'b11111;
|
|
|
|
7'o31: bits = 5'b00001;
|
|
|
|
7'o32: bits = 5'b11111;
|
|
|
|
7'o33: bits = 5'b00001;
|
|
|
|
7'o34: bits = 5'b11111;
|
|
|
|
|
|
|
|
7'o40: bits = 5'b10001;
|
|
|
|
7'o41: bits = 5'b10001;
|
|
|
|
7'o42: bits = 5'b11111;
|
|
|
|
7'o43: bits = 5'b00001;
|
|
|
|
7'o44: bits = 5'b00001;
|
|
|
|
|
|
|
|
7'o50: bits = 5'b11111;
|
|
|
|
7'o51: bits = 5'b10000;
|
|
|
|
7'o52: bits = 5'b11111;
|
|
|
|
7'o53: bits = 5'b00001;
|
|
|
|
7'o54: bits = 5'b11111;
|
|
|
|
|
|
|
|
7'o60: bits = 5'b11111;
|
|
|
|
7'o61: bits = 5'b10000;
|
|
|
|
7'o62: bits = 5'b11111;
|
|
|
|
7'o63: bits = 5'b10001;
|
|
|
|
7'o64: bits = 5'b11111;
|
|
|
|
|
|
|
|
7'o70: bits = 5'b11111;
|
|
|
|
7'o71: bits = 5'b00001;
|
|
|
|
7'o72: bits = 5'b00001;
|
|
|
|
7'o73: bits = 5'b00001;
|
|
|
|
7'o74: bits = 5'b00001;
|
|
|
|
|
|
|
|
7'o100: bits = 5'b11111;
|
|
|
|
7'o101: bits = 5'b10001;
|
|
|
|
7'o102: bits = 5'b11111;
|
|
|
|
7'o103: bits = 5'b10001;
|
|
|
|
7'o104: bits = 5'b11111;
|
|
|
|
|
|
|
|
7'o110: bits = 5'b11111;
|
|
|
|
7'o111: bits = 5'b10001;
|
|
|
|
7'o112: bits = 5'b11111;
|
|
|
|
7'o113: bits = 5'b00001;
|
|
|
|
7'o114: bits = 5'b11111;
|
|
|
|
|
|
|
|
default: bits = 0;
|
|
|
|
endcase
|
|
|
|
endmodule
|
|
|
|
|
2018-02-07 00:07:40 +00:00
|
|
|
module digits10_array(digit, yofs, bits);
|
|
|
|
|
2018-07-31 18:41:27 +00:00
|
|
|
input [3:0] digit; // digit 0-9
|
|
|
|
input [2:0] yofs; // vertical offset (0-4)
|
|
|
|
output [4:0] bits; // output (5 bits)
|
2018-02-07 00:07:40 +00:00
|
|
|
|
2018-08-07 20:15:45 +00:00
|
|
|
reg [4:0] bitarray[16][5]; // ROM array (16 x 5 x 5 bits)
|
2017-11-18 19:51:25 +00:00
|
|
|
|
2018-07-31 18:41:27 +00:00
|
|
|
assign bits = bitarray[digit][yofs]; // assign module output
|
2017-11-29 01:48:27 +00:00
|
|
|
|
2018-02-15 18:31:32 +00:00
|
|
|
integer i,j;
|
|
|
|
|
2017-11-21 16:15:08 +00:00
|
|
|
initial begin/*{w:5,h:5,count:10}*/
|
2017-11-18 19:51:25 +00:00
|
|
|
bitarray[0][0] = 5'b11111;
|
|
|
|
bitarray[0][1] = 5'b10001;
|
|
|
|
bitarray[0][2] = 5'b10001;
|
|
|
|
bitarray[0][3] = 5'b10001;
|
|
|
|
bitarray[0][4] = 5'b11111;
|
|
|
|
|
|
|
|
bitarray[1][0] = 5'b01100;
|
|
|
|
bitarray[1][1] = 5'b00100;
|
|
|
|
bitarray[1][2] = 5'b00100;
|
|
|
|
bitarray[1][3] = 5'b00100;
|
|
|
|
bitarray[1][4] = 5'b11111;
|
|
|
|
|
|
|
|
bitarray[2][0] = 5'b11111;
|
|
|
|
bitarray[2][1] = 5'b00001;
|
|
|
|
bitarray[2][2] = 5'b11111;
|
|
|
|
bitarray[2][3] = 5'b10000;
|
|
|
|
bitarray[2][4] = 5'b11111;
|
|
|
|
|
|
|
|
bitarray[3][0] = 5'b11111;
|
|
|
|
bitarray[3][1] = 5'b00001;
|
|
|
|
bitarray[3][2] = 5'b11111;
|
|
|
|
bitarray[3][3] = 5'b00001;
|
|
|
|
bitarray[3][4] = 5'b11111;
|
|
|
|
|
|
|
|
bitarray[4][0] = 5'b10001;
|
|
|
|
bitarray[4][1] = 5'b10001;
|
|
|
|
bitarray[4][2] = 5'b11111;
|
|
|
|
bitarray[4][3] = 5'b00001;
|
|
|
|
bitarray[4][4] = 5'b00001;
|
|
|
|
|
|
|
|
bitarray[5][0] = 5'b11111;
|
|
|
|
bitarray[5][1] = 5'b10000;
|
|
|
|
bitarray[5][2] = 5'b11111;
|
|
|
|
bitarray[5][3] = 5'b00001;
|
|
|
|
bitarray[5][4] = 5'b11111;
|
|
|
|
|
|
|
|
bitarray[6][0] = 5'b11111;
|
|
|
|
bitarray[6][1] = 5'b10000;
|
|
|
|
bitarray[6][2] = 5'b11111;
|
|
|
|
bitarray[6][3] = 5'b10001;
|
|
|
|
bitarray[6][4] = 5'b11111;
|
|
|
|
|
|
|
|
bitarray[7][0] = 5'b11111;
|
|
|
|
bitarray[7][1] = 5'b00001;
|
|
|
|
bitarray[7][2] = 5'b00001;
|
|
|
|
bitarray[7][3] = 5'b00001;
|
|
|
|
bitarray[7][4] = 5'b00001;
|
|
|
|
|
|
|
|
bitarray[8][0] = 5'b11111;
|
|
|
|
bitarray[8][1] = 5'b10001;
|
|
|
|
bitarray[8][2] = 5'b11111;
|
|
|
|
bitarray[8][3] = 5'b10001;
|
|
|
|
bitarray[8][4] = 5'b11111;
|
|
|
|
|
|
|
|
bitarray[9][0] = 5'b11111;
|
|
|
|
bitarray[9][1] = 5'b10001;
|
|
|
|
bitarray[9][2] = 5'b11111;
|
|
|
|
bitarray[9][3] = 5'b00001;
|
|
|
|
bitarray[9][4] = 5'b11111;
|
2018-02-03 20:20:56 +00:00
|
|
|
|
2018-02-07 00:07:40 +00:00
|
|
|
// clear unused array entries
|
2018-02-15 18:31:32 +00:00
|
|
|
for (i = 10; i <= 15; i++)
|
|
|
|
for (j = 0; j <= 4; j++)
|
2018-02-03 20:20:56 +00:00
|
|
|
bitarray[i][j] = 0;
|
2017-11-18 19:51:25 +00:00
|
|
|
end
|
|
|
|
endmodule
|
|
|
|
|
2018-07-31 18:41:27 +00:00
|
|
|
// test module
|
2018-02-07 00:07:40 +00:00
|
|
|
module test_numbers_top(clk, reset, hsync, vsync, rgb);
|
|
|
|
|
|
|
|
input clk, reset;
|
|
|
|
output hsync, vsync;
|
|
|
|
output [2:0] rgb;
|
|
|
|
|
2017-11-18 19:51:25 +00:00
|
|
|
wire display_on;
|
|
|
|
wire [8:0] hpos;
|
|
|
|
wire [8:0] vpos;
|
|
|
|
|
|
|
|
hvsync_generator hvsync_gen(
|
|
|
|
.clk(clk),
|
2018-02-03 20:20:56 +00:00
|
|
|
.reset(reset),
|
2017-11-18 19:51:25 +00:00
|
|
|
.hsync(hsync),
|
|
|
|
.vsync(vsync),
|
|
|
|
.display_on(display_on),
|
|
|
|
.hpos(hpos),
|
|
|
|
.vpos(vpos)
|
|
|
|
);
|
|
|
|
|
2018-02-07 00:07:40 +00:00
|
|
|
wire [3:0] digit = hpos[7:4];
|
|
|
|
wire [2:0] xofs = hpos[3:1];
|
|
|
|
wire [2:0] yofs = vpos[3:1];
|
2017-11-18 19:51:25 +00:00
|
|
|
wire [4:0] bits;
|
|
|
|
|
|
|
|
digits10_array numbers(
|
|
|
|
.digit(digit),
|
|
|
|
.yofs(yofs),
|
|
|
|
.bits(bits)
|
|
|
|
);
|
|
|
|
|
|
|
|
wire r = display_on && 0;
|
2018-02-07 00:07:40 +00:00
|
|
|
wire g = display_on && bits[xofs ^ 3'b111];
|
2017-11-18 19:51:25 +00:00
|
|
|
wire b = display_on && 0;
|
|
|
|
assign rgb = {b,g,r};
|
|
|
|
|
|
|
|
endmodule
|
2018-02-07 00:07:40 +00:00
|
|
|
|
|
|
|
`endif
|