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.
semicon_lab.jpg

Process In SystemC Part II

Email In PDF.

Threads

Threads are second kind of process, which when called keeps executing or waiting for some event to occur. Conditions that enable this processes can be event triggered, like posedge of clock.

Thread Process can be suspended and reactivated. The Thread Process can contain wait() functions that suspend process execution until an event occurs on one of the signals the process is sensitive to. An event will reactivate the thread process from the statement the process was last suspended. The process will continue to execute until the next wait().
Example 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     // Edge sensitive to clock

 54     SC_THREAD(incr_count);

 55     sensitive << 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