www.pudn.com > noc.rar > switch.h


/*
 *  TU Eindhoven
 *  Eindhoven, The Netherlands
 *
 *  Name            :   switch.h
 *
 *  Author          :   A.S.Slusarczyk@tue.nl
 *
 *  Date            :   13-09-2003
 *
 *  Function        :   Crossbar switch with e-cube router
 * Based on requested address forwards data_in_x, req_in_x and
 * ack_in_x from input to output. 
 * Note that while data and req travel from "left" to "right", ack goes from 
 * right to left
 * arbitration - if two inputs request the same output, the one with
 * smaller number wins
 *
 */


#ifndef SWITCH_H_INCLUDED
#define SWITCH_H_INCLUDED

#include 
#include "net_dim.h"


SC_MODULE(CROSSBAR3x3)
{
  sc_in clk;
  
  sc_in< sc_uint<2> > addr_0, addr_1, addr_2;
  sc_in< bool > conn_0, conn_1, conn_2;

  sc_in< sc_bv > data_in_0, data_in_1, data_in_2;
  sc_in< bool > req_in_0, req_in_1, req_in_2;
  sc_in< bool > ack_in_0, ack_in_1, ack_in_2;

  sc_out< sc_bv > data_out_0, data_out_1, data_out_2;
  sc_out< bool > req_out_0, req_out_1, req_out_2;
  sc_out< bool > ack_out_0, ack_out_1, ack_out_2;

  // grantX - which input has output X
  // 0-none, 1,2,3 - x0, x1, d
  sc_signal< sc_uint<2> > grant0, grant1, grant2;

  // round-robin arbitration - the requester with the number equal 
  // to round_robin has priority
  sc_signal< sc_uint<2> > round_robin;
  // increase round_robin
  sc_signal< bool > rr_inc;
  
  void crossbar_process();
  void arbiter_process();
  void round_robin_process();
  
  SC_CTOR(CROSSBAR3x3){
	// simple multiplexing based on current grants
	SC_METHOD(crossbar_process);
	sensitive << data_in_0 << data_in_1 << data_in_2
			  << req_in_0 << req_in_1 << req_in_2
			  << ack_in_0 << ack_in_1 << ack_in_2 
			  << grant0 << grant1 << grant2;
	
	// arbitration
	SC_METHOD(arbiter_process);
	sensitive_pos << clk;
	
	// round-robin counter
	SC_METHOD(round_robin_process);
	sensitive_pos << clk;
  }

};

#endif