Skip to content

Commit e486aa7

Browse files
Version 1.6.18. C++20 and SystemC 3.0.1
1 parent 2e5e305 commit e486aa7

Some content is hidden

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

61 files changed

+1311
-2266
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ add_custom_command(OUTPUT ${SYSTEMC_PCH}
5454
COMMAND
5555
${CLANG_CXX_EXECUTABLE} -Xclang -emit-pch -x c++-header
5656
${CMAKE_SOURCE_DIR}/systemc/src/systemc.h -o ${SYSTEMC_PCH} ${MSVC_FLAGS}
57-
-D__SC_TOOL__ -D__SC_TOOL_ANALYZE__ -DNDEBUG -std=c++17
57+
-D__SC_TOOL__ -D__SC_TOOL_ANALYZE__ -DNDEBUG -std=c++20
5858
-I${CMAKE_SOURCE_DIR}/systemc/src
5959
DEPENDS systemc
6060
COMMENT "Generating SystemC precompiled header ${SYSTEMC_PCH}"

cmake/CMakeLists.top

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cmake_minimum_required(VERSION 3.12)
1313
project (icsc_designs)
1414

1515
## C++ standard
16-
set(CMAKE_CXX_STANDARD 17)
16+
set(CMAKE_CXX_STANDARD 20)
1717

1818
enable_testing()
1919

cmake/svc_target.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function(svc_target exe_target)
179179
--
180180
-D__SC_TOOL__ -D__SC_TOOL_ANALYZE__ -DNDEBUG -DSC_ALLOW_DEPRECATED_IEEE_API
181181
-Wno-logical-op-parentheses
182-
-std=c++17 ${INCLUDE_DIRS} ${COMP_DEFINITIONS}
182+
-std=c++20 ${INCLUDE_DIRS} ${COMP_DEFINITIONS}
183183
-I${CMAKE_SOURCE_DIR}/sc_elab2/lib
184184
${PCH_OPT})
185185

components/common/sctcommon/sct_buffer.h

