Chris Johnson
Chris Johnson

Reputation: 1

Same TCMs with different sampling event

I wrote TCM for some calculation on AXI interfaces. TCM body is completely same for each interface but sampling event is different.

Is it possible to create one TCM and run it multiple times with different sampling events (clocks)?

Upvotes: 0

Views: 60

Answers (1)

Nils
Nils

Reputation: 129

Every TCM you start, creates its own thread. You can run with different sampling events by changing the sampling event on an instance basis. E.g. you have 2 instances of a monitor with a TCM running on sampling event @sample. you can modify the event using aspect orientation (here using the name aspect).

<'
type m_name : [mon1, mon2];
unit mon {
  name : m_name;  // using this aspect to distinguish instances
  event sample;
  tcm()@sample is {
    while (TRUE) {
      message(LOW, "TCM running in " , me);
      wait;
    };
  };
  run() is also {
    start tcm();
  };
};

extend sys {
  // create an event running at half sys.any speed
  !flag: bool;
  on sys.any { flag = not flag;}; 
  event clk is true(flag)@sys.any;

  // 2 mon instances with different names
  m1 : mon is instance;
    keep m1.name == mon1;
  m2 : mon is instance;
    keep m2.name == mon2;
};

// change sampling events per instance
extend mon1'name mon {
  event sample is only @sys.any;
};
extend mon2'name mon {
  event sample is only @get_enclosing_unit(sys).clk;
};
'>

Upvotes: 1

Related Questions