Jump to content

Errors in code


Uzmeed

Recommended Posts

Hi 

Attached is the code for parallel to serial and serial to parallel conversion

i have two problems in converter.cpp

1- count is not incrementing the value

2- Lout is not getting value of PS_reg

 

in SPPS48 i am getting the following error

./../../SPPS48.h: In constructor 'SPPS48::SPPS48(sc_core::sc_module_name)':
../../../SPPS48.h:51:9: error: 'struct SPPS48' has no member named 'M1'
../../../SPPS48.h:51:16: error: expected type-specifier before 'SPPS'
../../../SPPS48.h:51:16: error: expected ';' before 'SPPS'
../../../SPPS48.h:52:3: error: 'M1' was not declared in this scope
../../../SPPS48.h:60:3: error: 'M2' was not declared in this scope
../../../SPPS48.h:60:10: error: expected type-specifier before 'SPPS'
../../../SPPS48.h:60:10: error: expected ';' before 'SPPS'
../../../SPPS48.h:69:3: error: 'M3' was not declared in this scope
../../../SPPS48.h:69:10: error: expected type-specifier before 'SPPS'
../../../SPPS48.h:69:10: error: expected ';' before 'SPPS'

convert.cpp

main.cpp

SPPS.h

SPPS48.h

Link to comment
Share on other sites

From a quick glance into your source files, I see:

  • Your headers are missing #include guards.
  • You don't include SPPS.h in your header SPPS48.h, but your members M1, M2, and M3 are of type SPPS, which you define in SPPS.h
  • I recommend that you don't use the header <systemc.h>, as it seriously pollutes your public namespace. Use header <systemc> instead and import only the symbols in your current namespace, which you actually use.
  • Your constructor allocates manually memory for the members M1, M2, and M3 using "new", but lacks a destructor, which would release the objects using "delete". Anyway, this is not considered "Modern C++". Instead of raw pointers to objects of type SPPS, use a smart pointer. In your case, std::unique_ptr is probably the appropriate choice.
  • All members of your SC_MODULE are exposed to public. This may be good for debugging, but it is better to only expose those members, which constitute the public interface of your module (i.e., at least the input/output ports, constructor, and destructor). Your SC_METHODs and SC_THREADs don't need to be public.
  • Your approach to generate a clock signal in sc_main() is tedious the most. A clk signal of type sc_core::sc_clock is a more comfortable solution. To generate more comfortably complex stimuli, I recommend that you implement them in an own stimuli module. Therein, you can register an SC_THREAD, which performs the stimuli generation and which can easily wait for delays or event before proceeding to the next stimulus. In the same way a monitor for your output signal can be implemented.

I repeat my recommendation to learn first the basics of modern C++ and to read a good book on SystemC to get more efficient in your modelling attempts!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...