Lines changed: 78 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,17 @@ class sct_buffer :
3939
public sct_fifo_if<T>
4040
{
4141
public:
42-
/// Initialize FIFO slots in reset with zeros
43-
const bool INIT_BUFFER;
44-
45-
/// Number of bits in variables store index and length of FIFO
46-
static const unsigned INDX_WIDTH = sct_addrbits1<LENGTH>;
47-
using Indx_t = sc_uint<INDX_WIDTH>;
48-
static const unsigned ELEM_NUM_WIDTH = sct_nbits<LENGTH>;
49-
using ElemNum_t = sc_uint<ELEM_NUM_WIDTH>;
50-
51-
/// \param init_buffer -- Initialize all buffer elements with zeros in reset
52-
/// First element to get is always initialized to zero id
5342
explicit sct_buffer(const char* name,
5443
bool sync_valid = 0, bool sync_ready = 0,
5544
bool use_elem_num = 0, bool init_buffer = 0) :
56-
sc_prim_channel(name), INIT_BUFFER(init_buffer),
45+
sc_prim_channel(name),
46+
put_req(false), get_req(false), pop_indx(0), push_indx(0), element_num(0),
47+
#ifdef DEBUG_SYSTEMC
48+
attached_put(false), attached_get(false),
49+
#endif
5750
event(std::string(std::string(name)+"_event").c_str())
5851
{
59-
static_assert (LENGTH > 0);
52+
assert (LENGTH > 0);
6053
// This implementation equals to async valid/ready FIFO
6154
assert (!sync_valid && !sync_ready &&
6255
"No sync valid/ready allowed for Buffer");
@@ -77,23 +70,16 @@ class sct_buffer :
7770
/// Call in METHOD everywhere and CTHREAD reset sections
7871
void reset_get() override {
7972
pop_indx = 0;
80-
get_req = 0; data_out = T{};
73+
get_req = 0;
8174
request_update();
8275
}
8376

8477
/// Call in METHOD everywhere and CTHREAD reset sections
8578
void reset_put() override {
8679
push_indx = 0;
87-
put_req = 0; data_in = T{};
80+
put_req = 0;
8881
element_num = 0;
89-
90-
// Initialize zero cell to provide zero data before first push
9182
buffer[0] = T{};
92-
if (INIT_BUFFER) {
93-
for (unsigned i = 1; i != LENGTH; i++) {
94-
buffer[i] = T{};
95-
}
96-
}
9783
request_update();
9884
}
9985

@@ -114,70 +100,66 @@ class sct_buffer :
114100
}
115101

116102
T peek() const override {
117-
return data_out;
103+
return buffer[pop_indx];
104+
}
105+
106+
protected:
107+
inline void doGet() {
108+
get_req = 1;
109+
request_update();
118110
}
119111

112+
inline void doPut(const T& data) {
113+
put_req = 1;
114+
buffer[push_indx] = data;
115+
request_update();
116+
}
117+
118+
public:
120119
/// \return current request data, if no request last data returned
121120
T get() override {
122-
if (element_num != 0) {
123-
get_req = 1;
124-
request_update();
125-
if constexpr (SCT_CMN_TLM_MODE) event.notify(clk_period);
126-
}
127-
return data_out;
121+
if (element_num != 0) { doGet(); }
122+
return buffer[pop_indx];
128123
}
129124

130125
/// \return true if request is valid and enable is true
131126
bool get(T& data, bool enable = true) override {
132-
data = data_out;
133-
if (element_num != 0) {
134-
get_req = enable;
135-
request_update();
136-
if constexpr (SCT_CMN_TLM_MODE) event.notify(clk_period);
137-
return enable;
127+
data = buffer[pop_indx];
128+
if (enable && element_num != 0) {
129+
doGet();
130+
return true;
138131
} else {
139132
return false;
140133
}
141134
}
142135

143136
T b_get() override {
144137
while (element_num == 0) wait();
145-
get_req = 1;
146-
request_update();
147-
if constexpr (SCT_CMN_TLM_MODE) event.notify(clk_period);
148-
return data_out;
138+
doGet();
139+
return buffer[pop_indx];
149140
}
150141

151142
bool put(const T& data) override {
152-
data_in = data;
153143
if (element_num != LENGTH) {
154-
put_req = 1;
155-
request_update();
156-
if constexpr (SCT_CMN_TLM_MODE) event.notify(clk_period);
144+
doPut(data);
157145
return true;
158146
} else {
159147
return false;
160148
}
161149
}
162150

163151
bool put(const T& data, sc_uint<1> mask) override {
164-
data_in = data;
165-
if (element_num != LENGTH) {
166-
put_req = bool(mask);
167-
request_update();
168-
if constexpr (SCT_CMN_TLM_MODE) event.notify(clk_period);
169-
return mask;
152+
if (mask && element_num != LENGTH) {
153+
doPut(data);
154+
return true;
170155
} else {
171156
return false;
172157
}
173158
}
174159

175160
void b_put(const T& data) override {
176-
data_in = data;
177161
while (element_num == LENGTH) wait();
178-
put_req = 1;
179-
request_update();
180-
if constexpr (SCT_CMN_TLM_MODE) event.notify(clk_period);
162+
doPut(data);
181163
}
182164

183165
/// Maximal number of elements
@@ -201,28 +183,26 @@ class sct_buffer :
201183
}
202184

203185
protected:
204-
/// This buffer attached to a processes
205-
bool attached_put = false;
206-
bool attached_get = false;
207-
208-
sc_in_clk* clk_in = nullptr;
209-
sc_time clk_period = SC_ZERO_TIME;
210-
211-
T buffer[LENGTH];
212-
213186
/// Index of element that will be poped
214-
Indx_t pop_indx;
187+
unsigned short pop_indx : 16;
215188
/// Index where pushed element will be stored
216-
Indx_t push_indx;
189+
unsigned short push_indx : 16;
217190
/// Number of elements
218-
ElemNum_t element_num;
191+
unsigned short element_num : 16;
219192

220-
bool put_req;
221-
T data_in;
193+
bool put_req : 8;
194+
bool get_req : 8;
195+
196+
#ifdef DEBUG_SYSTEMC
197+
bool attached_put : 8;
198+
bool attached_get : 8;
199+
#endif
222200

223-
bool get_req;
224-
T data_out;
201+
sc_in_clk* clk_in = nullptr;
202+
sc_time clk_period = SC_ZERO_TIME;
225203

204+
T buffer[LENGTH] = {};
205+
226206
/// Event for put, get and peek thread processes notification
227207
sc_event event;
228208

@@ -233,20 +213,21 @@ class sct_buffer :
233213
get_req = 0;
234214
}
235215
if (put_req) {
236-
buffer[push_indx] = data_in;
237216
push_indx = (push_indx == LENGTH-1) ? 0 : (push_indx+1);
238217
element_num += 1;
239218
put_req = 0;
240219
}
241-
data_out = buffer[pop_indx];
220+
if constexpr (SCT_CMN_TLM_MODE) event.notify(clk_period);
242221
}
243222

