summaryrefslogtreecommitdiff
path: root/hdl/result_printer.sv
diff options
context:
space:
mode:
Diffstat (limited to 'hdl/result_printer.sv')
-rw-r--r--hdl/result_printer.sv37
1 files changed, 28 insertions, 9 deletions
diff --git a/hdl/result_printer.sv b/hdl/result_printer.sv
index 6e1bd53..322fac0 100644
--- a/hdl/result_printer.sv
+++ b/hdl/result_printer.sv
@@ -11,15 +11,21 @@ module result_printer
11 , input bit echo_ready 11 , input bit echo_ready
12 , output bit echo_valid 12 , output bit echo_valid
13 , output uart_byte_t echo_data 13 , output uart_byte_t echo_data
14
15 , output bit loop_ready
16 , input bit loop_valid
17 , input bit loop_data
14 ); 18 );
15 19
16 bit hold_valid; 20 bit hold_valid;
17 ram_read_response_t hold; 21 ram_read_response_t hold;
22 bit loop;
18 ram_byte_count_t byte_count; 23 ram_byte_count_t byte_count;
19 ram_word_count_t word_count; 24 ram_word_count_t word_count;
20 25
21 (* syn_encoding = "one-hot" *) enum int unsigned 26 (* syn_encoding = "one-hot" *) enum int unsigned
22 { HIGH_NIBBLE 27 { EQUALS_SIGN
28 , HIGH_NIBBLE
23 , LOW_NIBBLE 29 , LOW_NIBBLE
24 , WORD_SEPARATOR 30 , WORD_SEPARATOR
25 } state; 31 } state;
@@ -29,12 +35,16 @@ module result_printer
29 result_ready = 0; 35 result_ready = 0;
30 echo_valid = 0; 36 echo_valid = 0;
31 echo_data = 0; 37 echo_data = 0;
38 loop_ready = 0;
32 hold_valid = 0; 39 hold_valid = 0;
40 loop = 0;
33 byte_count = 0; 41 byte_count = 0;
34 word_count = 0; 42 word_count = 0;
35 state = state.first; 43 state = state.first;
36 end else begin 44 end else begin
37 if (echo_ready) echo_valid = 0; 45 if (echo_ready) echo_valid = 0;
46 if (loop_ready && loop_valid)
47 loop = loop_data;
38 if (result_ready && result_valid) begin 48 if (result_ready && result_valid) begin
39 hold_valid = 1; 49 hold_valid = 1;
40 hold = result_data; 50 hold = result_data;
@@ -48,35 +58,44 @@ module result_printer
48 automatic ram_word_t w = hold.data[word_count-1]; 58 automatic ram_word_t w = hold.data[word_count-1];
49 automatic ram_byte_t b = w[byte_count-1]; 59 automatic ram_byte_t b = w[byte_count-1];
50 echo_valid = 1; 60 echo_valid = 1;
61 if (state == EQUALS_SIGN && !loop)
62 state = state.next;
51 case (state) 63 case (state)
64 EQUALS_SIGN: echo_data = "=";
52 HIGH_NIBBLE: echo_data = b[7:4]; 65 HIGH_NIBBLE: echo_data = b[7:4];
53 LOW_NIBBLE: echo_data = b[3:0]; 66 LOW_NIBBLE: echo_data = b[3:0];
54 WORD_SEPARATOR: echo_data = ":"; 67 WORD_SEPARATOR: echo_data = ":";
55 endcase 68 endcase
56 if (state != WORD_SEPARATOR) begin 69 if (state == HIGH_NIBBLE || state == LOW_NIBBLE) begin
57 if (echo_data < 10) 70 if (echo_data < 10)
58 echo_data = echo_data + "0"; 71 echo_data = echo_data + "0";
59 else 72 else
60 echo_data = echo_data + "A" - 10; 73 echo_data = echo_data + "A" - 10;
61 end 74 end
62 state = state.next; 75 if (state == LOW_NIBBLE) begin
63 if (state == WORD_SEPARATOR && (byte_count != 1 || word_count == 1)) 76 if (byte_count == 1) begin
64 state = state.next;
65 if (state == state.first) begin
66 byte_count = byte_count - 1;
67 if (byte_count == 0) begin
68 byte_count = `RAM_WORD_BYTES; 77 byte_count = `RAM_WORD_BYTES;
69 word_count = word_count - 1; 78 word_count = word_count - 1;
79 state = state.next;
80 end else begin
81 byte_count = byte_count - 1;
82 state = HIGH_NIBBLE;
70 end 83 end
84 end else begin
85 state = state.next;
71 end 86 end
72 end else begin 87 end else begin
73 echo_valid = 1; 88 echo_valid = 1;
74 echo_data = "\n"; 89 if (loop && hold.address[3:0] != 'hf)
90 echo_data = " ";
91 else
92 echo_data = "\n";
75 hold_valid = 0; 93 hold_valid = 0;
76 end 94 end
77 end 95 end
78 96
79 result_ready = !hold_valid; 97 result_ready = !hold_valid;
98 loop_ready = 1;
80 end 99 end
81 end 100 end
82 101