Professional Documents
Culture Documents
Search
SystemC Tutorial
SystemC Introduction
SystemC Hello World
SystemC Jump Statements SystemC Data Types
SystemC Operators
Jump Statements: SystemC Statement and Flow Control
SystemC Jump Statements
break SystemC Functions
Execution of break statement leads to end of the loop.
SystemC Functions argument passing
SystemC Modules
Example1: break
#include "systemc.h" Contact / Report an issue
int sc_main (int argc, char* argv[]) {
Your valuable inputs are
required to improve the quality.
//break‐example
for(int i=0;i<8;i++) {
cout <<" Value of i="<<i<<endl;
Follow Us
if(i == 4) {
cout <<" Calling break"<<endl;
break;
}
}
// Terminate simulation
return 0;
}
Simulator Output:
j=0 i=4
j=1 i=3
j=2 i=2
j=3 i=1
Execute the above code on
continue
Execution of continue statement leads to skip the execution of statements followed by continue and jump
to next loop or iteration value.
Example1: continue
#include "systemc.h"
int sc_main (int argc, char* argv[]) {
//continue‐example
for(int i=0;i<5;i++) {
cout <<"Before continue, value of i="<<i<<endl;
if((i > 1) && (i < 4)) {
cout <<" Calling continue"<<endl;
continue;
}
cout <<"After continue, value of i="<<i<<endl;
}
// Terminate simulation
return 0;
}
Simulator Output:
goto
Execution of goto leads to jump to another point in the program.
Example1: goto
#include "systemc.h"
#include <iostream>
using namespace std;
int sc_main (int argc, char* argv[]) {
//declaration and initialization
int a = 15;
int b = 10;
my_lable:
cout <<" @ my_label "<<endl;
if( a > b ) {
cout <<" a is greater than b a = "<<a<<" b = "<<b<<endl;
a‐‐;
goto my_lable;
}
else
cout <<" b is greater than a "<<endl;
// Terminate simulation
return 0;
}
Simulator Output:
@ my_label
a is greater than b a = 15 b = 10
@ my_label
a is greater than b a = 14 b = 10
@ my_label
a is greater than b a = 13 b = 10
@ my_label
a is greater than b a = 12 b = 10
@ my_label
a is greater than b a = 11 b = 10
@ my_label
b is greater than a
Execute the above code on
© Copyright 2016 Verification Guide. All rights reserved.