Jump to content

Kishore17

Members
  • Content Count

    3
  • Joined

  • Last visited

Everything posted by Kishore17

  1. Hello Mr. Black, Thank you for the quick reply. I didn't quite understand what you exactly mean, but, I will try finding some material where i can learn how a co-operative multitasking event driven simulator works. But, did you mean to suggest that I use bus_o->write(VALUE); instead of bus_o = VALUE; I tried this, and I still get the same issue. The question that still haunts me is , why does busin in my datagen file updates after 1ns? I can already see the value in inputs.cpp at 0 NS. (Note : Inputs.cpp file receives busin value from datagen) If you mean to say that the behavior is correct and I don't have to modify anything in my code, then it's all good. Here, I am attaching datagen.h SC_MODULE(datagen) { public: sc_out<sc_bv<8>> busin_o; SC_CTOR(datagen); /*private:*/ void testgen(void); void asTakt(void); }; and inputs2.h SC_MODULE(inputs) { public: sc_in<sc_bv<8>> busin; sc_out<sc_bv<8>> pout; sc_out<sc_bv<8>> out; SC_CTOR(inputs); private: /* method*/ void mydesign(void); }; Please find the updated datagen.cpp, below void datagen::testgen(void) { busin_o->write("11111111"); cout<< "-------------------------------------"<< endl; cout << "In dataGen::testgen: @" << sc_time_stamp() << " Busin in datagen: "<< busin_o <<endl; wait(1,SC_NS); cout<< sc_delta_count() << endl; busin_o->write("00111111"); cout<< "-------------------------------------"<< endl; cout << "In dataGen::testgen: @" << sc_time_stamp() << " Busin in datagen: "<< busin_o <<endl; wait(1,SC_NS); busin_o->write("10000111"); cout<< "-------------------------------------"<< endl; cout << "In dataGen::testgen: @" << sc_time_stamp() << " Busin in datagen: "<< busin_o <<endl; wait(1,SC_NS); busin_o->write("11111110"); cout<< "-------------------------------------"<< endl; cout << "In dataGen::testgen: @" << sc_time_stamp() << " Busin in datagen: "<< busin_o <<endl; cout<<"Intended end of simulation"<< endl; sc_stop(); } And the inputs.cpp file still remains the same inputs::inputs(sc_module_name inst) : sc_module(inst) { cout<<"Constructor- inputs: "<< name() <<endl; SC_METHOD(mydesign); sensitive << busin; } void inputs::mydesign() { cout<< "-------------------------------------"<< endl; cout<<"Mydesign Activated @ "<<sc_time_stamp() <<endl; cout<< "-------------------------------------"<< endl; cout << "In Inputs::mydesign: @" << sc_time_stamp() << " Busin in Inputs: "<< busin <<endl; pout-> write(busin.read()); cout << "In Inputs::mydesign: @" << sc_time_stamp() << " pout in Inputs: "<< pout <<endl; } Please let me know if you find a problem with the code. Thanks a ton.
  2. Hello All, I am a beginner in SystemC, and I really need your help in solving a timing issue. Please find my code attached : datagen::datagen(sc_module_name nm) :sc_module(nm) { cout<<"Constructor- datagen: "<< name() << endl; SC_THREAD(testgen); } void datagen::testgen(void) { busin_o="11111111"; cout<< "-------------------------------------"<< endl; cout << "In dataGen::testgen: @" << sc_time_stamp() << " Busin in datagen: "<< busin_o <<endl; wait(1,SC_NS); cout<< sc_delta_count() << endl; busin_o="00111111"; cout<< "-------------------------------------"<< endl; cout << "In dataGen::testgen: @" << sc_time_stamp() << " Busin in datagen: "<< busin_o <<endl; wait(1,SC_NS); busin_o="10000111"; cout<< "-------------------------------------"<< endl; cout << "In dataGen::testgen: @" << sc_time_stamp() << " Busin in datagen: "<< busin_o <<endl; wait(1,SC_NS); busin_o="11111110"; cout<< "-------------------------------------"<< endl; cout << "In dataGen::testgen: @" << sc_time_stamp() << " Busin in datagen: "<< busin_o <<endl; cout<<"Intended end of simulation"<< endl; sc_stop(); } /* inputs2*/ inputs::inputs(sc_module_name inst) : sc_module(inst) { cout<<"Constructor- inputs: "<< name() <<endl; SC_METHOD(mydesign); sensitive << busin; } void inputs::mydesign() { cout<< "-------------------------------------"<< endl; cout<<"Mydesign Activated @ "<<sc_time_stamp() <<endl; cout<< "-------------------------------------"<< endl; cout << "In Inputs::mydesign: @" << sc_time_stamp() << " Busin in Inputs: "<< busin <<endl; pout-> write(busin.read()); cout << "In Inputs::mydesign: @" << sc_time_stamp() << " pout in Inputs: "<< pout <<endl; } I have 2 issues The first one is that mydesign block is being called twice @ 0 NS . (Can be seen in the screenshot) The second is that the assignment of busin_o in the datagen file is happening with a delay of 1ns, whereas in inputs2.cpp, it is happening correctly. But again, the assignment of busin to pout is not happening at the same time as it happens after 1 ns. I am really confused as to why the behavior is like this. Any help is appreciated. I have a feeling that there is a small timing error somewhere, but I am not able to fix it. Please help me. All the codes are attached for further reference. top2.h top2.cpp main2.cpp inputs2.h inputs2.cpp datagen2.h datagen2.cpp
  3. Hello Everyone, I have just started to learn system C and I have installed the 2.3.3 version on my linux system 18.04. I have tried installing in usr/local as well as in the local directory (for example : In the downloads itself). I have a very simple hello world program, but i have an error. I feel it is the problem with the installation, any help is highly appreciated. Thank you very much in advance. lugia@celebi:~/SystemC$ make Makefile:56: *** SYSTEMC_HOME [/usr/local/systemc-2.3.3/] is not present. Please update Makefile.config. Stop. lugia@celebi:~/SystemC$ make Makefile:56: *** SYSTEMC_HOME [/usr/local/systemc-2.3.3/] is not present. Please update Makefile.config. Stop. lugia@celebi:~/SystemC$ export SYSTEMC_HOME=/home/lugia/Downloads/systemc-2.3.3/ lugia@celebi:~/SystemC$ make g++ -g -Wall -pedantic -Wno-long-long -Werror -I. -I.. -I/home/lugia/Downloads/systemc-2.3.3//include -c hello.cpp -o hello.o In file included from /home/lugia/Downloads/systemc-2.3.3//include/systemc:74:0, from /home/lugia/Downloads/systemc-2.3.3//include/systemc.h:219, from hello.cpp:1: /home/lugia/Downloads/systemc-2.3.3//include/sysc/kernel/sc_module.h:397:5: error: expected ‘;’ before ‘struct’ struct user_module_name : ::sc_core::sc_module ^ hello.cpp:4:1: note: in expansion of macro ‘SC_MODULE’ SC_MODULE (hello_world) { ^~~~~~~~~ Makefile:109: recipe for target 'hello.o' failed make: *** [hello.o] Error 1 lugia@celebi:~/SystemC$ The error is as stated above. The code is as below. #include <systemc.h> using namespace std SC_MODULE (hello_world) { SC_CTOR (hello_world) { } void say_hello() { cout << "Hello World SystemC-2.3.1.\n"; } }; int sc_main(int argc, char* argv[]) { hello_world hello("HELLO"); hello.say_hello(); return(0); } and my make file is as follows SYSTEMC_HOME?=/home/lugia/Downloads/systemc-2.3.3/ TARGET_ARCH = linux64 FLAGS_COMMON = -g -Wall FLAGS_STRICT = -pedantic -Wno-long-long FLAGS_WERROR = -Werror PROJECT = hello #INCDIR = -I.\ # -I../usaTrackBusSimple OBJS = $(PROJECT).o ## default values for additional setup variables ifneq (,$(strip $(TARGET_ARCH))) ARCH_SUFFIX ?= -$(TARGET_ARCH) endif LDFLAG_RPATH ?= -Wl,-rpath= SYSTEMC_INC_DIR ?= $(SYSTEMC_HOME)/include SYSTEMC_LIB_DIR ?= $(SYSTEMC_HOME)/lib$(ARCH_SUFFIX) SYSTEMC_DEFINES ?= SYSTEMC_CXXFLAGS ?= $(FLAGS_COMMON) $(FLAGS_STRICT) $(FLAGS_WERROR) SYSTEMC_LDFLAGS ?= -L $(SYSTEMC_LIB_DIR) \ $(LDFLAG_RPATH)$(SYSTEMC_LIB_DIR) SYSTEMC_LIBS ?= -lsystemc -lm ## Add 'PTHREADS=1' to command line for a pthreads build ## (should not be needed in most cases) #ifdef PTHREADS #SYSTEMC_CXXFLAGS += -pthread -fPIC #SYSTEMC_LIBS += -lpthread #endif ## *************************************************************************** ## example defaults ## - basic configuration should be set from Makefile.config FILTER ?= cat INCDIR += -I. -I.. -I$(SYSTEMC_INC_DIR) LIBDIR += -L. -L.. CXXFLAGS += $(CFLAGS) $(SYSTEMC_CXXFLAGS) $(INCDIR) $(SYSTEMC_DEFINES) LDFLAGS += $(CFLAGS) $(SYSTEMC_CXXFLAGS) $(LIBDIR) $(SYSTEMC_LDFLAGS) LIBS += $(SYSTEMC_LIBS) $(EXTRA_LIBS) # "real" Makefile needs to set PROJECT ifeq (,$(strip $(PROJECT))) $(error PROJECT not set. Cannot build.) endif # basic check for SystemC directory ifeq (,$(wildcard $(SYSTEMC_HOME)/.)) $(error SYSTEMC_HOME [$(SYSTEMC_HOME)] is not present. \ Please update Makefile.config) endif ifeq (,$(wildcard $(SYSTEMC_INC_DIR)/systemc.h)) $(error systemc.h [$(SYSTEMC_INC_DIR)] not found. \ Please update Makefile.config) endif ifeq (,$(wildcard $(SYSTEMC_LIB_DIR)/libsystemc*)) $(error SystemC library [$(SYSTEMC_LIB_DIR)] not found. \ Please update Makefile.config) endif ## *************************************************************************** ## build rules .SUFFIXES: .cc .cpp .o .x GOLDEN?=$(firstword $(wildcard ../results/expected.log golden.log)) EXEEXT?=.x EXE := $(PROJECT)$(EXEEXT) all: announce build announce: @if test x1 = x$(FLAG_BATCH) ; then \ echo; echo "*** $(PROJECT):"; echo; \ fi check: announce all @if test -f "$(INPUT)" ; then INPUT="< $(INPUT)" ; fi ; \ eval "$(VALGRIND) ./$(EXE) $(ARGS) $${INPUT} > run.log" @cat run.log | grep -v "stopped by user" | \ $(FILTER) | awk '{if($$0!="") print $$0}' > run_trimmed.log @if test -f "$(GOLDEN)" ; then \ cat "$(GOLDEN)" | grep -v "stopped by user" | \ awk '{if($$0!="") print $$0}' > ./expected_trimmed.log ; \ diff ./run_trimmed.log ./expected_trimmed.log > diff.log 2>&1 ; \ if [ -s diff.log ]; then \ echo "***ERROR:"; cat diff.log; \ else echo "OK"; fi \ fi run: announce all @if test -f "$(INPUT)" ; then INPUT="< $(INPUT)" ; fi ; \ eval "./$(EXE) $(ARGS) $${INPUT}" build: announce $(EXE) $(EXE): $(OBJS) $(SYSTEMC_LIB_DIR)/libsystemc.a $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 2>&1 | c++filt @test -x $@ .cpp.o: $(CXX) $(CXXFLAGS) -c $< -o $@ .cc.o: $(CXX) $(CXXFLAGS) -c $< -o $@ clean:: announce rm -f $(OBJS) $(EXE) core $(EXTRA_CLEAN) \ run.log run_trimmed.log expected_trimmed.log diff.log ultraclean: announce clean rm -f Makefile.deps *~ #Makefile.deps: # $(CXX) $(CXXFLAGS) -M $(SRCS) >> Makefile.deps #include Makefile.deps
×
×
  • Create New...