Skip to content

Commit db65e18

Browse files
Version 1.4.18 String initialization for SC integer supported
1 parent 34cb0fa commit db65e18

File tree

385 files changed

+1290
-1423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

385 files changed

+1290
-1423
lines changed

doc/extensions.tex

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
\section{Extensions}\label{section:extensions}
2-
3-
\ifdefined\INTEL
4-
\include{extensions_intel}
5-
\fi
61

72
\subsection{Advanced FIFO}\label{section:adv_fifo}
83

@@ -126,13 +121,13 @@ \subsection{SystemVerilog intrinsic insertion}\label{section:black_box}
126121

127122
\subsection{Memory module name}
128123

129-
This section describes how to create own memory module with module name specified.
124+
This section describes how to create a custom memory module with module name specified.
130125

131-
To support vendor memory it needs to specify memory module name at instantiation point and exclude the SV module code generation (memory module is external one). To exclude SV module code generation empty {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_} should be used. To specify memory module name it needs to define {\tt \_\_SC\_TOOL\_MEMORY\_NAME\_\_} variable in the module body and initialize it with required name string.
126+
To support vendor memory it needs to specify memory module name at instantiation point and exclude the SV module code generation (memory module is external one). To exclude SV module code generation empty {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_} should be used. To specify memory module name it needs to define {\tt \_\_SC\_TOOL\_MODULE\_NAME\_\_} variable in the module body and initialize it with required name string.
132127

133128
If there are two instances of the same SystemC module, it is possible to give them different names, but {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_} must be declared in the module. If {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_} is not declared the SystemC module, only one SV module with first given name will be generated .
134129

135-
Module name could be specified for module with non-empty {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_}, but module names in {\tt \_\_SC\_TOOL\_MEMORY\_NAME\_\_} and {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_} should be the same.
130+
Module name could be specified for module with non-empty {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_}, but module names in {\tt \_\_SC\_TOOL\_MODULE\_NAME\_\_} and {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_} should be the same.
136131

137132
If specified module name in module without {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_} declaration conflicts with another module name, it updated with numeric suffix. Specified name in module with {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_} declaration never changed, so name uniqueness should be checked by user.
138133

@@ -142,10 +137,10 @@ \subsection{Memory module name}
142137
// Disable Verilog module generation
143138
std::string __SC_TOOL_VERILOG_MOD__[] = "";
144139
// Specify module name at instantiation
145-
std::string __SC_TOOL_MEMORY_NAME__;
140+
std::string __SC_TOOL_MODULE_NAME__;
146141
explicit memory_stub(const sc_module_name& name,
147142
const char* verilogName = "") :
148-
__SC_TOOL_MEMORY_NAME__(verilogName)
143+
__SC_TOOL_MODULE_NAME__(verilogName)
149144
{}
150145
};
151146

doc/install.tex

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,3 @@ \subsection{Run tool for custom design}
246246
svc_target(mydesign ELAB_TOP tb.dut_inst)
247247
\end{lstlisting}
248248

249-
250-
\subsection{Tool options and defines}\label{section:tool_options}
251-
252-
To run ICSC tool for the custom project it needs to create CMakeList.txt file. SystemVeriog code generation is done with {\tt svc\_target} function. {\tt svc\_target} is CMake function defined in {\tt \$ICSC\_HOME/lib64/cmake/SVC/svc\_target.cmake}.
253-
254-
ICSC has several options, which can be specified as {\tt svc\_target} parameters:
255-
256-
\begin{itemize}
257-
\item {\tt ELAB\_TOP} – design top module name, it needs to be specified if top module is instantiated outside of {\tt sc\_main()} or if there are more than one modules in {\tt sc\_main()};
258-
\item {\tt MODULE\_PREFIX} – module prefix string, no prefix if not specified, prefix applied for every module excluding Verilog intrinsic (module with {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_}) and memory modules (modules with {\tt \_\_SC\_TOOL\_MEMORY\_NAME\_\_});
259-
\item {\tt REPLACE\_CONST\_VALUE} – replace constant with its evaluated value if possible, by default constant variable is used;
260-
\item {\tt INIT\_LOCAL\_VARS} – initialize non-initialized process local variables with zero to avoid latches, that related to CPP data types only, SC data types always initialized with 0;
261-
\item {\tt NO\_SVA\_GENERATE} – do not generate SVA from immediate and temporal SystemC assertions, normally SVA are generated;
262-
\item {\tt NO\_REMOVE\_EXTRA\_CODE} – do not remove unused variable and unused code in generated SV, normally such code is removed to improve readability.
263-
\end{itemize}
264-
265-
ICSC tool provides {\tt \_\_SC\_TOOL\_\_} define for input SystemC project translation. This define used in temporal assertions and other ICSC library modules to have different behavior for simulation and SV generation. {\tt \_\_SC\_TOOL\_\_} can also be used in project code to hide pieces of code which is not targeted for translation to SystemVerilog.
266-
267-
To completely disable SystemC temporal assertion macro {\tt SCT\_ASSERT\_OFF} can be defined. That allows to hide all assertion specific code to meet SystemC synthesizable standard requirements. {\tt SCT\_ASSERT\_OFF} is required if the SystemC design is passed through a tool which includes its own (not patched) SystemC library.
268-
269-

