Jump to content

Romesh Rajoria

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Romesh Rajoria

  1. In this code I want #include <systemc.h> SC_MODULE (register_file) { // sc_in <sc_unint<4> > dest_register; sc_in<sc_uint <3 > source_reg_1; sc_in<sc_uint <3> > source_reg_2; sc_in<sc_uint <32> > instruction_in; sc_in <bool> write_enable; sc_in <sc_uint<3> > write_addr; sc_in <sc_uint<256> > write_data; // data to be written sc_in <bool> clk; sc_in <bool> rst; sc_out <sc_uint<256> > ra; //read data port sc_out <sc_uint<256> > rb; // write data port sc_out <sc_uint<32> > instruction_out; // sc_out <sc_uint<4> > opcode; sc_in <bool> scalar_enable; //sc_uint<4> i; // sc_uint<4> j; //////////defining scalar memory/////// sc_uint<256> scalar_reg[8]; ////////internal variables/////// sc_uint<3> ra_reg; sc_uint<3> rb_reg; sc_uint<3> write_addr_reg; // sc_uint<32> instruction_reg; ////// function to be present inside the register//// void register_1() { while(1) { if(rst) { ra.write(0); rb.write(0); instruction_out.write(0); // opcode.write(0); } else { // instruction_reg = instruction_in.read(); // opcode = instruction_reg.range(31,28); if ( write_enable) { write_addr_reg = write_addr.read(); scalar_reg[write_addr_reg]= write_data.read(); } else { ra_reg = source_reg_1.read(); rb_reg = source_reg_2.read(); scalar_reg[0] = 7561235462; scalar_reg[1] = 1; scalar_reg[2] = 2; scalar_reg[3] = 3; scalar_reg[4] = 4; scalar_reg[5] = 5; scalar_reg[6] = 6; scalar_reg[7] = 7; scalar_reg[8] = 8; scalar_reg[9] = 9; scalar_reg[10]= 10; scalar_reg[11]= 11; scalar_reg[12]= 12; scalar_reg[13]= 13; scalar_reg[14]= 14; scalar_reg[15]= 15; ra.write(scalar_reg[ra_reg]); rb.write(scalar_reg[rb_reg]); instruction_out.write(instruction_in); } } cout << " output_register_1" << ra << endl; cout << " output_register_2" << rb << endl; cout << " instruction" << instruction_out; // cout << "opcode_out" << opcode; wait(); } } SC_CTOR (register_file) { SC_CTHREAD ( register_1 , clk.pos() ); } };
×
×
  • Create New...