Quantcast
Channel: SystemC Language Forum RSS Feed
Viewing all articles
Browse latest Browse all 595

simulink block to systemC

$
0
0

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.

 

Attached Thumbnails

  • Untitled.jpg

Viewing all articles
Browse latest Browse all 595

Latest Images

Trending Articles



Latest Images