blob: e873d33391e123f74282003e68ad995e2a1e0e96 (
plain) (
blame)
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
|
module result_printer
( input bit clock
, input bit resetn
, output bit result_ready
, input bit result_valid
, input bit [15:0] result_data
, input bit echo_ready
, output bit echo_valid
, output bit [7:0] echo_data
);
bit hold_valid;
bit [15:0] hold;
(* syn_encoding = "one-hot" *) enum
{ DIGIT_1
, DIGIT_2
, DIGIT_3
, DIGIT_4
} state;
always @(posedge clock) begin
if (!resetn) begin
result_ready = 0;
echo_valid = 0;
echo_data = 0;
hold_valid = 0;
hold = 0;
state = state.first;
end else begin
if (echo_ready) echo_valid = 0;
if (result_ready && result_valid) begin
hold_valid = 1;
hold = result_data;
end
if (hold_valid && !echo_valid) begin
echo_valid = 1;
echo_data = hold[15:12];
hold = hold << 4;
if (echo_data < 10)
echo_data = echo_data + "0";
else
echo_data = echo_data + "A" - 10;
state = state.next;
if (state == state.first) hold_valid = 0;
end
result_ready = !hold_valid;
end
end
endmodule
|