Jump to content

Recommended Posts

Hello there,

I've been trying to create a vcd file which helps me study the waveform of a 2 by 4 decoder. But, when I try to open the file "decoder.vcd" , it tells me that there is no such file or directory [ on Ubuntu 14.0.4  ].

 

//File: decoder_top.cpp

#include "driver.h"                                 //module that drives DUT
#include "monitor.h"                              //module that monitors DUT
#include "2_by_4_decoder.h"               //module that contains the info of the ports of DUT

int sc_main(int argc, char* argv[])
{
sc_signal<bool> t_select, t_enable, t_z;

sc_trace_file *wf = sc_create_vcd_trace_file("decoder");
wf->set_time_unit(1, SC_NS);


decoder2by4 dcdr("2by4decoder");
dcdr<<t_enable <<t_select <<t_z;

driver d1("GenerateWaveforms");

d1.d_select(t_select);
d1.d_enable(t_enable);
//d1.d_cin(t_cin);

monitor mo1 ("MonitorWaveforms");
mo1<< t_select << t_enable << t_z;

sc_trace(wf, t_select, "t_select");
sc_trace(wf, t_enable, "t_enable");
sc_trace(wf, t_z, "t_z");


sc_start(100, SC_NS);

sc_stop();

sc_close_vcd_trace_file(wf);


return(0);
}


Please help me solve this issue.

Thanks in advance!

Share this post


Link to post
Share on other sites

Hello there, 

@Gerth, I guess am facing this issue , because few errors pop up while I try to run the executable. The object files have been generated without any flaws. 

Please correct me if am wrong.

Share this post


Link to post
Share on other sites

Hi kihtrak,

 

the issue is right in the first few lines of your screenshot:

d1.d_select(t_select);

d_select is of type sc_out<bool> and t_select of type sc_signal<sc_uint<2>> which means you can't connect them because they have different data types (connecting an sc_out to an sc_signal is not the issue here). So you can either change the type of one of those or fit a converter in if you can't do that for some reason.

Share this post


Link to post
Share on other sites

Hi Gerth, 

 

I've made changes as told by you. One more error pops up like this . while trying to run the executable.

 

Info: (I703) tracing timescale unit set: 1 ns (decoder.vcd)
 
Error: (E109) complete binding failed: port not bound: port 'GenerateWaveform.port_2' (sc_out)
In file: ../../../../src/sysc/communication/sc_port.cpp:231
 
I've already posted the top module, let me post the rest:
 
/File:driver.h
 
#include "systemc.h"
 
SC_MODULE (driver)
{
sc_out<bool> d_enable ;
sc_out<sc_uint<2> > d_select; 
//sc_out<sc_uint<4> > d_z;  
 
 
sc_uint<2> pattern;
 
void prc_driver(); 
 
SC_CTOR(driver)
{
SC_THREAD (prc_driver) ;
sensitive<< d_enable<< d_select;
}
};
 
 
 
//File: driver.cpp
 
#include "driver.h"
 
void driver::prc_driver()
{
sc_uint<2> pattern; 
pattern = 0; 
 
bool temp_enable; 
 
temp_enable = 0;  
 
while(1)
{
 
temp_enable!= temp_enable; 
 
wait(); 
 
d_enable.write(temp_enable); 
 
while (temp_enable)
{
d_select.write(pattern); 
d_enable.write(temp_enable);
//d_cin = pattern[2]; 
wait (5, SC_NS); 
pattern++; 
 
 
 
temp_enable!= temp_enable; 
 
}
 
}
}
 
 
//File : 2-by-4 decoder.h
 
 
#include "systemc.h"
 
SC_MODULE(decoder2by4)
 
{
 
sc_in<bool>enable; 
sc_in<sc_uint<2> > select; 
sc_out<sc_uint<4> > z; 
 
void prc_decoder2by4(); 
 
SC_CTOR(decoder2by4)
{
SC_METHOD(prc_decoder2by4); 
sensitive<<enable<<select; 
}
}; 
 
 
//File: monitor.h
 
#include"systemc.h"
 
SC_MODULE (monitor)
{
sc_in<bool> m_enable;
sc_in<sc_uint<2> > m_select;
sc_in<sc_uint<4> > m_z;   
 
void prc_monitor (); 
 
 
SC_CTOR(monitor)
{
SC_METHOD (prc_monitor); 
sensitive << m_enable << m_select<<m_z;  
}
}; 
 
Please help me solve this issue!
Thanks in advance
 
[Also I've another question: In the top module, do I have to include any "arguments" like - driver d1 ("GenerateWaveforms"); ? If I don't it gives some errors. Please help me understand why is that so.]

Share this post


Link to post
Share on other sites

Hi kihtrak,

 

I tried to compile your code to reproduce the message but that was not possible. After changing some types and positional port binding so that it compiled and started I could not produce your message at runtime. Please post your complete current code if you need help there. Regarding your second question: Yes, you are required to provide a name argument to your module instances. The technical background is, that there is no empty constructor defined but one with that name argument via the CTOR pre-processor macro.

Share this post


Link to post
Share on other sites

Hello Gerth, 

 

I get the idea behind defining the argument for instances. Thanks!

 

Let me post the complete code of mine:

 

//File : 2-by-4 decoder.h
 
 
#include "systemc.h"
 
SC_MODULE(decoder2by4)
 
