cvxcnt.v 2 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: cvxcnt.v,v 1.1 2002/03/28 00:26:13 berndt Exp $

   /////////////////////////////////////////////////////////////////////////
   //
   // Project Reality
   //
   // module:      cvxcnt
   // description: counter to generate x values for each span
   // 	       	   
   //
   // designer:    Mike M. Cai	 8/24/94
   //
   /////////////////////////////////////////////////////////////////////////

module cvxcnt( // outputs
      	       x_cur,
	       // inputs
	       ew_cv_start_x,
	       ncyc, 	   // ncyc = cycle_type[0]
      	       new_span, left,
	       reset_l, gclk);
output [11:0]  x_cur;
input [11:0]   ew_cv_start_x;
input 	       ncyc, new_span, left;
input 	       reset_l, gclk;

reg   	       comp_new;
reg [11:0]     add_value;
reg [11:0]     x_cur;

always @(posedge gclk or negedge reset_l)
   if ( reset_l == 1'h0)
      begin
      	 x_cur <= 12'h0;
	 comp_new <= 1'h0;
      end
   else
      begin
      	 comp_new <= new_span ? ~ncyc : (ncyc ? ~comp_new : comp_new);
      	 if ( left )
	    add_value = {11'h0, comp_new};
	 else
      	    add_value = 12'hfff & {12{comp_new}};
       	 x_cur <= new_span ? ew_cv_start_x : (x_cur + add_value);
      end

endmodule  //  cvxcnt