Jump to content

srahulkumar1989

Members
  • Content count

    12
  • Joined

  • Last visited

  1. Bit slicing in systemc

    Thanks Mr. Alan for the response. i have tried to know about range method by a simple code . variable.range(4,0) will reprensent the bottom 5 bits and discard the remaining 3 bits of a 8 bit input. variable.range(7,5) will discard the bottom 5 bits and represent the remaining 3 bits of a 8 bit input. please correct me if i am wrong.
  2. Bit slicing in systemc

    Hello all, I have just started the practical implementations in systemC. Here i am trying to implement a paradigm of Bit slicing in systemC. Like: My input is a 8 bit unsignedint type which should be sliced and the output to be a 2 bit unsignedint type. Here i am trying to slice the bits with some conditions - bottom bit of slice - offset by 0 - Relative to LSB Overall - slicing from bit 0 to bit 5 of a 8 bit input. #include "systemc.h" SC_MODULE(slice){ sc_in<sc_uint< 8,8> > input; sc_out<sc_uint< 2,2> > output; void do_slice(){ // slice the inputs and write at the output port } SC_CTOR(slice) { SC_METHOD(do_slice); sensitive<< input; } }; Is there any methods availabe for slicing or Extracting bits in systemC? if yes, how to choose the exact particular bits need to be sliced It will be grateful if any help is provided to proceed with the solution. Thanks in advance
  3. sc_ufixed symbols could not resolved.

    Thanks for the response Philipp. I tried to figure out what was the problem in my code. I used a source file (.cpp file) to instantiate the rand module and its connections . So, when i defined SC_INCLUDE_FX in the main file also, the error was solved. So i understood that we need to define the macros related to fixed point types in the related cpp files also
  4. sc_ufixed symbols could not resolved.

    Hi all, I am working with sc_fixed point types in systemc and i tried a small code with the usage of fixedpoint types. #define SC_INCLUDE_FX #include "systemc.h" #include <stdlib.h> //for srand() and rand() SC_MODULE(rand){ sc_out<sc_ufixed<8,8,SC_TRN,SC_SAT> > output; sc_ufixed<8,8,SC_TRN,SC_SAT> A; void process(){ while(true) { wait(19, SC_NS); A=rand() % 254 ; // range 0 to 253 output.write(A); } } SC_CTOR(rand) { SC_THREAD(process); } }; The above code is just a source module which provides the rand numbers in the fixed point format to the next module. But when i compile i am getting the syntax error as "sc_ufixed symbols could not be resolved" Even i defined locally the SC_INCLUDE_FX macro to work with the fixed point types. But i cant figure out what is the syntax problems while working with fixed point types. when i work the same with the integers, it works fine. Note: i am working in ubuntu 12.04 OS in eclipse C++ software. please help me to proceed with a solution
  5. A module with a delayed output

    Dear Mr. Ralph, Yes its clear now we should use a intermediate signal if we want to delay each of the value by 9ns and use a second process, or can just start the process 9ns later with wait(9, SC_NS). and thanks for warning me about delta cycle semantics of a signal in systemc in connection with simulink simulation semantics, I have to take a look about the infrastructure and continue with the translation. Thanks for your interaction.
  6. A module with a delayed output

    Dear Mr. Ralph, Thank you for the reply and interaction. my simulink random generator block sample period is 9 ns and the output of this block is given to a delay block with latency 1 sample period(9ns) and then it is given to the next functional block. So i want to write a RNG systemC module which produces new value every 9ns and write the outputs at the outport after a delay of 1 sample period (9ns). As you have mentioned : is that mean i just start the process with wait(9, SC_NS) ? could you please explain this point little more detailed. Thank you
  7. A module with a delayed output

    Hi all, i am trying to translate a simulink model to system c module. The simulink block is a source block where it generates random number in the range of [ 0 , 253 ] and with a explicit sample period( the block produces outputs and if appropriate, updates its internal state) of 9 ns, and the output of this block is given to the next block with a latency of 1 sample period. i tried to translate this block to a system c module as shown below: #include "systemc.h" #include <stdlib.h> //for srand(uint) and rand() SC_MODULE(RNG){ sc_in_clk clk; sc_out< sc_uint > output; sc_uint A; void process(){ // while(true) { wait(9, SC_NS); // Timed sampling, based on simulink block sample time A=rand() % 254 ; // do the process wait(9, SC_NS); // delaying the output for 1 latency ie. 1 sample period output.write(A); // then write the output } } SC_CTOR(RNG) { SC_THREAD(process); sensitive<< clk.pos(); } will the above code imitates the simulink model with its specifications as i prescribed? please have a look and let me know how i can proceed for the solution. Thank you.
  8. systemC data type conversions

    Thank you for your reply Torsten. I can understand .to_bool () member function cannot be used with fixed point types and fixed point types must be provided with the read member functions to read the value and also a criterion should be provided for outputting the boolean value (1 or 0) keeping the things on mind i tried to rewrite the code for an example. Please check the code and correct me if i am wrong. #include "systemc.h" #define SC_INCLUDE_FX SC_MODULE( convert) { sc_in<sc_ufixed < 12, 12, SC_TRN, SC_SAT > > count; sc_out<bool > FIFO_we; void function1(){ if ((count>= 1)&&(count<= 50)) // condition for the boolean { FIFO_we =count.read().is_zero(); // read() function and conversion to bool type FIFO_we=1; // assign the boolean value } else { FIFO_we =count.read().is_zero(); FIFO_we = 0; } SC_CTOR(convert) { SC_METHOD(function1); sensitive << count; } // End of Constructor };
  9. systemC data type conversions

    Is my question clearly understandable? if not please let me know!
  10. systemC data type conversions

    Hi all, I am newbie to system c and i am trying to work on system c data type's conversions. I have a inport which a system c ufixed type and i need to change it to a bool type on the outport. i tried the following code. SC_MODULE(convert) { sc_in<sc_ufixed < 1, 1, SC_TRN, SC_SAT > > din; sc_out<bool> dout; bool i; void conversion1() { i = din.to_bool(); dout.write(i); } SC_CTOR(convert) { SC_METHOD(conversion); sensitive<< din; } }; Is the above code correct? do i need to use the process method to convert the inport type to a another datatype on the outport? And Could you please refer me some good reference for system c data type conversions. Thank you very much
  11. simulink block to systemC

    Hello Mr. Ralph, Thank you very much for your reply, as you said i will have to look upon the timing semantics and its related stuff while transferring a simulink to SystemC model, and will go through heirarchial design too. Regarding the design: Do i need connect the outport of module M1 to the inport of the model M2 through a signal S and make the process in M2 sensitive to the inport of Module M2. so that whenever the output changes in M1, the input of M2 changes and the process activates. Am i correct? please let me know whether i have the correct understanding of your explanation? Thank you.
  12. simulink block to systemC

    Hi all, I am new to the system C and just had learnt about theoretical concepts in systemC. Currently i am trying to translate a simulink model to a systemC model and i have some doubts when i am trying to do. Please refer the below attached simulink model, a counter block is present and the output of the counter block is given as input to the successive block. my doubt is how to send the data from this block to next block . As soon as the count value is increased by 1 it should send the data to the next block and the next block works according to the count value. i tried some code designing the counter block and trying to access in the next block. #include "systemc.h" SC_MODULE (counter1) { sc_in<bool> reset ; // active high, synchronous Reset input sc_in<bool> enable; // Active high enable signal for counter sc_out<sc_uint<4> > counter_out; // 4 bit vector output of the counter //------------Local Variables Here--------------------- sc_uint<4> count; //------------Code Starts Here------------------------- // Below function implements actual counter logic void incr_count () { if (reset.read() == 1) { count = 0; counter_out.write(count); // If enable is active, then we increment the counter } else if (enable.read() == 1) { count = count + 1; counter_out.write(count); // writing the current count value at the o/p port. } } // End of function incr_count SC_CTOR(counter1) { cout<<"Executing new"<<endl; SC_METHOD(incr_count); sensitive << reset; } }; Now this count value at the outport is given as the input to the next block. so how do i access this count value in the next block and makes changes according the count value Next block code #include "systemc.h" #include "counter1.h" // including the conter module SC_MODULE (Transfer_control) { sc_in<sc_uint<4> > time_index ; sc_out<bool> fifo_we ; sc_out<bool> fifo_re ; Time_index.read(counter_out.write()) // will this statement read the count value at counter_out port ? but doing this type of code will i have sequential update and access of the count value in the next block? please help me to proceed with it.
×