rsp.v 13.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1994, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *                                                                        *
 *************************************************************************/
// $Id: rsp.v,v 1.7 2003/01/23 19:10:15 berndt Exp $

// rsp.v:	the whole shebang

`timescale 1ns / 10ps

module rsp(clk, reset_l,
    sp_cbus_read_enable, sp_cbus_write_enable, mem_cbus_write_enable, 
    cmd_cbus_read_enable, cmd_cbus_write_enable, 
    cbus_select, cbus_command, 
    dma_start, dma_last, sp_dma_grant, sp_read_grant, cmd_dma_grant, 
    cmd_read_grant, sp_dbus_read_enable, sp_dbus_write_enable, cbuf_ready, 
    cmd_busy, pipe_busy, tmem_busy,
    sp_dma_request, sp_read_request, mem_read_request,
    cmd_dma_request, cmd_read_request, flush, freeze, unfreeze, frozen,
    sp_interrupt, cbuf_write, xbus_data, cbus_din, cbus_dout, 
    dbus_din, dbus_dout);

   input		clk;
   input		reset_l;

   // DMA-related IO

   input		frozen;
   input		sp_cbus_read_enable;
   input		sp_cbus_write_enable;
   input		mem_cbus_write_enable;	// *** Use for CPU read of mems
   input		cmd_cbus_read_enable;
   input		cmd_cbus_write_enable;
   input	[1:0]	cbus_select;
   input	[2:0]	cbus_command;
   input		dma_start;
   input		dma_last;
   input		sp_dma_grant;
   input		sp_read_grant;
   input		cmd_dma_grant;
   input		cmd_read_grant;
   input		sp_dbus_read_enable;
   input		sp_dbus_write_enable;
   input		cbuf_ready;
   input 		cmd_busy;		// DP CMDBUF is not empty
   input 		pipe_busy;		// DP pipeline is active
   input 		tmem_busy;		// DP TMEM is loading

   input	[31:0]	cbus_din;
   input	[63:0]	dbus_din;
   output	[31:0]	cbus_dout;
   output	[63:0]	dbus_dout;

   output		sp_dma_request;
   output		sp_read_request;
   output		mem_read_request;
   output		cmd_dma_request;
   output		cmd_read_request;
   output		cbuf_write;
   output		flush;
   output		freeze;
   output		unfreeze;
   output		sp_interrupt;
   output	[63:0]	xbus_data;

   wire		[31:0]	rsp_cbus_dout;
   wire		[31:0]	mem_cbus_dout;
   wire		[31:0]	cmd_cbus_dout;

   wire		[31:0]	cbus_dout = rsp_cbus_dout 
				  | mem_cbus_dout 
				  | cmd_cbus_dout;

   wire		[63:0]  rd_inst;		// imem output
   wire		[63:0]  rd_inst_buf;		// imem output buffered in su
   wire       	[11:0] 	branch_or_addr;
   wire		[11:3] 	final_pc;		// IF stage
   wire		[11:2]  pc;
   wire			set_broke;
   wire			imem_dma_cycle;
   wire			imem_web;
   wire		[3:0]	rd_base;
   wire			ls_drive_rd_base;
   wire		[3:0]	rd_offset;
   wire		[3:0]	rd_elem_num;
   wire			vu_ex_load;
   wire			vu_ex_store;
   wire			su_ex_load;
   wire			su_ex_store;
   wire			ex_mfc2;
   wire			ex_mtc2;
   wire			ex_cfc2;
   wire			ex_mfc0;
   wire	   	[11:0]	vu_rd_ld_dec_k;
   wire	   	[11:0]	vu_rd_st_dec_k;
   wire		[15:0]	vu_bwe;
   wire	        [31:0]  su_ls_data;
   wire	        [127:0]	vu_ls_data;
   wire	        [127:0]	ls_ls_data;
   wire	        [127:0]	ls_dout = {su_ls_data[31:0],{96{1'b0}}}
				|  ls_ls_data
				|  vu_ls_data;
   wire			df_ls_drive_ls_in_wb;
   wire			df_pass_thru;
   wire   		chip_sel;		// suctl -> ls, active high
   wire		[127:0] df_datain;
   wire   		df_chip_sel_l;
   wire		[15:0] 	df_wen_l;		// write enable, active low
   wire       	[11:0] 	df_addr_low;
   wire       	[11:0] 	df_addr_high;
   wire		[127:0]	dmem_dataout;
   wire		[63:0]	dmem_rd_data;
   wire		[63:0]	mem_write_data;
   wire			ex_su_byte_ls;
   wire			ex_su_half_ls;
   wire			ex_su_uns_ls;
   wire			imem_csb;
   wire			su_nop_debug;
   wire			vu_nop_debug;
   wire			break_inst_debug;

					// SU ctl to VU
   wire	 		vu_comp;
   wire	 		vu_comp_k;
   wire		[5:0]	vu_func;
   wire			ex_ctc2_vc0;
   wire			ex_ctc2_vc1;
   wire			ex_ctc2_vc2;
   wire			vu_rd_store_type_k;
   wire		[3:0]	vu_elem;

   wire		[4:0]	vu_ld_addr;
   wire		[4:0]	vu_st_addr;
   wire		[4:0]	vu_st_xpose_addr;
   wire		[4:0]   vs;          	// RD: reg num for vs read
   wire		[4:0]   vt;          	// RD: reg num for vt read
   wire		[4:0]   acc_wr_reg;    	// DF: reg num for datapath writeback
   wire			acc_wr_en;  	// DF: write en for dp results
   wire			store_xpose_rd;
   wire			load_xpose_wb;

   wire			rd_cfvc0_k;
   wire			rd_cfvc1_k;
   wire			rd_cfvc2_k;

   // DMA-related Wires

   wire			halt;
   wire			single_step;
   wire		[11:2]	pc_data_in;		// from cp0 
   wire			pc_in_wr_en;
   wire		[31:0]	 ls_cp0_dout;		// CP0 data from ls
   wire		[31:0]	mem_cp0_dout;		// CP0 data from mem
   wire		[31:0]	cmd_cp0_dout;		// CP0 data from cmd
   wire		[31:0]	cp0_data =  ls_cp0_dout
				 | mem_cp0_dout
				 | cmd_cp0_dout;// CP0 data to su
   wire		[3:0]	cp0_address;
   wire			cp0_write;		// CTC2, EX
   wire			cp0_enable;		// CFC2, EX
   wire			dma_imem_select;
   wire		[3:0]	dma_wen;
   wire		[11:3]	dma_address;
   wire 		ex_dma_rd_to_dm;
   wire 		ex_dma_dm_to_rd;
   wire			dma_rd_to_dm;
   wire			dma_dm_to_rd;
   wire		[1:0]	dma_mask;
   wire			io_read_select;
   wire			io_write_select;
   wire			mem_load;
   wire			io_load;
   wire			xbus_dmem_select;
   wire			cmd_read;
   wire			cmd_ready;
   wire		[8:0]	cmd_address;
   wire			dma_busy;		// In case we want CP0 branch.
   wire		[63:0]	imem_datain;

   wire			debug_df_dma_rd_to_dm;

  su su (
	.clk			(clk),
	.reset_l		(reset_l),
	.halt			(halt),
	.single_step		(single_step),
	.pc_in_wr_en		(pc_in_wr_en),
	.pc_data_in		(pc_data_in),
	.dma_dm_to_rd		(dma_dm_to_rd),
	.dma_rd_to_dm		(dma_rd_to_dm),
	.dma_imem_select	(dma_imem_select),
	.rd_inst		(rd_inst),
	.rd_base		(rd_base),
	.ls_drive_rd_base	(ls_drive_rd_base),
	.rd_offset		(rd_offset),
	.rd_elem_num		(rd_elem_num),
	.chip_sel		(chip_sel),
	.su_ex_store		(su_ex_store),
	.su_ex_load		(su_ex_load),
	.vu_ex_store		(vu_ex_store),
	.vu_ex_load		(vu_ex_load),
	.ex_mfc2		(ex_mfc2),
	.ex_mtc2		(ex_mtc2),
	.ex_cfc2		(ex_cfc2),
	.ex_mfc0		(ex_mfc0),
	.ex_su_byte_ls		(ex_su_byte_ls),
	.ex_su_half_ls		(ex_su_half_ls),
	.ex_su_uns_ls		(ex_su_uns_ls),
	.df_ls_drive_ls_in_wb	(df_ls_drive_ls_in_wb), 
	.df_pass_thru		(df_pass_thru),

	.imem_dma_cycle		(imem_dma_cycle),
	.su_nop_debug		(su_nop_debug),
	.vu_nop_debug		(vu_nop_debug),
	.pc			(pc),

	.branch_or_addr		(branch_or_addr[11:0]),
	.set_broke		(set_broke),
	.vu_rd_ld_dec_k		(vu_rd_ld_dec_k),
	.vu_rd_st_dec_k		(vu_rd_st_dec_k),
	.break_inst_debug	(break_inst_debug),

	.ls_data		(ls_dout[127:96]),
	.su_ls_data		(su_ls_data[31:0]),

							// VU controls:
 	.vu_comp		(vu_comp),
 	.vu_comp_k		(vu_comp_k),
	.vu_func		(vu_func),
	.ex_ctc2_vc0		(ex_ctc2_vc0),
	.ex_ctc2_vc1		(ex_ctc2_vc1),
	.ex_ctc2_vc2		(ex_ctc2_vc2),
	.vu_rd_store_type_k	(vu_rd_store_type_k),
	.vu_elem		(vu_elem),

	.vu_ld_addr		(vu_ld_addr),
	.vu_st_addr		(vu_st_addr),
	.vu_st_xpose_addr	(vu_st_xpose_addr),
        .vs 			(vs),
        .vt 			(vt),
        .acc_wr_reg		(acc_wr_reg),
        .acc_wr_en 		(acc_wr_en),
        .store_xpose_rd		(store_xpose_rd),
        .load_xpose_wb		(load_xpose_wb),

	.rd_cfvc0_k		(rd_cfvc0_k),
	.rd_cfvc1_k		(rd_cfvc1_k),	
	.rd_cfvc2_k		(rd_cfvc2_k),	

	.cp0_address		(cp0_address),	
	.cp0_write 		(cp0_write),
	.cp0_enable 		(cp0_enable),
	.rd_inst_buf 		(rd_inst_buf)
   );   

    vu vu (						// VU inputs:
	.clk			(clk),	
	.reset_l		(reset_l),
	.su_storeinst_rd 	(vu_rd_store_type_k),	// store from VU 
	.su_instvld_rd		(vu_comp),	// valid CP2 inst
	.su_instvldk_rd		(vu_comp_k),	// valid CP2 inst
	.su_vseqone_rd		(vs[0]),
	.su_instelem_rd		(vu_elem),	// inst[elem]
	.su_instfunc_rd		(vu_func),	// inst[func]
	.su_rdcryout_rd		(rd_cfvc0_k),	// read VCO (vc0)
	.su_rdcmpcd_rd		(rd_cfvc1_k),	// read VCC (vc1)
	.su_rdcmpcdad_rd	(rd_cfvc2_k),	// read VCE (vc2)
	.su_wrcryout_wb		(ex_ctc2_vc0),	// write VCO (vc0)
	.su_wrcmpcd_wb		(ex_ctc2_vc1),	// write VCC (vc1)
	.su_wrcmpcdad_wb	(ex_ctc2_vc2),	// write VCE (vc2)

	.su_ld_rnum_ac		(vu_ld_addr),
	.su_st_rnum_rd		(vu_st_addr),
	.su_xp_rnum_rd		(vu_st_xpose_addr),
        .su_vs_addr_rd 		(vs),      	// reg num for vs read 
        .su_vt_addr_rd		(vt),		// reg num for vt read 
        .su_vd_addr_ac 		(acc_wr_reg),   // reg num for dp writeback 
        .su_wbv_wr_en_ac	(acc_wr_en), 	// write en for dp results 
        .su_bwe_ac 		(vu_bwe),       // load port byte wr en 
        .su_st_xposeop_rd	(store_xpose_rd),
        .su_ld_xposeop_wb	(load_xpose_wb),

	.su_data_to_from	(ls_dout),	// 128 bit load/store bus
	.vu_ls_data		(vu_ls_data)	// 128 bit load/store bus

   );

	// instantiate new dmem;

	wire sp_dmem_ena = 1'b0;

	sp_dmem dmem (
		.clk(clk),
		.csb(sp_dmem_ena),
		.web(df_wen_l),
		.addr_low(df_addr_low[11:4]),
		.addr_high(df_addr_high[11:4]),
		.di(df_datain),
		.do(dmem_dataout)
	);

   ls ls(
        .clk 			(clk),
	.reset_l		(reset_l),
	.halt			(halt),
	.rd_base		(rd_base),
	.ls_drive_rd_base	(ls_drive_rd_base),
	.rd_offset		(rd_offset),
	.rd_elem_num		(rd_elem_num),
        .address 		(branch_or_addr[11:0]),
	.df_ls_drive_ls_in_wb	(df_ls_drive_ls_in_wb), 
	.df_pass_thru		(df_pass_thru),
	.vu_ex_load		(vu_ex_load),
	.vu_ex_store		(vu_ex_store),
	.su_ex_store		(su_ex_store),
	.su_ex_load		(su_ex_load),
	.ex_mfc2		(ex_mfc2),
	.ex_mtc2		(ex_mtc2),
	.ex_cfc2		(ex_cfc2),
	.cp0_write 		(cp0_write),
	.vu_rd_ld_dec_k		(vu_rd_ld_dec_k),
	.vu_rd_st_dec_k		(vu_rd_st_dec_k),
        .chip_sel 		(chip_sel),
	.ex_su_byte_ls		(ex_su_byte_ls),
	.ex_su_half_ls		(ex_su_half_ls),
	.ex_su_uns_ls		(ex_su_uns_ls),
	.ex_dma_rd_to_dm	(ex_dma_rd_to_dm),
	.ex_dma_dm_to_rd	(ex_dma_dm_to_rd),
	.dma_wen		(dma_wen),
	.dma_address		(dma_address),
        .dmem_dataout	 	(dmem_dataout),
	.mem_write_data		(mem_write_data),
	.ex_mfc0		(ex_mfc0),
	.pc			(pc),

	.vu_bwe			(vu_bwe[15:0]),
        .df_chip_sel_l		(df_chip_sel_l),
        .df_wen_l 		(df_wen_l),
        .df_addr_low		(df_addr_low[11:0]),
        .df_addr_high  		(df_addr_high[11:0]),
	.dmem_rd_data		(dmem_rd_data),
        .df_datain 		(df_datain[127:0]),
	.debug_df_dma_rd_to_dm	(debug_df_dma_rd_to_dm),

        .ls_data		(ls_dout),
        .ls_ls_data		(ls_ls_data),
	.cp0_din		(cp0_data),
	.cp0_dout		(ls_cp0_dout)
   );

   rspbusses rspbusses(
        .clk 			(clk),
	.reset_l		(reset_l),

	.cbus_write_enable	(mem_cbus_write_enable),
        .dbus_read_enable	(sp_dbus_read_enable),
        .dbus_write_enable	(sp_dbus_write_enable),
	.io_load		(io_load),
	.io_read_select		(io_read_select),
	.io_write_select	(io_write_select),
	.dma_imem_select	(dma_imem_select),
	.xbus_dmem_select	(xbus_dmem_select),
        .dma_dm_to_rd 		(dma_dm_to_rd),
        .dma_rd_to_dm 		(dma_rd_to_dm),
	.dma_address		(dma_address),
        .dma_mask 		(dma_mask),
	.mem_load		(mem_load),
	.im_to_rd_data		(rd_inst_buf),
	.dmem_rd_data		(dmem_rd_data),

	.pc			(pc),
	.final_pc		(final_pc),
	.imem_dma_cycle		(imem_dma_cycle),

        .cbus_din 		(cbus_din),
        .cbus_dout 		(rsp_cbus_dout),
        .dbus_din 		(dbus_din),
        .dbus_dout 		(dbus_dout),
	.xbus_data		(xbus_data),

	.ex_dma_rd_to_dm	(ex_dma_rd_to_dm),
	.ex_dma_dm_to_rd	(ex_dma_dm_to_rd),
	.mem_write_data		(mem_write_data),
        .imem_datain		(imem_datain),
	.imem_web		(imem_web),
	.imem_csb		(imem_csb),
	.dma_wen		(dma_wen)
   );

   wire sp_imem_ena = 1'b0;

   sp_imem imem(
        .di	 		(imem_datain),
        .a	 		(final_pc),
	.csb			(sp_imem_ena),
        .pcg 			(clk),
	.web			(imem_web),
        .dout	 		(rd_inst)
   );

   io_mem_dma io_mem_dma (

	.clock			(clk),
	.reset_l		(reset_l),
	.cp0_enable 		(cp0_enable),
	.cbus_read_enable	(sp_cbus_read_enable),
	.cbus_write_enable	(sp_cbus_write_enable),
	.cbus_select		(cbus_select),
	.cbus_command		(cbus_command),
	.dma_start		(dma_start),
	.dma_last		(dma_last),
	.dma_grant		(sp_dma_grant),
	.read_grant		(sp_read_grant),
	.cp0_cmd_select		(cp0_address[3]),
	.cp0_address		(cp0_address[2:0]),
	.cp0_write 		(cp0_write),
	.cp0_read		(ex_mfc0),
	.set_broke		(set_broke),
	.cmd_read		(cmd_read),
	.cmd_address		(cmd_address),

	.dma_request		(sp_dma_request),
	.reg_read_request	(sp_read_request),
	.mem_read_request	(mem_read_request),
	.imem_select		(dma_imem_select),
	.mem_address		(dma_address),
	.mem_read		(dma_dm_to_rd),
	.mem_write		(dma_rd_to_dm),
	.mem_mask		(dma_mask),
	.halt			(halt),
	.single_step		(single_step),
	.dma_busy		(dma_busy),
	.cmd_ready		(cmd_ready),
	.pc_write		(pc_in_wr_en),
	.pc_data		(pc_data_in),
	.io_read_select		(io_read_select),
	.io_write_select	(io_write_select),
	.mem_load		(mem_load),
	.io_load		(io_load),
	.interrupt		(sp_interrupt),
	.cp0_din 		(cp0_data),
	.cp0_dout 		(mem_cp0_dout),
	.cbus_din		(cbus_din),
	.cbus_dout		(mem_cbus_dout)
    );

    io_cmd_dma io_cmd_dma (

	.clock			(clk),
	.reset_l		(reset_l),
	.start_gclk		(frozen),
	.cp0_enable 		(cp0_enable),
	.cbus_read_enable	(cmd_cbus_read_enable),
	.cbus_write_enable	(cmd_cbus_write_enable),
	.cbus_select		(cbus_select),
	.cbus_command		(cbus_command),
	.dma_start		(dma_start),
	.dma_last		(dma_last),
	.dma_grant		(cmd_dma_grant),
	.read_grant		(cmd_read_grant),
	.cbuf_ready		(cbuf_ready),
	.cp0_cmd_select		(cp0_address[3]),
	.cp0_address		(cp0_address[2:0]),
	.cp0_write 		(cp0_write),
	.cmd_ready		(cmd_ready),
	.cmd_busy		(cmd_busy),
	.pipe_busy		(pipe_busy),
	.tmem_busy		(tmem_busy),
	.dma_request 		(cmd_dma_request),
	.read_request 		(cmd_read_request),
	.cbuf_write		(cbuf_write),
	.xbus_dmem_select	(xbus_dmem_select),
	.cmd_read		(cmd_read),
	.cmd_address		(cmd_address),
	.flush			(flush),
	.freeze			(freeze),
	.unfreeze		(unfreeze),
	.cp0_din		(cp0_data),
	.cp0_dout		(cmd_cp0_dout),
	.cbus_din		(cbus_din),
	.cbus_dout		(cmd_cbus_dout)
    );

endmodule