Jump to content

Checking ports for power estimations

Recommended Posts


1- i am facing a problem , many developers on working on power estimation they count the transitions from 0 to 1.

if i am sending a packet of data that is user defined via sc_signal to communicate between two sc_port who also have user defined data types.

how it is possible to see the data transmitted and received in a binary manner.

2- how to know in systemc if a certain line or link switched from high to low and vice versa

thanks a lot.

Share this post

Link to post
Share on other sites

I'm not sure if I get your first question right. Essentially this is a C++ question. But what you could do is a type erase of your (POD) data, use it as a byte array and count the changed bits using XOR (be carefull to you plain data, no classes). Something like:

struct my_data {
  int x;
  long y;

my_data old_val, new_val;

uint8_t* old_data = reinterpret_cast<uint8_t*>(&old_val);
uint8_t* new_data = reinterpret_cast<uint8_t*>(&new_val);

unsigned toggles=0;
for(size_t i=0; i<sizeof(my_data); ++i){
  uint8_t diff = *(old_data+i)^*(new_data+i);
  uint8_t mask=1;
  for(size_t j=0; j<8; ++j, mask<<=1)
    if(mask&diff) ++toggles;

Regarding your second question: you transport the data via a signal which implements the signal_in_if. This interface has a value_changed_event()  getter which returns an event firing when the value of the signal changes. Just wait for this event.

Share this post

Link to post
Share on other sites

thanks a lot sir for your perfect example , but may i know the return value for this event , cause i tried to use it and never succeeded .

i always receive compile error , which means i do have error in the programming syntex.

thanks a lot

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now