summaryrefslogtreecommitdiff
path: root/hdl/result_printer.sv
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-03-13 16:48:51 -0700
committerJulian Blake Kongslie2022-03-13 16:48:51 -0700
commitc88beacfc7aff870272f78ce6043010e2299e211 (patch)
tree5edae532816c65abb5c2294f69dd9f42045aaa91 /hdl/result_printer.sv
parentAdding packed keyword to structs and tweaking tag_t slightly. (diff)
downloadmultipdp8-c88beacfc7aff870272f78ce6043010e2299e211.tar.xz
Print a newline after memory read result prints.
Diffstat (limited to '')
-rw-r--r--hdl/result_printer.sv58
1 files changed, 32 insertions, 26 deletions
diff --git a/hdl/result_printer.sv b/hdl/result_printer.sv
index 3041e6e..4f27d0e 100644
--- a/hdl/result_printer.sv
+++ b/hdl/result_printer.sv
@@ -1,8 +1,7 @@
1`include "defs.svh" 1`include "defs.svh"
2 2
3module result_printer 3module result_printer
4 #( TAG = 0 4 ( input bit clock
5 ) ( input bit clock
6 , input bit reset 5 , input bit reset
7 6
8 , output bit result_ready 7 , output bit result_ready
@@ -14,6 +13,7 @@ module result_printer
14 , output uart_byte_t echo_data 13 , output uart_byte_t echo_data
15 ); 14 );
16 15
16 bit hold_valid;
17 ram_read_response_t hold; 17 ram_read_response_t hold;
18 ram_byte_count_t byte_count; 18 ram_byte_count_t byte_count;
19 ram_word_count_t word_count; 19 ram_word_count_t word_count;
@@ -28,43 +28,49 @@ module result_printer
28 result_ready = 0; 28 result_ready = 0;
29 echo_valid = 0; 29 echo_valid = 0;
30 echo_data = 0; 30 echo_data = 0;
31 hold_valid = 0;
31 byte_count = 0; 32 byte_count = 0;
32 word_count = 0; 33 word_count = 0;
33 state = state.first; 34 state = state.first;
34 end else begin 35 end else begin
35 if (echo_ready) echo_valid = 0; 36 if (echo_ready) echo_valid = 0;
36 if (result_ready && result_valid) begin 37 if (result_ready && result_valid) begin
38 hold_valid = 1;
37 hold = result_data; 39 hold = result_data;
38 if (hold.tag == TAG) begin 40 byte_count = `RAM_WORD_BYTES;
39 byte_count = `RAM_WORD_BYTES; 41 word_count = `RAM_LINE_WORDS;
40 word_count = `RAM_LINE_WORDS; 42 state = state.first;
41 state = state.first;
42 end
43 end 43 end
44 44
45 if (word_count != 0 && !echo_valid) begin 45 if (hold_valid && !echo_valid) begin
46 automatic ram_word_t w = hold.data[word_count-1]; 46 if (word_count != 0) begin
47 automatic ram_byte_t b = w[byte_count-1]; 47 automatic ram_word_t w = hold.data[word_count-1];
48 echo_valid = 1; 48 automatic ram_byte_t b = w[byte_count-1];
49 case (state) 49 echo_valid = 1;
50 HIGH_NIBBLE: echo_data = b[7:4]; 50 case (state)
51 LOW_NIBBLE: echo_data = b[3:0]; 51 HIGH_NIBBLE: echo_data = b[7:4];
52 endcase 52 LOW_NIBBLE: echo_data = b[3:0];
53 if (echo_data < 10) 53 endcase
54 echo_data = echo_data + "0"; 54 if (echo_data < 10)
55 else 55 echo_data = echo_data + "0";
56 echo_data = echo_data + "A" - 10; 56 else
57 state = state.next; 57 echo_data = echo_data + "A" - 10;
58 if (state == state.first) begin 58 state = state.next;
59 byte_count = byte_count - 1; 59 if (state == state.first) begin
60 if (byte_count == 0) begin 60 byte_count = byte_count - 1;
61 byte_count = `RAM_WORD_BYTES; 61 if (byte_count == 0) begin
62 word_count = word_count - 1; 62 byte_count = `RAM_WORD_BYTES;
63 word_count = word_count - 1;
64 end
63 end 65 end
66 end else begin
67 echo_valid = 1;
68 echo_data = "\n";
69 hold_valid = 0;
64 end 70 end
65 end 71 end
66 72
67 result_ready = word_count == 0; 73 result_ready = !hold_valid;
68 end 74 end
69 end 75 end
70 76