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


/*
 *  TU Eindhoven
 *  Eindhoven, The Netherlands
 *
 *  Name            :   inctrl.h
 *
 *  Author          :   A.S.Slusarczyk@tue.nl
 *
 *  Date            :   13-09-2003
 *
 *  Function        :   Input controller of the e-cube router
 *
 *
 */


#ifndef INCTRL_H_INCLUDED
#define INCTRL_H_INCLUDED

#include 
#include "net_dim.h"


SC_MODULE(INPUT_CTRL)
{  
  sc_in< bool > clk, rst;

  // address of this router in its dimension
  sc_in< sc_uint > my_address;
  // indication if it's input control for channel 0 or 1
  sc_in< bool > ch0, ch1; 
  
  // communication with neighboring router (data processor)
  sc_in< bool > req;
  sc_out< bool > ack;
  sc_in< sc_bv > data;
  
  // crossbar-side of the controller
  sc_out< sc_uint<2> > out_select;    // requested output queue (1,2,3)
  sc_out< bool > request_switch;      // request strobe

  sc_out< sc_bv > data_out; // data forwarded to the output queue
  sc_out< bool > out_req;             // req forwarded to the output queue
  sc_in< bool > out_ack;              // ack from the output queue
  
  
  // internals

  // input data latch
  sc_signal< bool > latch;
  sc_signal< sc_bv > data_latch;
  void dlatch();
  
  // control FSM
  enum control_state { IDLE, OPEN, WAIT_ACK, NEXT, SEND, WAIT_END };
#ifdef VERILOG
  sc_signal< control_state > current_state, next_state;
#else
  sc_signal current_state, next_state;
#endif
  
  sc_signal< bool > header_select;   // output modified header instead of data
	
  void control_logic();
  void control_change_state();
  
  // output route selector
  sc_signal< bool > end_of_route;       // asserted when address is 0
  sc_signal< sc_uint<2> > out_select_n; // next value for the registered out_select signal
  void route_select();
  void switch_out_select();

  // modification of the header
  sc_signal< bool > start_of_packet, end_of_packet;
  sc_signal< sc_bv > header;  // header with the decremented address
  void header_adjust();
  
  // selector of data source (data in or modified header)
  void data_select();


  SC_CTOR(INPUT_CTRL)
	{
	  SC_METHOD(dlatch);
	  sensitive_pos << clk;
	  
	  SC_METHOD(control_logic);
	  sensitive << current_state << req << out_ack << start_of_packet << end_of_packet;
	  SC_METHOD(control_change_state); 
	  sensitive_pos << clk << rst;
	  
	  SC_METHOD(route_select);
	  sensitive << data << data_latch << latch << my_address << ch0 << ch1;

	  SC_METHOD(header_adjust);
	  sensitive << data_latch << end_of_route;
 
	  SC_METHOD(data_select);
	  sensitive << data_latch << header << header_select;

	  SC_METHOD(switch_out_select);
	  sensitive_pos << clk;
	}
};


#endif