Download presentation
Presentation is loading. Please wait.
1
Tutorial 1 COEN691B
2
Coverage Linux SSH through Windows (skip to slide 11) SystemC (basic)
Producer Consumer Demo
3
Linux Basic to Using Command Line
Open the Terminal Applications Accessories Terminal
5
Linux Right now in home directory (folder)
“pwd” to print the working directory
6
Linux Which is equivalent to:
7
Linux “ls” to list the files and folders in the current directory
8
Linux “mkdir directory_name” to create a folder
9
Linux “cd dir_name” to go into dir_name Equivalent to going into
10
Linux “cd ..” goes up one directory Note that you are not allowed to work above your home directory (other people’s directories)
11
SSH through Windows ENCS Computer Labs’ Windows OS is connected to your Linux drive Use SSH Secure Shell Client (or other SSH programs) to connect to Concordia’s Linux Server: Host Name: login.encs.concordia.ca Port Number: 22
12
SSH through Windows Your Linux data is on the U-Drive
13
SSH through Windows
14
SSH through Windows SSH with SSH Secure Shell Client
15
SSH through Windows Click on Quick Connect or the Connect buttons or
16
SSH through Windows Press Enter or Click on Connect Host Name:
login.encs.concordia.ca User Name: your_username Port Number: 22 Press Enter or Click on Connect
17
SSH through Windows
18
SystemC Module #include “systemc.h” SC_MODULE(Module_name){ void thread1(); void thread2(); sc_event event; //constructor SC_CTOR(Module_name){ SC_THREAD(thread1); SC_THREAD(thread2); } } Module_name thread1 thread2 2 Concurrent threads
19
SystemC Module Functions void Module_name::thread1(){ cout << sc_time_stamp() << “ I’m thread1” << endl; } void Module_name::thread2(){ cout << sc_time_stamp() << “ I’m thread2” << endl; }
20
SystemC Main Function sc_main(int argc, char* argv[]){ Module_name mod_var(“mod_instance_name”); //run for 100 simulated seconds sc_start(100, SC_SEC); }
21
SystemC Compile using the following command: g++ -I. -I$(SYSTEMC_HOME)/include -L. -L$(SYSTEMC_HOME)/lib-linux64 -o sim Module_name.cpp -lsystemc –lm ./sim $(SYSTEMC_HOME) on login.encs.concordia.ca is /CMC/tools/systemc
22
SystemC Output: SystemC Sep :22: Copyright (c) by all Contributors ALL RIGHTS RESERVED 0 s I’m thread1 0 s I’m thread2
23
SystemC SystemC Time The sc_start(some_time) run the simulation for some time, but in our example does not logical (simulated) advance time. If we add time to the threads, output of the threads will be different.
24
SystemC Module Functions void Module_name::thread1(){ wait(10, SC_SEC) cout << sc_time_stamp() << “ I’m thread1” << endl; } void Module_name::thread2(){ wait(2, SC_SEC); cout << sc_time_stamp() << “ I’m thread2” << endl; }
25
SystemC Output: SystemC Sep :22: Copyright (c) by all Contributors ALL RIGHTS RESERVED 2 s I’m thread2 10 s I’m thread1
26
SystemC SystemC Time Macros Macro Meaning SC_SEC Seconds SC_MS
Milliseconds SC_US Microseconds SC_NS Nanoseconds SC_PS Picoseconds SC_FS Femtoseconds
27
SystemC sc_event SystemC threads can wait on time or events. Whenever an event is notified, the threads which are waiting on the event wakes up and can continue execution.
28
SystemC Module Functions void Module_name::thread1(){ wait(event); wait(5, SC_SEC); cout << sc_time_stamp() << “ I’m thread1” << endl; } void Module_name::thread2(){ wait(25, SC_SEC); cout << sc_time_stamp() << “ I’m thread2” << endl; event.notify(); }
29
SystemC Output: SystemC Sep :22: Copyright (c) by all Contributors ALL RIGHTS RESERVED 25 s I’m thread2 30 s I’m thread1
30
SystemC sc_fifo: First-in first-out (FIFO) channel The type of values in the FIFO must be defined. sc_fifo <type> fifoVar; The FIFO channel can be used to write and read values in the order they were written X Y A B Z C
31
sc_fifo functions write(data_var): Blocking Write data_var into the FIFO. If the FIFO is full, wait until there is room (when data are read) nb_write(data_var): Non-Blocking Same as write(), but if the FIFO is full, nothing is written and it returns false
32
sc_fifo functions read(data_var) Blocking Read the first value in the FIFO into data_var. If the FIFO is empty, wait until there is data (when data are written) nb_read(data_var): Non-Blocking Same as read(), but if the FIFO is full, no data is read and it returns false
33
sc_fifo functions num_available(): Returns how many data is available in the FIFO to be read num_free(): Returns how much free space is in the FIFO to write.
34
Producer Consumer Demo
A module with two threads One thread is the producer which produces data into a FIFO. The other thread is the consumer which consumes data from the FIFO How can a Makefile be used and how it is used for the assignments
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.