244223
void end_of_elaboration() override {
224+
#ifdef DEBUG_SYSTEMC
245225
if (!attached_put || !attached_get) {
246226
cout << "\nBuffer " << name()
247227
<< " is not fully attached to process(es)" << endl;
248228
assert (false);
249229
}
230+
#endif
250231
if constexpr (SCT_CMN_TLM_MODE) {
251232
if (clk_in) {
252233
clk_period = get_clk_period(clk_in);
@@ -259,23 +240,32 @@ class sct_buffer :
259240

260241
public:
261242
void clk_nrst(sc_in_clk& clk_in_, sc_in<bool>& nrst_in) {
262-
if constexpr (SCT_CMN_TLM_MODE) { clk_in = &clk_in_; }
243+
clk_in = &clk_in_;
263244
}
264245

265246
void add_to(sc_sensitive& s, bool attachedPut, bool attachedGet) {
266247
if (sct_seq_proc_handle == sc_get_current_process_handle()) {
267248
// Sequential method
268-
if constexpr (SCT_CMN_TLM_MODE) { s << event; }
249+
if constexpr (SCT_CMN_TLM_MODE) {
250+
s << event;
251+
} else {
252+
if (TRAITS::CLOCK == 2) s << *clk_in;
253+
else s << (TRAITS::CLOCK ? clk_in->pos() : clk_in->neg());
254+
}
269255
} else {
270256
auto procKind = sc_get_current_process_handle().proc_kind();
271257
if (procKind != SC_THREAD_PROC_ && procKind != SC_CTHREAD_PROC_) {
272258
cout << "Buffer cannot be used in combinational method process" << endl;
273259
assert (false);
274260
}
275-
if constexpr (SCT_CMN_TLM_MODE) {
261+
if constexpr (SCT_CMN_TLM_MODE) {
276262
if (procKind != SC_CTHREAD_PROC_) { s << event; }
277-
}
263+
} else {
264+
if (TRAITS::CLOCK == 2) s << *clk_in;
265+
else s << (TRAITS::CLOCK ? clk_in->pos() : clk_in->neg());
266+
}
278267
}
268+
#ifdef DEBUG_SYSTEMC
279269
if (attachedPut) {
280270
if (attached_put) {
281271
cout << "Double addToPut() for Buffer: " << name() << endl;
@@ -290,13 +280,19 @@ class sct_buffer :
290280
}
291281
attached_get = true;
292282
}
283+
#endif
293284
}
294285

295286
void add_to(sc_sensitive* s, sc_process_handle* p, bool attachedPut,
296287
bool attachedGet) {
297288
if (sct_seq_proc_handle == *p) {
298289
// Sequential method
299-
if constexpr (SCT_CMN_TLM_MODE) { *s << *p << event; }
290+
if constexpr (SCT_CMN_TLM_MODE) {
291+
*s << *p << event;
292+
} else {
293+
if (TRAITS::CLOCK == 2) *s << *p << *clk_in;
294+
else *s << *p << (TRAITS::CLOCK ? clk_in->pos() : clk_in->neg());
295+
}
300296
} else {
301297
auto procKind = p->proc_kind();
302298
if (procKind != SC_THREAD_PROC_ && procKind != SC_CTHREAD_PROC_) {
@@ -305,8 +301,12 @@ class sct_buffer :
305301
}
306302
if constexpr (SCT_CMN_TLM_MODE) {
307303
if (procKind != SC_CTHREAD_PROC_) { *s << *p << event; }
308-
}
304+
} else {
305+
if (TRAITS::CLOCK == 2) *s << *p << *clk_in;
306+
else *s << *p << (TRAITS::CLOCK ? clk_in->pos() : clk_in->neg());
307+
}
309308
}
309+
#ifdef DEBUG_SYSTEMC
310310
if (attachedPut) {
311311
if (attached_put) {
312312
cout << "Double addToPut() for Buffer: " << name() << endl;
@@ -321,6 +321,7 @@ class sct_buffer :
321321
}
322322
attached_get = true;
323323
}
324+
#endif
324325
}
325326

326327
void addTo(sc_sensitive& s) override { add_to(s, true, true); }

components/common/sctcommon/sct_zero_width.h

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,15 @@ struct sct_zero_width;
3030
struct sct_zero_width : public sc_dt::sc_value_base
3131
{
3232
sct_zero_width() {}
33-
sct_zero_width(int_type v) {}
34-
sct_zero_width(uint_type v) {}
35-
sct_zero_width(const char* a) {}
36-
sct_zero_width(unsigned long a) {}
37-
sct_zero_width(long a) {}
38-
sct_zero_width(unsigned int a) {}
39-
sct_zero_width(int a) {}
40-
sct_zero_width(double a) {}
41-
42-
sct_zero_width(const sc_uint_base& a) {}
43-
sct_zero_width(const sc_unsigned& a) {}
44-
sct_zero_width(const sc_int_base& a) {}
45-
sct_zero_width(const sc_signed& a) {}
46-
sct_zero_width(const sc_bv_base& a) {}
47-
sct_zero_width(const sc_bit& a) {}
48-
49-
sct_zero_width(const sc_concatref& a) {}
50-
51-
sct_zero_width(const sct_zero_width& a) {}
33+
template<class T> sct_zero_width(const T&) {}
5234

5335
static const sct_zero_width& get_zero_width() {
5436
static sct_zero_width val;
5537
return val;
5638
}
5739

5840
template<class T>
59-
sct_zero_width& operator = (const T& v) {return *this;}
41+
sct_zero_width& operator = (const T&) {return *this;}
6042

6143
template<class T>
6244
sct_zero_width& operator += (T v) {return *this;}
@@ -84,12 +66,6 @@ struct sct_zero_width : public sc_dt::sc_value_base
8466
sct_zero_width& operator -- () {return *this;}
8567
sct_zero_width& operator -- (int) {return *this;}
8668

87-
bool operator == (const sct_zero_width&) {return true;}
88-
bool operator == (int_type v) {return v == 0;}
89-
bool operator == (uint_type v) {return v == 0;}
90-
bool operator == (int v) {return v == 0;}
91-
bool operator == (unsigned int v) {return v == 0;}
92-
9369
bool operator ! () {return true;}
9470
bool operator ~ () {return true;}
9571

designs/examples/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ project(icsc_examples)
1919
## SVC package contains ScTool and SystemC libraries
2020
find_package(SVC REQUIRED)
2121

22-
# C++ standard must be the same as in ScTool, $(SystemC_CXX_STANDARD) contains 17
23-
set(CMAKE_CXX_STANDARD 17)
22+
# C++ standard must be the same as in ScTool, $(SystemC_CXX_STANDARD) contains 20
23+
set(CMAKE_CXX_STANDARD 20)
2424

2525
add_subdirectory(asserts)
2626
add_subdirectory(counter)

designs/examples/dma/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ project(DmaEngine_NoSs)
2323
find_package(SVC REQUIRED)
2424

2525
set(PROC_TECH fpga)
26-
set(CMAKE_CXX_STANDARD 17)
27-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
26+
set(CMAKE_CXX_STANDARD 20)
27+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")
2828

2929
include_directories(
3030
"$ENV{ICSC_HOME}/include"

0 commit comments

Comments
 (0)