csshuffle.v 2.68 KB
/**************************************************************************
 *                                                                        *
 *               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: csshuffle.v,v 1.1.1.1 2002/05/17 06:07:45 blythe Exp $
   /////////////////////////////////////////////////////////////////////////
   //
   // Project Reality
   //
   // module:      csshuffle
   // description: Converts data from RSP format to RDP format
   //   
   //
   // designer:    Mike M. Cai   7/11/94
   //
   /////////////////////////////////////////////////////////////////////////


module csshuffle( // outputs
      	       	  rm_addr, rl_addr, shf_state, update_shf,
		  // inputs
		  cmd, base_adrs, inc_shf_state, 
		  reset_l, gclk);
output [4:0]   rm_addr, rl_addr;
output	       update_shf;
output [4:0]   shf_state;
input [5:0]   cmd;
input [4:0]   base_adrs;
input 	      inc_shf_state, reset_l, gclk;

reg [4:0]      shf_state, inc, noinc;
wire   	       update_shf;
wire [4:0]      off_addr;
wire [4:0]     off_addr_inv;
wire   	       sel_inv;
wire [4:0]     rm_addr, rl_addr;

`include  "rdpcmd.vh"

assign  update_shf = shf_state == 5'h15;
always @(posedge gclk or negedge reset_l)
   if (reset_l == 1'h0)
      shf_state <= 5'h0;
   else begin
//      update_shf = shf_state == 5'h15;
//      rst = reset_l | update_shf;
//      inc = shf_state + inc_shf_state;
//      inc = shf_state + 1;
//      inc1 = inc_shf_state ? inc : shf_state;
//      shf_state <= update_shf ? 5'h0 : inc1;
      inc = update_shf ? 5'h0 : shf_state + 1;
      noinc = update_shf ? 5'h0 : shf_state;
      shf_state <= inc_shf_state ? inc : noinc;
   end

csshuftbl tbl( .off_addr(off_addr), .sel_inv(sel_inv),
      	       .shf_state(shf_state), .cmd(cmd));

assign  
   off_addr_inv = {off_addr[4:1], off_addr[0] ^ sel_inv};

csadder5b addmsboff(.sum(rm_addr), .a(off_addr), .base_adrs(base_adrs),
      	       	     .shf_state(shf_state));
csadder5b addlsboff(.sum(rl_addr), .a(off_addr_inv), .base_adrs(base_adrs),
      	       	     .shf_state(shf_state));

endmodule  //  csshuffle