45 parameter NUM_XFER_BITS=
6,
// number of bits to specify transfer length 47 parameter CMD_DONE_BIT=
10,
// VDT BUG: CMD_DONE_BIT is used in a function call parameter! 52 // programming interface 56 input [
NUM_XFER_BITS-
1:
0]
num128_in,
// number of 128-bit words to transfer (8*16 bits) - full burst of 8 (0 - full 64) 58 input start,
// start generating commands 59 output reg [
31:
0]
enc_cmd,
// encoded command SuppressThisWarning VivadoSynthesis [Synth 8-3332] Sequential element cmd_encod_linear_wr.enc_cmd_reg[9,6,4:3] is unused and will be removed from module cmd_encod_linear_wr. 60 output reg enc_wr,
// write encoded command 72 localparam ENC_CMD_SHIFT=
6;
// [7:6] - command: 0 -= NOP, 1 - WRITE, 2 - PRECHARGE, 3 - ACTIVATE 82 // read buffer is always at addr 0 and 1, 83 localparam REPEAT_ADDR=
5;
// loop here (2-cycle command write) 84 localparam PRELAST_WRITE_ADDR=
'h6;
// jump here (from 4) if only 2 writes are needed (are fall from 4 wnen 1 write is left 85 localparam LAST_WRITE_ADDR=
'h8;
// jump here (from 4) if only 2 writes are needed (are fall from 4 wnen 1 write is left 86 localparam NO_WRITE_ADDR=
'ha;
// jump here (from 4) if only 1 write is needed 89 // localparam WRITE_ADDR3= 6; 90 // localparam WRITE_ADDR4= 8; 91 localparam CUT_SINGLE_ADDR=
2;
// cut read buffer after this address if only one burst is needed 92 localparam CUT_DUAL_ADDR=
4;
// cut read buffer after this address if two bursts are needed 97 localparam CMD_NOP=
0;
// 3-bit normal memory RCW commands (positive logic) 103 reg [
COLADDR_NUMBER-
4:
0]
col;
// start memory column (3 LSBs should be 0?) // VDT BUG: col is used as a function call parameter! 104 reg [
2:
0]
bank;
// memory bank; 112 reg [
ROM_WIDTH-
1:
0]
rom_r;
// SuppressThisWarning VivadoSynthesis: [Synth 8-3332] Sequential element cmd_encod_linear_wr.rom_r_reg[8] is unused and will be removed from module cmd_encod_linear_wr. 125 reg [
ROM_DEPTH-
1:
0]
jump_gen_addr;
// will overrun as stop comes from ROM SuppressThisWarning VivadoSynthesis: [Synth 8-3332] Sequential element cmd_encod_linear_wr.jump_gen_addr_reg[0] is unused and will be removed from module cmd_encod_linear_wr. 131 // prepare jump address? and bufrd during 2,3 133 // make num128 7-bits to accommodate 64! 134 always @ (
posedge clk)
begin 138 always @ (
posedge clk)
begin 175 always @ (
posedge clk)
begin 180 // ROM-based (registered output) encoded sequence 181 // TODO: Remove last ENC_BUF_RD 182 always @ (
posedge clk)
begin 189 // 4'h4: rom_r <= (ENC_CMD_NOP << ENC_CMD_SHIFT) | (1 << ENC_BUF_RD) | (1 << ENC_DQ_DQS_EN) | (1 << ENC_ODT); // single cycle 205 always @ (
posedge clk)
begin 211 // else enc_done <= enc_wr || !gen_run_d; 217 {{
CMD_PAUSE_BITS-
2{
1'b0}},
rom_skip[
1:
0]},
// skip; // number of extra cycles to skip (and keep all the other outputs) 218 pre_done,
// done, // end of sequence 219 bank[
2:
0],
// bank (here OK to be any) 221 1'b0,
// cke; // disable CKE 222 rom_r[
ENC_SEL],
// sel; // first/second half-cycle, other will be nop (cke+odt applicable to both) 223 rom_r[
ENC_DQ_DQS_EN],
// dq_en; // enable (not tristate) DQ lines (internal timing sequencer for 0->1 and 1->0) 224 rom_r[
ENC_DQ_DQS_EN],
// dqs_en; // enable (not tristate) DQS lines (internal timing sequencer for 0->1 and 1->0) 226 1'b0,
// dci; // DCI disable, both DQ and DQS lines (internal logic and timing sequencer for 0->1 and 1->0) 227 1'b0,
// buf_wr; // connect to external buffer (but only if not paused) 230 else enc_cmd <=
func_encode_cmd (
// encode non-NOP command 234 bank[
2:
0],
// bank (here OK to be any) 235 full_cmd[
2:
0],
// rcw; // RAS/CAS/WE, positive logic 237 1'b0,
// cke; // disable CKE 238 rom_r[
ENC_SEL],
// sel; // first/second half-cycle, other will be nop (cke+odt applicable to both) 239 rom_r[
ENC_DQ_DQS_EN],
// dq_en; // enable (not tristate) DQ lines (internal timing sequencer for 0->1 and 1->0) 240 rom_r[
ENC_DQ_DQS_EN],
// dqs_en; // enable (not tristate) DQS lines (internal timing sequencer for 0->1 and 1->0) 242 1'b0,
// dci; // DCI disable, both DQ and DQS lines (internal logic and timing sequencer for 0->1 and 1->0) 243 1'b0,
// buf_wr; // connect to external buffer (but only if not paused) 245 rom_r[
ENC_NOP],
// nop; // add NOP after the current command, keep other data 251 // move to include?/*! 252 * @file x393_mcontr_encode_cmd.vh
254 * @author Andrey Filippov
256 * @brief Functions used to encode memory controller sequences
258 * @copyright Copyright (c)
2015 Elphel, Inc.
262 * x393_mcontr_encode_cmd.vh is free software; you can redistribute it
and/
or modify
263 * it under the terms of the GNU General Public License as published by
264 * the Free Software Foundation, either version
3 of the License,
or 265 * (at your option) any later version.
267 * x393_mcontr_encode_cmd.vh is distributed in the hope that it will be useful,
268 * but WITHOUT ANY WARRANTY; without even the implied warranty of
269 * MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE. See the
270 * GNU General Public License
for more details.
272 * You should have received a copy of the GNU General Public License
273 * along with this program.
If not, see <http:
//www.gnu.org/licenses/> . 275 * Additional permission under GNU GPL version
3 section
7:
276 *
If you modify this Program,
or any covered work, by linking
or combining it
277 * with independent modules provided by the FPGA vendor only (this permission
278 * does
not extend to any
3-rd party modules,
"soft cores" or macros) under
279 * different license terms solely
for the purpose of generating binary
"bitstream" 280 * files
and/
or simulating the code, the copyright holders of this Program give
281 * you the right to distribute the covered work without those independent modules
282 * as long as the source code
for them is available from the FPGA vendor free of
283 * charge,
and there is no dependence on any encrypted modules
for simulating of
284 * the combined code. This permission applies to you
if the distributed code
285 * contains all the components
and scripts required to completely simulate it
286 * with at least one of the Free Software programs.
289 function [
31:
0] func_encode_cmd;
290 input [
14:
0] addr;
// 15-bit row/column address 291 input [
2:
0]
bank;
// bank (here OK to be any) 292 input [
2:
0] rcw;
// RAS/CAS/WE, positive logic 293 input odt_en;
// enable ODT 294 input cke;
// disable CKE 295 input sel;
// first/second half-cycle, other will be nop (cke+odt applicable to both) 296 input dq_en;
// enable (not tristate) DQ lines (internal timing sequencer for 0->1 and 1->0) 297 input dqs_en;
// enable (not tristate) DQS lines (internal timing sequencer for 0->1 and 1->0) 298 input dqs_toggle;
// enable toggle DQS according to the pattern 299 input dci;
// DCI disable, both DQ and DQS lines (internal logic and timing sequencer for 0->1 and 1->0) 300 input buf_wr;
// connect to external buffer (but only if not paused) 301 input buf_rd;
// connect to external buffer (but only if not paused) 302 input nop;
// add NOP after the current command, keep other data 303 input buf_rst;
// connect to external buffer (but only if not paused) 306 addr[
14:
0],
// 15-bit row/column address 308 rcw[
2:
0],
// RAS/CAS/WE 309 odt_en,
// enable ODT 310 cke,
// may be optimized (removed from here)? 311 sel,
// first/second half-cycle, other will be nop (cke+odt applicable to both) 312 dq_en,
// enable (not tristate) DQ lines (internal timing sequencer for 0->1 and 1->0) 313 dqs_en,
// enable (not tristate) DQS lines (internal timing sequencer for 0->1 and 1->0) 314 dqs_toggle,
// enable toggle DQS according to the pattern 315 dci,
// DCI disable, both DQ and DQS lines (internal logic and timing sequencer for 0->1 and 1->0) 316 buf_wr,
// phy_buf_wr, // connect to external buffer (but only if not paused) 317 buf_rd,
// phy_buf_rd, // connect to external buffer (but only if not paused) 318 nop,
// add NOP after the current command, keep other data 319 buf_rst
// Reserved for future use 324 function [
31:
0] func_encode_skip;
325 input [
CMD_PAUSE_BITS-
1:
0] skip;
// number of extra cycles to skip (and keep all the other outputs) 326 input done;
// end of sequence 327 input [
2:
0]
bank;
// bank (here OK to be any) 328 input odt_en;
// enable ODT 329 input cke;
// disable CKE 330 input sel;
// first/second half-cycle, other will be nop (cke+odt applicable to both) 331 input dq_en;
// enable (not tristate) DQ lines (internal timing sequencer for 0->1 and 1->0) 332 input dqs_en;
// enable (not tristate) DQS lines (internal timing sequencer for 0->1 and 1->0) 333 input dqs_toggle;
// enable toggle DQS according to the pattern 334 input dci;
// DCI disable, both DQ and DQS lines (internal logic and timing sequencer for 0->1 and 1->0) 335 input buf_wr;
// connect to external buffer (but only if not paused) 336 input buf_rd;
// connect to external buffer (but only if not paused) 337 input buf_rst;
// connect to external buffer (but only if not paused) 339 func_encode_skip= func_encode_cmd (
341 bank[
2:
0],
// bank (here OK to be any) 342 3'b0,
// RAS/CAS/WE, positive logic 343 odt_en,
// enable ODT 345 sel,
// first/second half-cycle, other will be nop (cke+odt applicable to both) 346 dq_en,
// enable (not tristate) DQ lines (internal timing sequencer for 0->1 and 1->0) 347 dqs_en,
// enable (not tristate) DQS lines (internal timing sequencer for 0->1 and 1->0) 348 dqs_toggle,
// enable toggle DQS according to the pattern 349 dci,
// DCI disable, both DQ and DQS lines (internal logic and timing sequencer for 0->1 and 1->0) 350 buf_wr,
// connect to external buffer (but only if not paused) 351 buf_rd,
// connect to external buffer (but only if not paused)
4065colreg[COLADDR_NUMBER-4:0]
[NUM_XFER_BITS-1:0] 4030num128_in
[COLADDR_NUMBER-4:0] 4029start_col
4071rom_rreg[ROM_WIDTH-1:0]
4067num128reg[NUM_XFER_BITS:0]
4053PRELAST_WRITE_ADDR'h6
4070gen_addrreg[ROM_DEPTH-1:0]
4064rowreg[ADDRESS_NUMBER-1:0]
4083jump_gen_addrreg[ROM_DEPTH-1:0]
[ADDRESS_NUMBER-1:0] 4028row_in