-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_converter.v
executable file
·74 lines (65 loc) · 1.98 KB
/
number_converter.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Joyce Tung
//
// Create Date: 01:33:40 03/03/2022
// Design Name:
// Module Name: number_converter
// Project Name:
// Target Devices:
// Tool versions:
// Description: Simple module converting FSM number format to display num format
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments: If the FSM works, this works
//
//////////////////////////////////////////////////////////////////////////////////
module number_converter(num1, num2, num3, num4, valid, numbers);
input [9:0] num1; input [9:0] num2; input [9:0] num3; input [9:0] num4;
input [3:0] valid;
output wire [47:0] numbers;
wire [3:0] num1_d1; // digit 1
wire [3:0] num1_d2;
wire [3:0] num1_d3;
wire [3:0] num1_d4;
wire [3:0] num2_d1;
wire [3:0] num2_d2;
wire [3:0] num2_d3;
wire [3:0] num2_d4;
wire [3:0] num3_d1;
wire [3:0] num3_d2;
wire [3:0] num3_d3;
wire [3:0] num3_d4;
wire [3:0] num4_d1;
wire [3:0] num4_d2;
wire [3:0] num4_d3;
wire [3:0] num4_d4;
assign num1_d1 = num1/100; // digit 1
assign num1_d2 = (num1/10)%10;
assign num1_d3 = (num1)%10;
assign num2_d1 = num2/100;
assign num2_d2 = (num2/10)%10;
assign num2_d3 = (num2)%10;
assign num3_d1 = num3/100;
assign num3_d2 = (num3/10)%10;
assign num3_d3 = (num3)%10;
assign num4_d1 = num4/100;
assign num4_d2 = (num4/10)%10;
assign num4_d3 = (num4)%10;
assign numbers[47:36] = (valid[0] == 1) ?
{num1_d1, num1_d2, num1_d3}
: {12{1'b1}};
assign numbers[35:24] = (valid[1] == 1) ?
{num2_d1, num2_d2, num2_d3}
: {12{1'b1}};
assign numbers[23:12] = (valid[2] == 1) ?
{num3_d1, num3_d2, num3_d3}
: {12{1'b1}};
assign numbers[11:0] = (valid[3] == 1) ?
{num4_d1, num4_d2, num4_d3}
: {12{1'b1}};
endmodule