doc/preamble.tex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@
4141
breakatwhitespace=true
4242
}
4343

44+
\lstdefinestyle{mytext}{
45+
frame=tb,
46+
language=text,
47+
aboveskip=3mm,
48+
belowskip=3mm,
49+
showstringspaces=false,
50+
columns=flexible,
51+
basicstyle={\small\ttfamily},
52+
numbers=none,
53+
breaklines=true,
54+
breakatwhitespace=true
55+
}
56+
4457
\lstset{frame=tb,
4558
language=C++,
4659
aboveskip=3mm,

doc/prepare.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,6 @@ \subsection{Naming restrictions}
890890
Suffix {\tt \_next} is used for register variables, so it is not recommended to use such suffix for SystemC variables.
891891

892892
ICSC tool provides {\tt \_\_SC\_TOOL\_\_} define for input SystemC project translation.
893-
Module/interface field {\tt\_\_SC\_TOOL\_MEMORY\_NAME\_\_} is reserved for vendor memory name.
893+
Module/interface field {\tt\_\_SC\_TOOL\_MODULE\_NAME\_\_} is reserved for vendor memory name.
894894
Module/interface field {\tt \_\_SC\_TOOL\_VERILOG\_MOD\_\_} is reserved for disable module generation in SystemVerilog code.
895895

doc/tool_options.tex

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
\subsection{Tool options and defines}\label{section:tool_options}
3+
4+
ICSC has several options, which can be specified as {\tt svc\_target} parameters. These options given in Table~\ref{tab:tool_opts}.
5+
6+
7+
\begin{table}
8+
\begin{tabular}{|l|l|}
9+
\hline
10+
Tool option & Description \\
11+
\hline
12+
{\tt ELAB\_TOP} & Design top module name, it needs to be specified if \\
13+
& top module is instantiated outside of {\tt sc\_main()} \\
14+
& or if there are more than one modules in {\tt sc\_main()} \\
15+
{\tt MODULE\_PREFIX} & Module prefix string, no prefix if not specified, prefix \\
16+
& applied for every module excluding SV intrinsic, \\
17+
& see~\ref{section:black_box} \\
18+
{\tt UNSIGNED} & Unsigned mode for designs with unsigned arithmetic only, \\
19+
& see~\ref{section:unsigned_mode} \\
20+
{\tt INIT\_LOCAL\_VARS} & Initialize non-initialized process local variables \\
21+
& with 0 to avoid latches, that related to CPP data \\
22+
& types only, SC data types always initialized with 0 \\
23+
{\tt INIT\_RESET\_LOCAL\_VARS} & Initialize non-initialized clocked thread local \\
24+
& variables declared in reset section with zero, \\
25+
& that related to CPP data types only, \\
26+
& SC data types always initialized with 0 \\
27+
{\tt PORT\_MAP\_GENERATE} & Generate port map file and top module wrapper with \\
28+
& flatten port arrays, port map file used for SC/SV \\
29+
& mixed language simulation, top module wrapper used for \\
30+
& logic synthesis tools which do not support unpacked \\
31+
& port array in top module interface \\
32+
{\tt NO\_SVA\_GENERATE} & Do not generate SVA from immediate and temporal \\
33+
& SystemC assertions, SVA are generated by default \\
34+
{\tt NO\_REMOVE\_EXTRA\_CODE} & Do not remove unused variable and unused code, \\
35+
& normally such code is removed to improve readability \\
36+
\hline
37+
\end{tabular}
38+
\caption{{\tt svc\_target} parameters}
39+
\label{tab:tool_opts}
40+
\end{table}
41+
42+
ICSC tool provides {\tt \_\_SC\_TOOL\_\_} define for input SystemC project translation. This define used in temporal assertions and other ICSC library modules to have different behavior for simulation and SV generation. {\tt \_\_SC\_TOOL\_\_} can also be used in project code to hide pieces of code which is not targeted for translation to SystemVerilog.
43+
44+
To completely disable SystemC temporal assertion macro {\tt SCT\_ASSERT\_OFF} can be defined. That allows to hide all assertion specific code to meet SystemC synthesizable standard requirements. {\tt SCT\_ASSERT\_OFF} is required if the SystemC design is passed through a tool which includes its own (not patched) SystemC library.
45+
46+
\subsubsection{Unsigned mode}\label{section:unsigned_mode}
47+
48+
Unsigned mode is intended for designs with unsigned arithmetic only. That means all variables and constants types are unsigned, all expressions are evaluated as non-negative.
49+
50+
In this mode variables and constants types as well as expressions types are checked to be unsigned. C99 types {\tt uint8\_t} and {\tt uint16\_t} (declared in {\tt <cstdint>}) are not recommended to use in this mode as they leads to false warnings.
51+
52+
Literals could be signed and unsigned (with suffix {\tt U}) in all operations except shifts. In shift expressions both arguments, including literals, should be unsigned.
53+
54+
\begin{lstlisting}[style=mycpp]
55+
int i; // Warning, signed type variable
56+
unsigned u = 1;
57+
unsigned long ul = 2
58+
sc_uint<12> x = 3;
59+
sc_int<12> y; // Warning, signed type variable
60+
sc_biguint<32> bx = 4;
61+
uint8_t z;
62+
const unsigned N = 42;
63+
ul = u + 1;
64+
ul = 1 << x; // Warning, signed literal in shift
65+
ul = 1U << x;
66+
ul = x + z; // False warning for uint8_t
67+
\end{lstlisting}

doc/trans_flow.tex

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,41 @@ \subsection{Variables generation}\label{section:var_gen}
209209
end
210210
\end{lstlisting}
211211

212+
\subsection{Non-modified member variables generation}\label{section:non_modif_var_gen}
213+
Module or modular interface member variables which are non-modified in any process, considered as initialized at elaboration phase. Because of dynamic elaborator used in the tool, it is not possible to detect if a variable is not initialized at elaboration phase.
214+
215+
For such member variables which are scalar (non-array) and non-record type, SV local parameters are generated.
216+
No local parameters generated for array and record members, so these variables remain non-initialized. Such member variable should be initialized in reset section of a process where it is used.
217+
218+
\begin{lstlisting}[style=mycpp]
219+
class MyModule : public sc_module {
220+
bool C = true;
221+
int D;
222+
unsigned E;
223+
224+
CTOR (MyModule) {
225+
D = 42;
226+
}
227+
void setE(unsigned par) { E = par; }
228+
}
229+
...
230+
MyModule m{"m"};
231+
...
232+
m.setE(43); // In parent module constructor
233+
\end{lstlisting}
234+
%
235+
\begin{lstlisting}[style=myverilog]
236+
// Generated SystemVerilog
237+
localparam logic C = 1;
238+
localparam logic signed [31:0] D = 42;
239+
localparam logic [31:0] E = 43;
240+
\end{lstlisting}
241+
242+
Nothing is generated if the variable is not used in any process. If such variable is member of array of modular interfaces, it should be used in a process of each modular interface.
212243

213244
\subsection{Constants generation}\label{section:const_gen}
214245

215-
For constants and static constants SV local parameters are generated. There is {\tt KEEP\_CONST\_VARIABLES} option to replace the constants in the code with their values, see~\ref{section:tool_options}. Constant is replaced with its value if the value if there is no reference to the constant. If constant is replaced with its value or not used in the code, no SV local parameter is generated.
246+
For constants and static constants SV local parameters are generated.
216247

217248
\begin{lstlisting}[style=mycpp]
218249
static const bool C = true;
@@ -226,6 +257,8 @@ \subsection{Constants generation}\label{section:const_gen}
226257
localparam logic signed [31:0] D = 'd42;
227258
\end{lstlisting}
228259

260+
There is {\tt REPLACE\_CONST\_VARIABLES} option to replace the constants in the code with their values, see~\ref{section:tool_options}. A constant is replaced with its value if the value if there is no reference to the constant. If constant is replaced with its value or not used in the code, no SV local parameter is generated.
261+
229262
\subsection{Method process generation}\label{section:method_gen}
230263

231264
Method process is directly translated into {\tt always\_comb} block. All the local variables of the method are translated into local variables in the {\tt always\_comb} block.

doc/ug.pdf

-26.5 KB
Binary file not shown.

doc/ug.tex

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
\subtitle{version 1.4}
77

88
\author{Mikhail Moiseev}
9+
\ifdefined\INTEL
10+
\else
911
\affiliation[obeypunctuation=true]{
1012
\institution{Intel Corporation}
1113
}
14+
\fi
1215

1316
%\email{mikhail.moiseev at intel.com}
1417

@@ -23,8 +26,6 @@
2326

2427
\pagebreak
2528

26-
%\newif\INTEL
27-
2829
\section{Preface}
2930

3031
Intel\textregistered Compiler for SystemC* (ICSC) is open source tool distributed under \href{https://github.com/intel/systemc-compiler/blob/main/LICENSE.txt}{Apache License v2.0 with LLVM Exceptions}. The source codes are available at \href{https://github.com/intel/systemc-compiler}{github.com/intel/systemc-compiler}.
@@ -69,11 +70,18 @@ \section{Terminology and abbreviations}
6970
\else
7071
\include{install}
7172
\fi
73+
\include{tool_options}
7274

7375
\include{prepare}
7476

7577
\include{trans_flow}
7678

79+
\section{Extensions}\label{section:extensions}
80+
81+
\ifdefined\INTEL
82+
\include{extensions_intel}
83+
\fi
84+
7785
\include{extensions}
7886

7987
\include{errors}

sc_tool/lib/sc_tool/SCToolFrontendAction.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ Object* getOuterArray(SCDesign& designDB, Object* memberObj)
112112
return arrayObj;
113113
}
114114

115-
const std::string SCElabASTConsumer::TOOL_VERSION = "1.4.15";
116-
const std::string SCElabASTConsumer::TOOL_DATE = "10 Mar,2022";
115+
const std::string SCElabASTConsumer::TOOL_VERSION = "1.4.18";
116+
const std::string SCElabASTConsumer::TOOL_DATE = "15 Apr,2022";
117117

118118
void SCElabASTConsumer::HandleTranslationUnit(clang::ASTContext &astCtx)
119119
{
@@ -125,25 +125,21 @@ void SCElabASTConsumer::HandleTranslationUnit(clang::ASTContext &astCtx)
125125
TOOL_VERSION << ", " << TOOL_DATE << endl;
126126
cout << "--------------------------------------------------------------" << endl;
127127

128-
//replaceConstByValue.setValue(true);
129-
//cout << "replaceConstByValue " << replaceConstByValue << endl;
130-
131128
//const char* optNames[] = {doElab};
132129
//const char* optNames[] = {doConstCfg, doGenCfg};
133130
//const char* optNames[] = {doModuleBuilder, doGenCfg, doGenTerm, doGenRTL, doGenStmt, doGenBlock};
134131
//const char* optNames[] = {doModuleBuilder, doGenCfg, doGenStmt, doGenFuncCall, doVerWriter};
135132
//const char* optNames[] = {doModuleBuilder, doGenStmt, doGenName, doGenRTL};
136133
//const char* optNames[] = {doModuleBuilder, doConstCfg, doConstTerm, doConstBlock, doGenCfg};
137-
//const char* optNames[] = {doConstStmt};
138-
//const char* optNames[] = {doConstCfg, doElab};
139134
//const char* optNames[] = {doGenCfg, doGenLoop, doGenBlock, doModuleBuilder};
140135
//const char* optNames[] = {doModuleBuilder, doConstStmt, doConstCfg/*, doState*/};
141136
//const char* optNames[] = {doModuleBuilder, doGenStmt};
142137
//const char* optNames[] = {doGenTerm, doGenCfg, doGenStmt, doModuleBuilder};
143138
//const char* optNames[] = {doConstCfg, doConstLoop, doConstStmt, doConstBlock, doModuleBuilder};
144139
//const char* optNames[] = {doConstCfg, doConstStmt, doModuleBuilder};
145140
//const char* optNames[] = {doGenFuncCall, doGenStmt, doModuleBuilder};
146-
const char* optNames[] = {doModuleBuilder};
141+
//const char* optNames[] = {doConstStmt, doUseDef, doModuleBuilder};
142+
const char* optNames[] = {doUseDef, doConstStmt, doModuleBuilder};
147143
size_t optSize = sizeof(optNames)/sizeof(const char*);
148144
//DebugOptions::enable(optNames, optSize);
149145

sc_tool/lib/sc_tool/ScCommandLine.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ cl::opt<bool> initResetLocalVars(
5656
cl::cat(ScToolCategory)
5757
);
5858

59-
cl::opt<bool> replaceConstByValue(
60-
"replace_const_value",
61-
cl::desc("Replace constant with its number value if possible"),
62-
cl::cat(ScToolCategory)
63-
);
64-
6559
cl::opt<std::string> modulePrefix (
6660
"module_prefix",
6761
cl::desc("Module prefix string"),

0 commit comments

Comments
 (0)