Skip to content

Commit 96d94ca

Browse files
Version 1.3.31
1 parent 65f9ad5 commit 96d94ca

File tree

465 files changed

+13525
-6289
lines changed

Some content is hidden

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

465 files changed

+13525
-6289
lines changed

cmake/svc_target.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ function(svc_target exe_target)
1414
# PORT_MAP_GENERATE -- generate port map file for SV/SC mixed simulation
1515
# NO_REMOVE_EXTRA_CODE -- disable removing unused variable and extra code
1616
# INIT_LOCAL_VARS -- initialize local variables at declaration with zero
17+
# INIT_RESET_LOCAL_VARS -- initialize CTHREAD reset section local variables
18+
# at declaration with zero
1719
# ELAB_ONLY -- run elaboration without process generation
1820
# WILL_FAIL -- test will fail on non-synthesizable code
1921
set(boolOptions REPLACE_CONST_VALUE
2022
NO_SVA_GENERATE
2123
PORT_MAP_GENERATE
2224
NO_REMOVE_EXTRA_CODE
2325
INIT_LOCAL_VARS
26+
INIT_RESET_LOCAL_VARS
2427
ELAB_ONLY
2528
WILL_FAIL)
2629

@@ -59,6 +62,10 @@ function(svc_target exe_target)
5962
set(INIT_LOCAL_VARS -init_local_vars)
6063
endif()
6164

65+
if (${PARAM_INIT_RESET_LOCAL_VARS})
66+
set(INIT_RESET_LOCAL_VARS -init_reset_local_vars)
67+
endif()
68+
6269
if (${PARAM_REPLACE_CONST_VALUE})
6370
set(REPLACE_CONST_VALUE -replace_const_value)
6471
endif()
@@ -157,6 +164,7 @@ function(svc_target exe_target)
157164
${PORT_MAP_GENERATE}
158165
${NO_REMOVE_EXTRA_CODE}
159166
${INIT_LOCAL_VARS}
167+
${INIT_RESET_LOCAL_VARS}
160168
${ELAB_ONLY}
161169
--
162170
-D__SC_TOOL__ -D__SC_TOOL_ANALYZE__ -DNDEBUG

doc/install.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ \subsubsection{Generate SV code for all examples, tests and designs}
198198
For {\tt counter} example:
199199
%
200200
\begin{lstlisting}[language=bash]
201-
$ cd examples/counter # go to counter example folder
201+
$ cd icsc/examples/counter # go to counter example folder
202202
$ cat sv_out/counter.sv # see generated SystemVerilog file
203203
\end{lstlisting}
204204

@@ -207,10 +207,10 @@ \subsubsection{Run SystemC simulation}
207207
SystemC simulation for examples and tests can be run with:
208208
\begin{lstlisting}[language=bash]
209209
$ cd $ICSC_HOME
210-
$ mkdir build && cd build
210+
$ mkdir -p build && cd build
211211
$ cmake ../ # prepare Makefiles
212212
$ make counter # compile SystemC simulation for counter example
213-
$ cd examples/counter # go to counter example folder
213+
$ cd icsc/examples/counter # go to counter example folder
214214
$ ./counter # run SystemC simulation
215215
\end{lstlisting}
216216

doc/prepare.tex

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,21 @@ \subsection{Clock and reset}
303303

304304
Clocked thread process ({\tt SC\_CTHREAD} and {\tt SC\_THREAD}) is activated by one clock edge. Method process ({\tt SC\_METHOD}) can be sensitive to any change in the signals including clock positive or/and negative edge.
305305

306+
Method process can have arbitrary number of resets in its sensitivity list.
307+
\begin{lstlisting}[style=mycpp]
308+
SC_CTOR(test_reset) {
309+
SC_METHOD(proc);
310+
sensitive << sreset << areset << ...;
311+
}
312+
void proc() {
313+
if (!sreset || !areset) {
314+
// Reset behavior
315+
} else {
316+
// Normal behavior
317+
}
318+
}
319+
\end{lstlisting}
320+
306321
Clocked thread process can have one, several or no reset. Clocked thread cannot have more than one asynchronous reset, but can have multiple synchronous resets. SystemC synthesizable subset does not allow clocked thread without resets and multiple synchronous resets. As soon as no reset clocked threads and clocked thread with multiple synchronous resets are required for some applications that is supported by ICSC tool.
307322