{
 
sc_in<bool>enable; 
sc_in<sc_uint<2> > select; 
sc_out<sc_lv<4> > z; 
 
void prc_decoder2by4(); 
 
SC_CTOR(decoder2by4)
{
SC_METHOD(prc_decoder2by4); 
sensitive<<enable<<select; 
}
}; 
 
//File: decoder2by4.cpp
 
#include"2_by_4_decoder.h"
 
void decoder2by4::prc_decoder2by4()
{
if(enable)
{
switch(select.read())
{
case 0: z = 0001;  break;
case 1: z= 0010; break; 
case 2: z= 0100; break;
case 3: z= 1000; break; 
}
}
else
z = 1111; 
}
 
 
//File: decoder_top.cpp
 
#include "driver.h"
#include "monitor.h"
#include "2_by_4_decoder.h"
 
 
int sc_main(int argc, char* argv[])
{
sc_signal<bool>  t_enable; 
sc_signal<sc_uint<2> > t_select; 
sc_signal<sc_lv<4> > t_z; 
 
sc_trace_file *wf = sc_create_vcd_trace_file("decoder"); 
wf->set_time_unit(1, SC_NS); 
 
 
decoder2by4 dcdr("2by4decodr"); 
dcdr.enable(t_enable);
dcdr.select(t_select); 
dcdr.z(t_z); 
 
 
driver dr("GenerateWaveform"); 
dr.d_select(t_select); 
dr.d_enable(t_enable); 
 
 
monitor mo1 ("MonitorWaveforms"); 
mo1.m_select(t_select); 
mo1.m_enable(t_enable);
mo1.m_z(t_z); 
 
sc_trace(wf, t_select, "t_select"); 
sc_trace(wf, t_enable, "t_enable"); 
sc_trace(wf, t_z, "t_z"); 
 
 
sc_start(100, SC_NS); 
 
sc_stop(); 
 
sc_close_vcd_trace_file(wf);
 
 
return(0); 
}
 
 
//File: driver.cpp
 
 
#include "driver.h"
 
void driver::prc_driver()
{
sc_uint<2> pattern; 
pattern = 0; 
 
bool temp_enable; 
 
temp_enable = 0;  
 
while(1)
{
 
temp_enable!= temp_enable; 
 
wait(); 
 
d_enable.write(temp_enable); 
 
while (temp_enable)
{
d_select.write(pattern); 
d_enable.write(temp_enable);
//d_cin = pattern[2]; 
wait (5, SC_NS); 
pattern++; 
 
 
 
temp_enable!= temp_enable; 
 
}
 
}
}
 
//File:driver.h
 
#include "systemc.h"
 
SC_MODULE (driver)
{
sc_out<bool> d_enable ;
sc_out<sc_lv<2> > d_select; 
//sc_out<sc_uint<4> > d_z;  
 
 
sc_uint<2> pattern;
 
void prc_driver(); 
 
SC_CTOR(driver)
{
SC_THREAD (prc_driver) ;
sensitive<< d_enable<< d_select;
}
};
 
 
//File : monitor.cpp
 
 #include "monitor.h"
 
void monitor::prc_monitor()
{
cout<<"At time"<<sc_time_stamp()<<"::";
cout<<" (select, enable) "; 
cout<<m_select<<m_enable; 
cout<<"output is "<<m_z<<endl; 
}
 
 
/File: monitor.h
 
#include"systemc.h"
 
SC_MODULE (monitor)
{
sc_in<bool> m_enable;
sc_in<sc_uint<2> > m_select;
sc_in<sc_lv<4> > m_z;   
 
void prc_monitor (); 
 
 
SC_CTOR(monitor)
{
SC_METHOD (prc_monitor); 
sensitive << m_enable << m_select<<m_z;  
}
}; 
 

 

Please help me correct the errors. 

Thanks in advance.

Share this post


Link to post
Share on other sites

Hello Gerth, 

Am sorry for bugging you a lot! 

Am still getting the same error, if I just change the type d_select port in the driver module from sc_lv to sc_uint. 

 

I've also attached the Makefile. Please help me sort this out. 

 

 
SYSTEMC=/usr/local/systemc231
ARCH=linux64
 
CPP_FLAGS= -I. -I$(SYSTEMC)/include
LDFLAGS=-L$(SYSTEMC)/lib-linux64 -lsystemc
 
SRC= decoder2by4.cpp decoder_top.cpp  monitor.cpp driver.cpp
OBJS= decoder2by4.o decoder_top.o  driver.o monitor.o
 
 
all: 2by4decoder
 
decoder_top.o:  decoder_top.cpp
g++ $(CPP_FLAGS) -c decoder_top.cpp 
 
decoder2by4.o:  decoder2by4.cpp
g++ $(CPP_FLAGS) -c decoder2by4.cpp 
 
driver.o:  driver.cpp
g++ $(CPP_FLAGS) -c driver.cpp 
 
monitor.o:  monitor.cpp
g++ $(CPP_FLAGS) -c monitor.cpp 
 
 
2by4decoder: $(OBJS)  
g++ $(LDFLAGS) -o 2by4decoder $(OBJS)
 
 
The commands I entered (in the terminal): 
1. make
2. ./2by4decoder  (to run the executable )
 
Thanks a lot for your patience! 

Share this post


Link to post
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...