ms.v 21.9 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 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519

 /************************************************************************\
 *                                                                        *
 *               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: ms.v,v 1.1 2002/03/28 00:26:13 berndt Exp $
//		top level for memspan
//  this module contains instantiation of spanbuf.v and the four memspan
//  logic modules ms_sm.v, ms_sc.v, ms_si.v, ms_rp.v as well as the
//  dither module from phil ms_rand.v;
//
//	added:  tristate driver cells dbus_driver.v  ebus_driver.v
//	to add:  64b driver to/from texture unit (tonyd, rws)
//
//  Note:  memspan does not differentiate between primitives, e.g. each
//  span from its point of view is a primitive;  it's up to the host to
//  perform sync's as needed to achieve expected results...
//
//  Phasing info:  all is relative to "startspant0" here:  later by:
//	5 clocks:  z to blend OR load data to texture unit
//	6 clocks:  c to blend AND alpha from color combiner unit
//*new* 7 clocks:  copy data from texture unit to memspan
//	8 clocks:  z from blend 
//	9 clocks:  c from blend
//	14 clocks: writemasks latched, launch write of spanlet

//  (note:  above is max case; actual can be up to 3 less due to mode
//   controlled pipe length, needed to allow sustained throughput r/w c/z
//   of the single port register file spanbufs;  and behaviorally all are
//   extended a clock functionally if twocycle mode case, but this is details)
//
//  Prefetch occurs much before the above, determined by EW output to
//	span buffer timing relative to startspant0.

//	span buffer not yet designed/sized (see notes herein);
//	***add cbus i/f module, tristate dbus module********

//  a note on stalls:  the working assumption is that the memspan stall
//  signal "stopgclock" is used "immediately" to defer next rising edge
//  of gclock.

//mods 10-19-94:  rel_sync_full, stb_sync_full, unfreeze_gclk, freeze_gclk;
//mods 10-20-94:  tristate drivers ms_drve/t/d.v, cbus module "ms_dma.v";
//			add pipe_busy output from ms_sm.v
//mods 10-26-94:  add startspant12, endspant11, fullc/zwmt11, stallnxtwm
//mods 10-28-94:  cbus read/write separate enables, add stopgclock to ms_sc.v
//mods 11-7 add endspant14 (sc, rp)
//mods 11-10 add BIST
//mods 11-16:  add wire copywen (ms_si to ms_rp), si:  ccalpha, alphacompen;
//		also wrcopymode_buf, wrcsize8_buf, wrcsize16_buf;
//mods 11-17:  add rdpc/zwptrn[6:0] from ms_rp to ms_si for ldc/zbufwen phasing;
//mods 11-20:  add to si: dithalpha, dithalphaen, blendalpha for copymode;
//mods 11-21:  add stallwptr from ms_rp to ms_si to kill rdpwe at stalls;
//	add rmwcsize32 to ms_rp for cptrinc;
//mods 11-23:  add ms_sm outport start_gclk, prop to top level;
//mods 11-29:  buffer fillcolor as wrfillcolor in ms_sc.v
//mods 12-2:  add stallptr input to ms_si for conflict sm
//mods 12-5:  add out/in wrrender_buf ms_sc/ms_rp
//     12-6:  add rmwenreadc into ms_si for coverage hack;
//	12-7:  mod startspan(input), startspand2(stall creation);
//		undo d2 mod
//	12-22:  add sc->rp:  wrloadmode_buf, wrenreadz_buf for transl fix;
//	12-30:  add validt2 to ms_sc.v (new year's hack);
//	1-3 add rmwenreadz from ms_sc to ms_si for zread force at enreadz=0;
//	1-4 add test_mode1 from ms_debug to ms_si, ms_rp; test_mode0 to ms_sc;
//	  stallrdctxtd, stallwrctxtd, stallczwmd, stallc/zr/wd to ms_debug;
//		also add stopgclockd;
//	1-5 add  rel_sync_full to diags; also:  stb_sync_full;
//	2-1  add start4ms from ms_sm to ms_si for extphase bug fix;
//		SECOND TAPEOUT MODS
//	3-30-95  add new ports rp => si:  limitcw, limitzw (timing paths);
//		remove stallwptr rp => si ports;
//	4-4-95  connect test_mode0 from ms_debug to ms_sc to reset ptrs;
//	6/2/95 (pg) added ordered dither stuff
//	6-9-95 update buswidth for start_gclk, now a bus for new gclk scheme;

`timescale 1ns/1ns

module ms(clock, gclock, reset_l, grant, start, finish, dma_write_enable,
	dma_read_enable, cbus_read_enable, cbus_write_enable, cbus_select,
	cbus_command, read_grant,
	stb_sync_full, freeze_gclk, unfreeze_gclk,
	cycle_type, image_read_en, z_update_en, z_compare_en, color_base,
	color_size, color_format, z_base, tex_base, tex_size, tex_format,
	load_tlut_en, fillcolor, alphacompen, dithalphaen, blendalpha, noise,
	startspant0, nextspanxi, nextspanxf, nextspancount, nextspanxdec,
	load_en, spanbufmt, rdpwdepthin, rdpwredin, rdpwgreenin,
	rdpwbluein, rdpwalphain, rdpcolorwen, ccalpha,
	dither_sel, rgb_dither,
	bist_done, bist_fail,

//bidirectional
	copy_load, cbus_data, dbus_data, ebus_data,

//outputs begin
	load_dv, rel_sync_full, pipe_busy,
	stopgclock, start_gclk, rdramreq, read_request, rdramrw,
	spanbufrd, rdprred, rdprgreen, rdprblue, rdpralpha,
	bist_go, bist_check,
	start_gclk1, start_gclk2, start_gclk3,
	start_gclk4, start_gclk5, start_gclk6,
	rdprdepthd);

// `include "ms.vh"	// Note: causes some sort of asic synth problem.
`include "ms.vh"	//hmmm...right now I need it to compile....rws 10-19

`timescale 10ps/10ps    //1unit = 0.01ns

input clock;					// system clock
input gclock;                                   // stallable system clock
input bist_done;
input [7:0] bist_fail;

input reset_l;					// system reset
input stb_sync_full;				//full sync request to ms
input freeze_gclk;				//from host, freeze gclk
input unfreeze_gclk;				//from sp, undo fullsync freeze

input grant;					//dma grant
input start;					//dma data valid
input finish;					//dma read last cycle
input dma_write_enable;				//ms to io tristate en
input dma_read_enable;				//io to ms enable

input cbus_read_enable;
input cbus_write_enable;
input [1:0] cbus_select;
input [2:0] cbus_command;
input read_grant;

input [1:0]  cycle_type;			//attributes etc. begin
input image_read_en;
input z_update_en;
input z_compare_en;
input [25:0]  color_base;
input [1:0]  color_size;
input [2:0]  color_format;
input [25:0]  z_base;
input [25:0]  tex_base;
input [1:0]  tex_size;
input [2:0]  tex_format;
input load_tlut_en;				//ignored unless load_en set
input [31:0]  fillcolor;
input alphacompen;
input dithalphaen;
input [7:0]  blendalpha;
input [2:0] noise;				//cc noise to dither gen

input startspant0;				//startspan from EW pipe, delay

input [19:0]  nextspanxi;			//EW initial span pix coord
input [11:0]  nextspanxf;			//EW final span pix coord
input [11:0]  nextspancount;			//EW count per span
input nextspanxdec;				//right major per span
input load_en;					//load enable per span
input spanbufmt;				//span buffer empty

input [17:0]  rdpwdepthin;			//depth value from blend
input [7:0] rdpwredin;
input [7:0] rdpwgreenin;
input [7:0] rdpwbluein;
input [2:0] rdpwalphain;
input rdpcolorwen;				//wen (sync'd with color)
input [7:0]  ccalpha;				//alpha from cc
input [1:0] dither_sel;
input [2:0] rgb_dither;

inout [63:0] copy_load;		// bidirectional copy / load bus
inout [31:0] cbus_data;
inout [63:0] dbus_data;
inout [7:0] ebus_data;

output load_dv;			// valid load data on copy_load bus
output rdramreq;
output rdramrw;
output read_request;		//output of cbus module to io 

output stopgclock;		//stall output:  used by rws sim env only
output start_gclk;		//new polarity of above for system level
output rel_sync_full;		//to EW, sync done, gclk to stop
output pipe_busy;		//memspan not in rel_sync_full condition

output spanbufrd;				//pop span buffer
			//note:  for simplicity, we might not want to read and
			//write span buffer at same time, add logic to do this?
			//e.g. spanbufmt = spanbufmt.in || spanbufload from EW
			//note also:  spanbuf never overflows (choose size!);

output [7:0] rdprred;				//color to blend unit
output [7:0] rdprgreen;
output [7:0] rdprblue;
output [2:0] rdpralpha;

output [17:0]  rdprdepthd;			//depth to blend unit

output bist_go;
output bist_check;

output start_gclk1;		//buffered output for new gclk distribution scheme
output start_gclk2;		//buffered output for new gclk distribution scheme
output start_gclk3;		//buffered output for new gclk distribution scheme
output start_gclk4;		//buffered output for new gclk distribution scheme
output start_gclk5;		//buffered output for new gclk distribution scheme
output start_gclk6;		//buffered output for new gclk distribution scheme

//wires define

//sm

wire [3:0] smcwincwr, smzwincwr;
wire [6:0] start_gclk_bus;

assign start_gclk  = start_gclk_bus[0];
assign start_gclk1 = start_gclk_bus[1];
assign start_gclk2 = start_gclk_bus[2];
assign start_gclk3 = start_gclk_bus[3];
assign start_gclk4 = start_gclk_bus[4];
assign start_gclk5 = start_gclk_bus[5];
assign start_gclk6 = start_gclk_bus[6];
 
//sc

wire [1:0] cycle_type, color_size, tex_size;
wire [2:0] color_format, tex_format;
wire [6:0] rdramlen;
wire [11:0] nextspanxf, nextspancount, stepcount, pixcount, wrcxf_buf;
wire [19:0] nextspanxi;
wire [25:0] color_base, tex_base, z_base, rdramaddr;
wire [25:0] rdcxi, savezxi, rdzxi, rmwcxi, rmwzxi, wrcxi_buf, wrzxi_buf,
		wrcxi, wrzxi;
wire [3:0] rmwrbcrptr, rdrbzrptr, wrrbcrptr_buf, wrrbzrptr_buf;
wire [31:0] wrfillcolor;
wire [3:0] rbcrptrd, rbzrptrd, rbcwptrd, rbzwptrd;

//si

wire [143:0] din, dout;
wire [3:0] addr0, addr1;
wire [7:0] ebus_data, ebus_dout;
wire [26:0] rdprcolor, rdpwcolor;
wire [17:0] rdprdepthd, rdpwdepth;
wire [31:0] zwmask, fillcolor;
wire [63:0] dbus_data, dbus_dout, cwmask, copy_load, dataload;
wire [6:0] rdpcrptrsb, rdpzrptrsb, rdpcwptrsbc, rdpzwptrsbc, rdpcwptrn, rdpzwptrn;
wire [3:0] rbcrptr, rbzrptr, rbcwptr, rbzwptr;

wire [7:0] rdpwredin, rdpwgreenin, rdpwbluein;
wire [2:0] rdpwalphain;
wire [17:0] rdpwdepthin;

//rp

wire [7:0] copywen, ccalpha, dithalpha, blendalpha;

//rand

wire [2:0] rand_r, rand_g, rand_b;

//iomsdma

wire [CBUS_SELECT_SIZE-1:0] cbus_select;
wire [CBUS_COMMAND_SIZE-1:0] cbus_command;
wire [DRAM_ADDRESS_SIZE-1:0] dma_address;
wire [DMA_LENGTH_SIZE-1:0] dma_length;
wire [CBUS_DATA_SIZE-1:0] reg_read_data, diagdata, diagdout;
wire [CBUS_DATA_SIZE-1:0] reg_write_data, diagdin;
wire [DP_REG_ADDRESS_SIZE-1:0] reg_address, diagaddr;
wire [CBUS_DATA_SIZE-1:0] cbus_data;

//debug

wire [DP_BIST_FAIL_SIZE-1:0] bist_fail;
wire we0d;
wire we1d;
wire [3:0] addr0d;
wire [3:0] addr1d;
wire [143:0] dind;

//module instantiations

ms_sm sm ( .clock(clock), .reset_l(reset_l), .stb_sync_full(stb_sync_full),
	.freeze_gclk(freeze_gclk), .unfreeze_gclk(unfreeze_gclk),
	.rdspace(rdspace), .rdenreadc(rdenreadc), .rdenreadz(rdenreadz),
        .grant(grant), .start(start), .finish(finish),
        .creqw(creqw), .zreqw(zreqw), .cwmzero(cwmzero), .zwmzero(zwmzero),
	.rddone(rddone), .smcwincwr(smcwincwr), .smzwincwr(smzwincwr),
        .stallphase(stallphase), .stallrw(stallrw), .stallrdctxt(stallrdctxt),
	.stallwrctxt(stallwrctxt), .stallptr(stallptr), .stallczwm(stallczwm),
	.stallnxtwm(stallnxtwm), .spanproc(spanproc),

        .steprddone(steprddone),
	.finishd1(finishd1),
	.finishd2(finishd2),
        .rdramreqcr(rdramreqcr), .rdramreqzr(rdramreqzr),
	.rdramreqcw(rdramreqcw), .rdramreqzw(rdramreqzw),
        .enrbwe(enrbwe), .selrbcr(selrbcr), .selrbzr(selrbzr),
        .selrbcw(selrbcw), .selrbzw(selrbzw),
	.selcwmask(selcwmask), .selzwmask(selzwmask),
	.resetcreqw(resetcreqw), .resetzreqw(resetzreqw),
        .steprbcrptr(steprbcrptr), .steprbzrptr(steprbzrptr),
	.steprbcwptr(steprbcwptr), .steprbzwptr(steprbzwptr),
	.rbphase(rbphase), .start_gclk_bus(start_gclk_bus),
	.start4ms(start4ms),
	.stopgclock(stopgclock), .rel_sync_full(rel_sync_full),
	.pipe_busy(pipe_busy), .stopgclockd(stopgclockd) );


ms_sc sc ( .clock(clock), .gclock(gclock), .reset_l(reset_l),
	.stopgclock(stopgclock),
        .cycle_type(cycle_type), .image_read_en(image_read_en),
	.z_update_en(z_update_en), .z_compare_en(z_compare_en),
        .color_base(color_base), .color_size(color_size),
	.z_base(z_base), .tex_base(tex_base),
	.tex_size(tex_size), .load_en(load_en),
        .color_format(color_format), .fillcolor(fillcolor),
	.tex_format(tex_format), .ldtlut_en(load_tlut_en),
        .nextspanxi(nextspanxi), .nextspanxf(nextspanxf),
	.nextspancount(nextspancount), .nextspanxdec(nextspanxdec),
	.spanbufmt(spanbufmt),
        .startspant0(startspant0d), .startspant1(startspant1),
	.startspant7m(startspant7m), .steprddone(steprddone),
        .steprbcrptr(steprbcrptr), .steprbzrptr(steprbzrptr),
	.steprbcwptr(steprbcwptr), .steprbzwptr(steprbzwptr),
        .rdramreqcr(rdramreqcr), .rdramreqzr(rdramreqzr),
	.rdramreqcw(rdramreqcw), .rdramreqzw(rdramreqzw),
	.creqw(creqw), .zreqw(zreqw), .test_mode0(test_mode0),
        .resetcreqw(resetcreqw), .resetzreqw(resetzreqw),
	.startspant12(startspant12), .endspant11(endspant11),
	.fullcwmt11(fullcwmt11), .fullzwmt11(fullzwmt11),
	.startspant8(startspant8), .endspant12(endspant12),
	.endspant14(endspant14), .validt2 (validt2),

        .rdspace(rdspace), .rddone(rddone), .rdenreadc(rdenreadc),
	.rdenreadz(rdenreadz), .rdcxi(rdcxi), .savezxi(savezxi),
	.rdxdec(rdxdec), .rdzxi(rdzxi),
        .rmwenreadc(rmwenreadc), .rmwenreadz(rmwenreadz),
	.wrfillmode(wrfillmode),
	.wrzxi_buf(wrzxi_buf), .wrxdec_buf(wrxdec_buf),
        .rmwenwritec(rmwenwritec), .rmwenwritez(rmwenwritez),
	.wrenwritec_buf(wrenwritec_buf), .wrenwritez_buf(wrenwritez_buf),
	.stallrdctxt(stallrdctxt), .stallrdctxtd(stallrdctxtd),
	.stallwrctxtd(stallwrctxtd),
        .stallwrctxt(stallwrctxt), .rdramreq(rdramreq), .rdramlen(rdramlen),
	.rdramaddr(rdramaddr), .rdramdir(rdramdir), .rdramrw(rdramrw),
        .rdtwophase(rdtwophase), .rmwtwophase(rmwtwophase),
	.rdcopymode(rdcopymode), .rdfillmode(rdfillmode),
	.rdloadmode(rdloadmode), .wrloadmode(wrloadmode),
        .rmwcopymode(rmwcopymode), .rmwfillmode(rmwfillmode),
	.rmwloadmode(rmwloadmode), .pixcount(pixcount),
        .wrcopymode_buf(wrcopymode_buf), .wrfillmode_buf(wrfillmode_buf),
	.rmwrgbmode(rmwrgbmode), .rmwloadtlut(rmwloadtlut),
        .rdperclk8(rdperclk8), .rdperclk4(rdperclk4),
	.rdperclk2(rdperclk2), .rmwperclk8(rmwperclk8),
	.rmwperclk4(rmwperclk4), .rmwperclk2(rmwperclk2),
        .rmwcsize8(rmwcsize8), .rmwcsize16(rmwcsize16),
	.rmwcsize32(rmwcsize32), .wrcsize8_buf(wrcsize8_buf),
	.wrcsize16_buf(wrcsize16_buf), .wrfillcolor(wrfillcolor),
        .wrcsize32_buf(wrcsize32_buf), .wrcxi_buf(wrcxi_buf),
	.wrcxf_buf(wrcxf_buf), .rmwcxi(rmwcxi), .rmwzxi(rmwzxi),
	.rmwxdec(rmwxdec), .spanproc(spanproc), .wrrender_buf(wrrender_buf),
	.smcwincwr(smcwincwr), .smzwincwr(smzwincwr),
	.rmwrbcrptr(rmwrbcrptr), .rdrbzrptr(rdrbzrptr),
	.wrrbcrptr_buf(wrrbcrptr_buf), .wrrbzrptr_buf(wrrbzrptr_buf),
        .stepcount(stepcount), .rbzrptr(rbzrptr),
	.rbcrptr(rbcrptr), .rbzwptr(rbzwptr), .rbcwptr(rbcwptr),
  	.rbcrptrd(rbcrptrd), .rbzwptrd(rbzwptrd),
	.rbcwptrd(rbcwptrd), .rbzrptrd(rbzrptrd),
	.wrcxi(wrcxi), .wrzxi(wrzxi), .wrxdec(wrxdec), .stallnxtwm(stallnxtwm),
	.wrloadmode_buf(wrloadmode_buf), .wrenreadz_buf(wrenreadz_buf),
        .spanbufrd(spanbufrd), .wrcopymode(wrcopymode) );

ms_si si ( .clock(clock), .gclock(gclock), .reset_l(reset_l),
	.rbphase(rbphase), .finishd1(finishd1), .finishd2(finishd2), 
	.start(start), .rdpwcolor(rdpwcolor), .rmwenreadz(rmwenreadz),
	.rdpwdepth(rdpwdepth), .stopgclock(stopgclock),
	.dbus_din(dbus_data), .dma_read_en(dma_read_enable),
	.ebus_din(ebus_data), .wrcopymode_buf(wrcopymode_buf),
        .dout(dout), .selrbcr(selrbcr), .selrbzr(selrbzr),
	.selrbcw(selrbcw), .selrbzw(selrbzw),
        .rmwrgbmode(rmwrgbmode), .wrcopymode(wrcopymode),
        .rdpreqcr(rdpreqcr), .rdpreqzr(rdpreqzr), .rdpreqcw(rdpreqcw),
	.rdpreqzw(rdpreqzw), .enrbwe(enrbwe),
	.selcwmask(selcwmask), .selzwmask(selzwmask),
        .wrfillcolor(wrfillcolor), .rbcrptr(rbcrptr),
	.rbzrptr(rbzrptr), .rbcwptr(rbcwptr),
	.rbzwptr(rbzwptr), .rdcxi(rdcxi), .rdzxi(rdzxi), .rdxdec(rdxdec),
        .wrcxi(wrcxi), .wrzxi(wrzxi), .wrxdec(wrxdec),
	.rmwcsize8(rmwcsize8), .rmwcsize16(rmwcsize16),
	.rmwcsize32(rmwcsize32), .rmwenreadc(rmwenreadc),
        .wrfillmode(wrfillmode), .cwmask(cwmask),
        .zwmask(zwmask), .rdpcrptrsb(rdpcrptrsb), .rdpzrptrsb(rdpzrptrsb),
	.rdpcwptrsbc(rdpcwptrsbc), .rdpzwptrsbc(rdpzwptrsbc),
	.rdprpixc(rdprpixc), .rdprpixz(rdprpixz),
        .rdpwpixc(rdpwpixc), .rdpwpixz(rdpwpixz),
	.rmwcopymode(rmwcopymode), .rmwloadtlut(rmwloadtlut),
	.load_dve(load_dve), .blendalpha(blendalpha), .alphacompen(alphacompen),
	.wrcsize8_buf(wrcsize8_buf), .wrcsize16_buf(wrcsize16_buf),
	.rdpcwptrn(rdpcwptrn), .dithalpha(dithalpha),
	.rdpzwptrn(rdpzwptrn), .dithalphaen(dithalphaen),
	.stallptr(stallptr), .test_mode1(test_mode1),
	.start4ms(start4ms), .limitcw(limitcw),  .limitzw(limitzw), 

        .dbus_dout(dbus_dout), .ebus_dout(ebus_dout), .din(din),
        .rdprcolor({rdprred, rdprgreen, rdprblue, rdpralpha}),
	.rdprdepthd(rdprdepthd), .copywen(copywen),
	.addr0(addr0), .addr1(addr1),
	.we0(we0), .we1(we1), .copy_load(copy_load), .dataload(dataload),
        .stallphase(stallphase), .stallrw(stallrw) );


ms_rp rp ( .clock(clock), .gclock(gclock), .reset_l(reset_l),
	.startspan(startspant0), .pixcount(pixcount),
	.stepcount(stepcount), .stopgclock(stopgclock),
        .rdloadmode(rdloadmode), .rdfillmode(rdfillmode),
	.rdcopymode(rdcopymode), .rmwxdec(rmwxdec),
        .rdtwophase(rdtwophase), .rmwtwophase(rmwtwophase),
	.rmwloadmode(rmwloadmode), .rmwcopymode(rmwcopymode),
	.rmwfillmode(rmwfillmode), .copywen(copywen),
        .rmwloadtlut(rmwloadtlut), .rdperclk8(rdperclk8),
	.rdperclk4(rdperclk4), .rdperclk2(rdperclk2),
        .rmwperclk8(rmwperclk8), .rmwperclk4(rmwperclk4),
	.rmwperclk2(rmwperclk2), .rmwcxi(rmwcxi), .rmwzxi(rmwzxi),
        .wrcxi_buf(wrcxi_buf), .wrcxf_buf(wrcxf_buf),
	.wrzxi_buf(wrzxi_buf), .wrxdec_buf(wrxdec_buf),
        .rbzrptr(rbzrptr), .rbcrptr(rbcrptr), .rbzwptr(rbzwptr),
	.rbcwptr(rbcwptr), .rmwenreadz(rmwenreadz), .rmwenreadc(rmwenreadc),
        .rmwenwritec(rmwenwritec), .rmwenwritez(rmwenwritez),
	.rmwcsize16(rmwcsize16), .rmwcsize32(rmwcsize32),
        .rdpwdepthin(rdpwdepthin), .wrloadmode(wrloadmode),
	.rdpwcolorin({rdpwredin, rdpwgreenin, rdpwbluein, rdpwalphain}),
	.rdpcolorwen(rdpcolorwen), .alphacompen(alphacompen),
	.dithalphaen(dithalphaen),
        .blendalpha(blendalpha), .dithalpha(dithalpha),
	.ccalpha(ccalpha), .rand_r(rand_r), .rand_g(rand_g), .rand_b(rand_b),
        .rdcxi(rdcxi), .savezxi(savezxi), .wrrender_buf(wrrender_buf),
        .resetcreqw(resetcreqw), .resetzreqw(resetzreqw),
	.wrenwritez_buf(wrenwritez_buf), .wrenwritec_buf(wrenwritec_buf),
        .wrcsize8_buf(wrcsize8_buf), .wrcsize16_buf(wrcsize16_buf),
	.wrcsize32_buf(wrcsize32_buf), .rdxdec(rdxdec),
        .wrfillmode_buf(wrfillmode_buf), .wrcopymode_buf(wrcopymode_buf),
        .rmwrbcrptr(rmwrbcrptr), .rdrbzrptr(rdrbzrptr),
        .wrrbcrptr_buf(wrrbcrptr_buf), .wrrbzrptr_buf(wrrbzrptr_buf),
	.wrloadmode_buf(wrloadmode_buf), .wrenreadz_buf(wrenreadz_buf),
	.test_mode1(test_mode1),

        .startspant1(startspant1), .startspant7m(startspant7m),
        .stallptr(stallptr), .stallczwm(stallczwm), .load_dv(load_dv),
	.startspant12(startspant12), .endspant11(endspant11),
	.fullcwmt11(fullcwmt11), .fullzwmt11(fullzwmt11),
        .creqw(creqw), .zreqw(zreqw), .cwmask(cwmask), .zwmask(zwmask),
	.cwmzero(cwmzero), .zwmzero(zwmzero), .stallczwmd(stallczwmd),
	.startspant8(startspant8), .startspant0(startspant0d),
        .rdprpixz(rdprpixz), .rdprpixc(rdprpixc), .rdpwpixz(rdpwpixz),
	.rdpwpixc(rdpwpixc), .rdpreqzr(rdpreqzr), .rdpreqcr(rdpreqcr),
        .rdpreqzw(rdpreqzw), .rdpreqcw(rdpreqcw), .rdpzrptrsb(rdpzrptrsb),
	.rdpcrptrsb(rdpcrptrsb), .rdpzwptrsbc(rdpzwptrsbc),
	.rdpcwptrsbc(rdpcwptrsbc), .endspant12(endspant12),
	.endspant14(endspant14), .load_dve(load_dve),
 	.stallcrd(stallcrd), .stallzrd(stallzrd),
   	.stallcwd(stallcwd), .stallzwd(stallzwd),
        .rdpcwptrn(rdpcwptrn), .validt2 (validt2),
        .rdpzwptrn(rdpzwptrn),
	.limitcw(limitcw),  .limitzw(limitzw),
        .rdpwdepth(rdpwdepth), .rdpwcolor(rdpwcolor) );

ms_rand rand ( .clk(clock), .reset_l(reset_l),
	.dither_sel(dither_sel), .rgb_dither(rgb_dither), .noise(noise),
	.rand_r(rand_r), .rand_g(rand_g), .rand_b(rand_b),
	.alpha_dither(dithalpha) );

spanbuf sb0 ( .wen(we0d), .clk(clock), .a(addr0d), .di(dind[143:72]),
						 .dout(dout[143:72]) );

spanbuf sb1 ( .wen(we1d), .clk(clock), .a(addr1d), .di(dind[71:0]),
						 .dout(dout[71:0]) );

ms_dma iomsdma ( .clock(clock), .reset_l(reset_l),
	.cbus_read_enable(cbus_read_enable),
	.cbus_write_enable(cbus_write_enable),
	.cbus_select(cbus_select), .cbus_command(cbus_command),
	.read_grant(read_grant),
	.dma_read(rdramrw), .dma_down(rdramdir), .dma_address(rdramaddr[23:0]),
	.dma_length(rdramlen), .reg_read_data(diagdout),
	.read_request(read_request),
	.reg_write_data(diagdin), .reg_address(diagaddr),
	.reg_write_enable(diagwr), .cbus_data(cbus_data) );

ms_debug iomsdebug (.clock(clock), .reset_l(reset_l),
   .reg_write_enable(diagwr), .reg_address(diagaddr),
   .reg_write_data(diagdin), .bist_done(bist_done),
   .rbcrptrd(rbcrptrd), .rbcwptrd(rbcwptrd), .rel_sync_full(rel_sync_full),
   .rbzrptrd(rbzrptrd), .rbzwptrd(rbzwptrd), .stopgclockd(stopgclockd),
   .stallrdctxtd(stallrdctxtd), .stallwrctxtd(stallwrctxtd),
   .stallczwmd(stallczwmd), .stallcrd(stallcrd), .stallzrd(stallzrd),
   .stallcwd(stallcwd), .stallzwd(stallzwd), .stb_sync_full(stb_sync_full),
   .bist_fail(bist_fail),
   .we0(we0), .we1(we1), .addr0(addr0), .addr1(addr1), .din(din), .dout(dout),
   .reg_read_data(diagdout), .test_mode0(test_mode0), .test_mode1(test_mode1),
   .bist_go(bist_go), .bist_check(bist_check),
   .we0d(we0d), .we1d(we1d), .addr0d(addr0d), .addr1d(addr1d), .dind(dind));

dbus_driver drvd ( .dbus_data_out(dbus_dout), .dbus_enable(dma_write_enable),
		.dbus_data(dbus_data) );

ebus_driver drve ( .ebus_data_out(ebus_dout), .ebus_enable(dma_write_enable),
                .ebus_data(ebus_data) );

tmem_driver drvt ( .tmem_data_out(dataload), .tmem_enable(load_dv),
                .tmem_data(copy_load) );

endmodule