308323
Method process can be sensitive to all resets required.
@@ -354,7 +369,9 @@ \subsection{Clock and reset}
354369
}
355370
\end{lstlisting}
356371

357-
For thread process ICSC generates pair of {\tt always\_comb} and {\tt always\_ff} blocks as described in~\ref{section:noreset}.
372+
For clocked thread process ICSC generates pair of {\tt always\_comb} and {\tt always\_ff} blocks as described in~\ref{section:thread_gen}.
373+
374+
There are some limitation to variable use in reset section of clocked thread described in~\ref{section:reg_in_reset}.
358375

359376
\subsection{Data types}
360377

doc/trans_flow.tex

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ \subsection{Module generation}\label{section:module_gen}
7474
localparam logic signed [31:0] D = 'd42;
7575

7676
//------------------------------------------------------------------------------
77-
// Assignments generated for SystemC array of channels
77+
// Assignments generated for SystemC channel arrays
7878
assign f[0] = f0;
7979
assign f[1] = f1;
8080

@@ -388,6 +388,51 @@ \subsection{Thread process generation}\label{section:thread_gen}
388388
end
389389
\end{lstlisting}
390390

391+
\subsection{Register variables in thread reset section}\label{section:reg_in_reset}
392+
393+
There are some limitations to use register variables in reset section of clocked thread. Register variable is a variable which keeps its values between thread states. Register variable {\tt i} is represented with a pair of variables {\tt i} and {\tt i\_next} in SV code. Register next to current value has non-blocking assignment in {\tt always\_ff} block, therefore such variable cannot have blocking assignment in reset section. For operations which modify register variable in reset section error is reported:
394+
%
395+
\begin{lstlisting}[style=mycpp]
396+
void proc() {
397+
int i = 1; // Register variable
398+
i++; // Error reported
399+
i += 1; // Error reported
400+
wait();
401+
while (true) {
402+
out = i; // Value from reset used here
403+
wait();
404+
}
405+
\end{lstlisting}
406+
407+
\begin{lstlisting}[style=myverilog]
408+
logic signed [31:0] i;
409+
logic signed [31:0] i_next;
410+
always_ff @(posedge clk or negedge arstn)
411+
begin : read_modify_reg_in_reset_ff
412+
if ( ~arstn ) begin
413+
i <= 1;
414+
i++; // Blocking assignment
415+
i = i + 2;
416+
end
417+
else begin
418+
i <= i_next;
419+
end
420+
\end{lstlisting}
421+
422+
Another problem with register variable is reading it in reset section. As soon as the variables has non-blocking assignment it values could be incorrect in RHS of the following statements. For operations which read register variable in reset section warning is reported:
423+
%
424+
\begin{lstlisting}[style=mycpp]
425+
void proc() {
426+
int i = 1; // Register variable
427+
int j = i; // Warning reported
428+
i = j; // X results in SV simulation
429+
wait();
430+
while (true) {
431+
out = i; // Value from reset used here
432+
wait();
433+
}
434+
\end{lstlisting}
435+
391436
\subsection{Thread process without reset}\label{section:noreset}
392437

393438
Thread process without reset supported with limitations: such process can have only one {\tt wait()} and cannot have any code in reset section.

doc/ug.pdf

9.56 KB
Binary file not shown.

examples/counter/example.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,53 @@
1212
// and all DUT ports are bound.
1313
struct Tb : sc_module
1414
{
15-
sc_clock clk{"clk", sc_time(1, SC_NS)};
15+
sc_in_clk clk{"clk"};
1616
sc_signal<bool> rstn{"rstn"};
1717
sc_signal<sc_uint<4> > counter{"counter"};
1818
sc_signal<bool> even{"even"};
1919

2020
Dut dut_inst{"dut_inst"};
21-
21+
2222
SC_CTOR(Tb)
2323
{
24+
SC_CTHREAD(reset_test, clk.pos());
25+
2426
dut_inst.clk(clk);
2527
dut_inst.rstn(rstn);
2628
dut_inst.counter(counter);
2729
dut_inst.even(even);
30+
31+
SC_METHOD(print_method);
32+
sensitive << clk.pos();
33+
}
34+
35+
void print_method() {
36+
cout << sc_time_stamp() << "\t\t" << rstn.read() << "\t\t"
37+
<< counter.read() << "\t\t" << even.read() << endl;
2838
}
39+
40+
void reset_test() {
41+
rstn = 1;
42+
wait(2);
43+
44+
rstn = 0;
45+
wait(3);
46+
47+
rstn = 1;
48+
wait(100);
49+
}
50+
2951
};
3052

3153
int sc_main (int argc, char **argv)
3254
{
55+
sc_clock clk{"clk", sc_time(1, SC_NS)};
3356
Tb tb("tb");
34-
sc_start();
57+
tb.clk(clk);
58+
59+
cout <<"Time\t\tReset\t\tCounter\t\tEven" << endl;
60+
sc_start(20, SC_NS);
61+
cout <<"\n\t\t*****Simulation complete*****" << endl;
62+
3563
return 0;
3664
}

examples/dvcon20/dvcon_fifo.sv

Lines changed: 30 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//==============================================================================
22
//
3-
// The code is generated by Intel Compiler for SystemC, version 1.3.20
3+
// The code is generated by Intel Compiler for SystemC, version 1.3.31
44
// see more information at https://github.com/intel/systemc-compiler
55
//
66
//==============================================================================
@@ -174,39 +174,30 @@ logic almost_full_reg;
174174

175175
always_comb
176176
begin : asyncProc // AdvFifo.h:176:5
177-
if (1)
177+
if (!out_valid_reg)
178178
begin
179-
if (!out_valid_reg)
179+
if (pop_enable_sig)
180180
begin
181-
if (pop_enable_sig)
182-
begin
183-
data_out = data_in;
184-
out_valid = push;
185-
push_sig = push && !pop;
186-
end else begin
187-
out_valid = mcp_valid_reg;
188-
data_out = mcp_data_reg;
189-
push_sig = push;
190-
end
181+
data_out = data_in;
182+
out_valid = push;
183+
push_sig = push && !pop;
191184
end else begin
192-
out_valid = 1;
193-
data_out = pop_data;
185+
out_valid = mcp_valid_reg;
186+
data_out = mcp_data_reg;
194187
push_sig = push;
195188
end
189+
end else begin
190+
out_valid = 1;
191+
data_out = pop_data;
192+
push_sig = push;
196193
end
197-
if (1)
194+
if (push_enable_sig)
198195
begin
199-
if (push_enable_sig)
200-
begin
201-
ready_to_push = pop && pop_enable && out_valid_reg || ready_push_reg;
202-
end else begin
203-
ready_to_push = ready_push_reg;
204-
end
205-
end
206-
if (1)
207-
begin
208-
almost_full = almost_full_reg || (push && !pop && element_num == 6 - 3 - 1);
196+
ready_to_push = pop && pop_enable && out_valid_reg || ready_push_reg;
197+
end else begin
198+
ready_to_push = ready_push_reg;
209199
end
200+
almost_full = almost_full_reg || (push && !pop && element_num == 6 - 3 - 1);
210201
end
211202

212203
//------------------------------------------------------------------------------
@@ -258,30 +249,24 @@ function void syncProc_func;
258249
ready_push_reg_next = ready_to_push;
259250
if (pop && pop_enable && out_valid_reg)
260251
begin
261-
if (1)
252+
if (popIndx_next == 6 - 1)
262253
begin
263-
if (popIndx_next == 6 - 1)
264-
begin
265-
popIndx_next = 0;
266-
end else begin
267-
popIndx_next = popIndx_next + 1;
268-
end
269-
elementNum_next = elementNum_next - 1;
254+
popIndx_next = 0;
255+
end else begin
256+
popIndx_next = popIndx_next + 1;
270257
end
258+
elementNum_next = elementNum_next - 1;
271259
end
272260
if (push_sig && ready_to_push)
273261
begin
274262
fifo_buffer_flat_next[pushIndx_next] = data_in;
275-
if (1)
263+
if (pushIndx_next == 6 - 1)
276264
begin
277-
if (pushIndx_next == 6 - 1)
278-
begin
279-
pushIndx_next = 0;
280-
end else begin
281-
pushIndx_next = pushIndx_next + 1;
282-
end
283-
elementNum_next = elementNum_next + 1;
265+
pushIndx_next = 0;
266+
end else begin
267+
pushIndx_next = pushIndx_next + 1;
284268
end
269+
elementNum_next = elementNum_next + 1;
285270
end
286271
pop_data_next = fifo_buffer_flat_next[popIndx_next];
287272
if (push_enable)
@@ -291,10 +276,7 @@ function void syncProc_func;
291276
end
292277
if (pop_enable)
293278
begin
294-
if (1)
295-
begin
296-
element_num_next = elementNum_next;
297-
end
279+
element_num_next = elementNum_next;
298280
out_valid_reg_next = elementNum_next != 0;
299281
end
300282
element_num_d_next = element_num;
@@ -318,12 +300,9 @@ begin : syncProc_ff
318300
pushIndx <= 0;
319301
pop_data <= 0;
320302
fifo_buffer_flat[0] <= 32'd0;
321-
if (1)
303+
for (integer i = 1; i < 6; i++)
322304
begin
323-
for (integer i = 1; i < 6; i++)
324-
begin
325-
fifo_buffer_flat[i] <= 32'd0;
326-
end
305+
fifo_buffer_flat[i] <= 32'd0;
327306
end
328307
end
329308
else begin

sc_tool/lib/sc_tool/SCToolFrontendAction.cpp

Lines changed: 4 additions & 4 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.3.26";
116-
const std::string SCElabASTConsumer::TOOL_DATE = "08 Jun,2021";
115+
const std::string SCElabASTConsumer::TOOL_VERSION = "1.3.31";
116+
const std::string SCElabASTConsumer::TOOL_DATE = "02 Jul,2021";
117117

118118
void SCElabASTConsumer::HandleTranslationUnit(clang::ASTContext &astCtx)
119119
{
@@ -141,9 +141,9 @@ void SCElabASTConsumer::HandleTranslationUnit(clang::ASTContext &astCtx)
141141
//const char* optNames[] = {doModuleBuilder, doGenStmt};
142142
//const char* optNames[] = {doGenTerm, doGenCfg, doGenStmt, doModuleBuilder};
143143
//const char* optNames[] = {doConstCfg, doConstLoop, doConstStmt, doConstBlock, doModuleBuilder};
144-
const char* optNames[] = {doModuleBuilder};
144+
const char* optNames[] = {doGenStmt, doModuleBuilder};
145145
size_t optSize = sizeof(optNames)/sizeof(const char*);
146-
//DebugOptions::enable(optNames, optSize);
146+
//DebugOptions::enable(optNames, optSize);
147147

148148
//keepConstVariables = true;
149149

sc_tool/lib/sc_tool/ScCommandLine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ cl::opt<bool> initLocalVars(
4444
cl::cat(ScToolCategory)
4545
);
4646

47+
cl::opt<bool> initResetLocalVars(
48+
"init_reset_local_vars",
49+
cl::desc("Initialize CTHREAD reset local variables at declaration with zero"),
50+
cl::cat(ScToolCategory)
51+
);
52+
4753
cl::opt<bool> replaceConstByValue(
4854
"replace_const_value",
4955
cl::desc("Replace constant with its number value if possible"),

sc_tool/lib/sc_tool/ScCommandLine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern llvm::cl::opt<bool> noSvaGenerate;
2222
extern llvm::cl::opt<bool> portMapGenerate;
2323
extern llvm::cl::opt<bool> noRemoveExtraCode;
2424
extern llvm::cl::opt<bool> initLocalVars;
25+
extern llvm::cl::opt<bool> initResetLocalVars;
2526
extern llvm::cl::opt<bool> replaceConstByValue;
2627
extern llvm::cl::opt<std::string> modulePrefix;
2728

0 commit comments

Comments
 (0)