Romesh Rajoria Posted April 28, 2020 Report Share Posted April 28, 2020 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() ); } }; Quote Link to comment Share on other sites More sharing options...
David Black Posted April 28, 2020 Report Share Posted April 28, 2020 This is easy. First, sc_int<N> and sc_uint<N> are limited to 64 bits. So you cannot use 256 there; however, you can use sc_bigint<N> and sc_biguint<N> for any value of N>64. Second, you will need to specify constants as strings since C++ itself does not support >64 native numbers; although, you can use C++ user-defined literals to get around this limitation if using C++ 2011 or better. maehne 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.