Trung tâm đào tạo thiết kế vi mạch Semicon


  • ĐĂNG KÝ TÀI KHOẢN ĐỂ TRUY CẬP NHIỀU TÀI LIỆU HƠN!
  • Đăng ký
    *
    *
    *
    *
    *
    Fields marked with an asterisk (*) are required.
wafer.jpg

Process In SystemC Part III

Email In PDF.

Clocked Threads
SC_CTHREAD process is different from the SC_THREAD process in a number of ways. First the SC_CTHREAD process specifies a clock object.

 When other process types are described in a module constructor they only have the name of the process specified, but the SC_CTHREAD process has the name of the process and the clock that triggers the process. An SC_CTHREAD does not have a separate sensitivity list like the other process types. The sensitivity list is just the specified clock edge. The SC_CTHREAD process will be activated whenever the specified clock edge occurs. In this example the positive edge of the clock is specified so process incr_count will execute on every positive edge of the clock.

Note :SC_CTHREAD can have only one bit wide ports as trigger.
Example Clocked Threads

  1 //-----------------------------------------------------
  2 // This is my second Systemc Example
  3 // Design Name : first_counter
  4 // File Name : first_counter.cpp
  5 // Function : This is a 4 bit up-counter with
  6 // Synchronous active high reset and
  7 // with active high enable signal
  8 //-----------------------------------------------------
  9 #include "systemc.h"
 10 
 11 SC_MODULE (first_counter) {
 12   sc_in_clk     clock ;      // Clock input of the design
 13   sc_in<bool>   reset ;      // active high, synchronous Reset input
 14   sc_in<bool>   enable;      // Active high enable signal for counter
 15   sc_out<sc_uint<4> > counter_out; // 4 bit vector output of the counter
 16 
 17   //------------Local Variables Here---------------------
 18   sc_uint<4> count;
 19 
 20   //------------Code Starts Here-------------------------
 21   // Below function implements actual counter logic
 22   void incr_count () {
 23     // For threads, we need to have while true loop
 24     while (true) { 
 25       // Wait for the event in sensitivity list to occure
 26       // In this example - positive edge of clock
 27       wait();
 28       if (reset.read() == 1) {
 29         count =  0;
 30         counter_out.write(count);
 31       // If enable is active, then we increment the counter
 32       } else if (enable.read() == 1) {
 33         count = count + 1;
 34         counter_out.write(count);
 35       }
 36     }
 37   } // End of function incr_count
 38 
 39   // Below functions prints value of count when ever it changes
 40   void print_count () {
 41     while (true) {
 42       wait();
 43       cout<<"@" << sc_time_stamp() <<
 44         " :: Counter Value "<endl;
 45     }
 46   }
 47 
 48   // Constructor for the counter
 49   // Since this counter is a positive edge trigged one,
 50   // We trigger the below block with respect to positive
 51   // edge of the clock
 52   SC_CTOR(first_counter) {
 53     // cthreads require to have thread name and triggering 
 54     // event to passed as clock object
 55     SC_CTHREAD(incr_count, clock.pos());
 56     // Level Sensitive to change in counter output
 57     SC_THREAD(print_count);
 58       sensitive << counter_out;
 59   } // End of Constructor
 60 
 61 }; // End of Module counter

  Bạn Có Đam Mê Với Vi Mạch hay Nhúng      -     Bạn Muốn Trau Dồi Thêm Kĩ Năng

Mong Muốn Có Thêm Cơ Hội Trong Công Việc

Và Trở Thành Một Người Có Giá Trị Hơn

Bạn Chưa Biết Phương Thức Nào Nhanh Chóng Để Đạt Được Chúng

Hãy Để Chúng Tôi Hỗ Trợ Cho Bạn. SEMICON  

Lần cập nhật cuối ( Thứ ba, 29 Tháng 3 2022 00:41 )  
Chat Zalo