📄 command.v
字号:
/******************************************************************************** LOGIC CORE: Command module * MODULE NAME: command()* COMPANY: Northwest Logic Design, Inc.* www.nwlogic.com** REVISION HISTORY: ** Revision 1.0 05/11/2000 Description: Initial Release.* 1.1 07/10/2000 Description: change precharge to terminate* for full page accesses.** FUNCTIONAL DESCRIPTION:** This module is the command processor module for the SDR SDRAM controller.** Copyright Northwest Logic, Inc., 2000. All rights reserved. ******************************************************************************/ `timescale 1ps / 1psmodule command( CLK, RESET_N, SADDR, NOP, READA, WRITEA, REFRESH, PRECHARGE, LOAD_MODE, SC_CL, SC_RC, SC_RRD, SC_PM, SC_BL, REF_REQ, REF_ACK, CM_ACK, OE, SA, BA, CS_N, CKE, RAS_N, CAS_N, WE_N );`include "params.v"input CLK; // System Clockinput RESET_N; // System Resetinput [`ASIZE-1:0] SADDR; // Addressinput NOP; // Decoded NOP commandinput READA; // Decoded READA commandinput WRITEA; // Decoded WRITEA commandinput REFRESH; // Decoded REFRESH commandinput PRECHARGE; // Decoded PRECHARGE commandinput LOAD_MODE; // Decoded LOAD_MODE commandinput [1:0] SC_CL; // Programmed CAS latencyinput [1:0] SC_RC; // Programmed RC delayinput [3:0] SC_RRD; // Programmed RRD delayinput SC_PM; // programmed Page Modeinput [3:0] SC_BL; // Programmed burst lengthinput REF_REQ; // Hidden refresh requestoutput REF_ACK; // Refresh request acknowledgeoutput CM_ACK; // Command acknowledgeoutput OE; // OE signal for data path moduleoutput [11:0] SA; // SDRAM addressoutput [1:0] BA; // SDRAM bank addressoutput [1:0] CS_N; // SDRAM chip selectsoutput CKE; // SDRAM clock enableoutput RAS_N; // SDRAM RASoutput CAS_N; // SDRAM CASoutput WE_N; // SDRAM WE_N reg CM_ACK;reg REF_ACK;reg OE;reg [11:0] SA;reg [1:0] BA;reg [1:0] CS_N;reg CKE;reg RAS_N;reg CAS_N;reg WE_N;// Internal signals//reg do_nop;reg do_reada;reg do_writea;reg do_writea1;reg do_refresh;reg do_precharge;reg do_load_mode;reg command_done;reg [7:0] command_delay;reg [3:0] rw_shift;//reg do_act;reg rw_flag;reg do_rw;reg [7:0] oe_shift;reg oe1;reg oe2;reg oe3;reg oe4;reg [3:0] rp_shift;reg rp_done;wire [`ROWSIZE - 1:0] rowaddr;wire [`COLSIZE - 1:0] coladdr;wire [`BANKSIZE - 1:0] bankaddr;assign rowaddr = SADDR[`ROWSTART + `ROWSIZE - 1: `ROWSTART]; // assignment of the row address bits from SADDRassign coladdr = SADDR[`COLSTART + `COLSIZE - 1:`COLSTART]; // assignment of the column address bitsassign bankaddr = SADDR[`BANKSTART + `BANKSIZE - 1:`BANKSTART]; // assignment of the bank address bits// This always block monitors the individual command lines and issues a command// to the next stage if there currently another command already running.//always @(posedge CLK or negedge RESET_N)begin if (RESET_N == 0) begin // do_nop <= 0; do_reada <= 0; do_writea <= 0; do_refresh <= 0; do_precharge <= 0; do_load_mode <= 0; command_done <= 0; command_delay <= 0; rw_flag <= 0; rp_shift <= 0; rp_done <= 0; do_writea1 <= 0; end else begin// Issue the appropriate command if the sdram is not currently busy if ((REF_REQ == 1 | REFRESH == 1) & command_done == 0 & do_refresh == 0 & rp_done == 0 // Refresh & do_reada == 0 & do_writea == 0) do_refresh <= 1; else do_refresh <= 0; if ((READA == 1) & (command_done == 0) & (do_reada == 0) & (rp_done == 0) & (REF_REQ == 0)) // READA do_reada <= 1; else do_reada <= 0; if ((WRITEA == 1) & (command_done == 0) & (do_writea == 0) & (rp_done == 0) & (REF_REQ == 0)) // WRITEA begin do_writea <= 1; do_writea1 <= 1; end else begin do_writea <= 0; do_writea1 <= 0; end if ((PRECHARGE == 1) & (command_done == 0) & (do_precharge == 0)) // PRECHARGE do_precharge <= 1; else do_precharge <= 0; if ((LOAD_MODE == 1) & (command_done == 0) & (do_load_mode == 0)) // LOADMODE do_load_mode <= 1; else do_load_mode <= 0; // set command_delay shift register and command_done flag// The command delay shift register is a timer that is used to ensure that// the SDRAM devices have had sufficient time to finish the last command. if ((do_refresh == 1) | (do_reada == 1) | (do_writea == 1) | (do_precharge == 1) | (do_load_mode)) begin command_delay <= 8'b11111111; command_done <= 1; rw_flag <= do_reada; end else begin command_done <= command_delay[0]; // the command_delay shift operation command_delay[6:0] <= command_delay[7:1]; command_delay[7] <= 0; end // start additional timer that is used for the refresh, writea, reada commands if (command_delay[0] == 0 & command_done == 1) begin rp_shift <= 4'b1111; rp_done <= 1; end else begin rp_done <= rp_shift[0]; rp_shift[2:0] <= rp_shift[3:1]; rp_shift[3] <= 0; end end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -