summaryrefslogtreecommitdiff
path: root/hdl
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-03-13 16:49:58 -0700
committerJulian Blake Kongslie2022-03-13 16:49:58 -0700
commitf30ba899708ffba0058bdc2380f220b374bc35fa (patch)
tree5dfe4fea5c75c506fbd306b6d528f130dbc2d5b2 /hdl
parentChange FIFO size for UARTs to 1024 bytes in each direction. (diff)
downloadmultipdp8-f30ba899708ffba0058bdc2380f220b374bc35fa.tar.xz
Fix DRAM timings to avoid back-to-back transactions.
Diffstat (limited to '')
-rw-r--r--hdl/ram_controller.sv14
1 files changed, 11 insertions, 3 deletions
diff --git a/hdl/ram_controller.sv b/hdl/ram_controller.sv
index 6eeb46d..8922a09 100644
--- a/hdl/ram_controller.sv
+++ b/hdl/ram_controller.sv
@@ -1,5 +1,8 @@
1`include "defs.svh" 1`include "defs.svh"
2 2
3`define RESET_CYCLES 5 // Spec wants 100ns
4`define TRWR_CYCLES 2 // Spec wants 40ns
5
3module ram_controller 6module ram_controller
4 ( input bit clock 7 ( input bit clock
5 , input bit reset 8 , input bit reset
@@ -82,7 +85,8 @@ module ram_controller
82 , TOGGLE_CLOCK 85 , TOGGLE_CLOCK
83 } half_state; 86 } half_state;
84 87
85 bit [2:0] reset_counter; 88 bit [$clog2(`RESET_CYCLES+1):0] reset_counter;
89 bit [$clog2(`TRWR_CYCLES+1):0] trwr_counter;
86 90
87 bit prev_rwds; 91 bit prev_rwds;
88 92
@@ -100,10 +104,11 @@ module ram_controller
100 base_address = 0; 104 base_address = 0;
101 slow = 0; 105 slow = 0;
102 word_count = `RAM_LINE_WORDS; 106 word_count = `RAM_LINE_WORDS;
107 trwr_counter = `TRWR_CYCLES;
103 state = state.first; 108 state = state.first;
104 half_state = half_state.first; 109 half_state = half_state.first;
105 if (reset) 110 if (reset)
106 reset_counter = 5; // Spec wants >= 100ns of reset 111 reset_counter = `RESET_CYCLES; // Spec wants >= 100ns of reset
107 else 112 else
108 reset_counter = reset_counter - 1; 113 reset_counter = reset_counter - 1;
109 end else begin 114 end else begin
@@ -119,11 +124,12 @@ module ram_controller
119 state = state.first; 124 state = state.first;
120 end 125 end
121 126
122 if (!valid) begin 127 if (!valid || trwr_counter != 0) begin
123 ram_rwds_oe = 0; 128 ram_rwds_oe = 0;
124 ram_data_oe = 0; 129 ram_data_oe = 0;
125 ram_csn = 1; 130 ram_csn = 1;
126 ram_clkp = 0; 131 ram_clkp = 0;
132 if (trwr_counter != 0) --trwr_counter;
127 end else if (half_state == TOGGLE_CLOCK) begin 133 end else if (half_state == TOGGLE_CLOCK) begin
128 half_state = half_state.next; 134 half_state = half_state.next;
129 if (state != CHIP_SELECT && state != SEND_COMMAND_1) 135 if (state != CHIP_SELECT && state != SEND_COMMAND_1)
@@ -217,6 +223,7 @@ module ram_controller
217 end 223 end
218 224
219 endcase 225 endcase
226
220 if (!stall) begin 227 if (!stall) begin
221 state = state.next; 228 state = state.next;
222 if (state == state.first) begin 229 if (state == state.first) begin
@@ -228,6 +235,7 @@ module ram_controller
228 result_data.data = command.data; 235 result_data.data = command.data;
229 result_data.tag = command.tag; 236 result_data.tag = command.tag;
230 end 237 end
238 trwr_counter = `TRWR_CYCLES;
231 end 239 end
232 end 240 end
233 end 241 end