Dilip Kumar
Dilip Kumar

Reputation: 1746

error: No match to call the 'module'

I am not able to initialize or call full_adder module for combining multiple full_adder.

Getting error 
error: no match for call to ‘(full_adder) (sc_core::sc_signal_in_if<sc_dt::sc_uint<4> >*, sc_core::sc_signal_in_if<sc_dt::sc_uint<4> >*, sc_core::sc_signal<bool, (sc_core::sc_writer_policy)0u>&, sc_core::sc_signal_inout_if<sc_dt::sc_uint<4> >*, sc_core::sc_signal<bool, (sc_core::sc_writer_policy)0u>&)’
  (*fa0_ptr) (a[0],b[0], c0,sum[0],c0);

help is greatly appreciated.

Here is my sample code.

full_adder.h

SC_MODULE(full_adder)
{
        sc_in<bool> a,b, carry_in;
        sc_out<bool> sum, carry_out;

        sc_signal<bool> c1,s1,c2;
        void prc_or();
contd.......

fourbit_adder.h

#include "full_adder.h"

SC_MODULE(fourbit_adder)
{
        sc_in<sc_uint<4> > a,b;
        sc_in<bool> carry_in;
        sc_out<sc_uint<4> > sum;
        sc_out<bool> carry_out;



        sc_signal<bool> c0,c1,c2;
        void prc_or();
        full_adder *fa0_ptr, *fa1_ptr, *fa2_ptr, *fa3_ptr;

        SC_CTOR(fourbit_adder)
        {

        fa0_ptr = new full_adder("fa0"); // constructor operator which allocates and initialize the memory.
        //Positional association
        (*fa0_ptr) (a[0],b[0], c0,sum[0],c0);

Upvotes: 0

Views: 1067

Answers (2)

Jellybaby
Jellybaby

Reputation: 986

Firstly, yes you can cast int to bool but that is not really your issue. You are trying to connect signals and ports (or interfaces and channels) together. And although the channels carry int and bool, the channels themselves are of totally different types (for example sc_in<bool> and sc_signal< sc_int<99> > are of incompatible types).

The simplest solution is to just use an intermediate module to convert the signals. That is, one that takes an sc_int<W> and converts it to an array of W boolean signals (or vice versa). What I think you may be looking for is the sc_int_bitref class that can reference a bit with an sc_int or sc_uint.

Here is a quick but fully working example. The template class UintToBits module has one signal of type sc_uint and an array of bool signals. The module process is sensitive to the sc_uint signal and updates all the bool signals when triggered. You could take this to the n'th degree with template template classes (sc_int/sc_uint/sc_lv etc) but this is just a simple solution that should get you working.

template SC_MODULE(UintToBits){

typedef sc_uint<W>  UintType;   //type of sc_uint
sc_signal<UintType> uint_i;     //input signal sc_uint
sc_signal<bool>     bool_o[W];  //output signal W x bool

SC_CTOR(UintToBits){
    SC_METHOD(proc);        //setup conversion proc
    sensitive << uint_i;    //and kick it off when uint changes
}

void proc(){
    UintType value = uint_i;    //get the uint value
    for(int i = 0; i < W; ++i){ //for each bit in uint
        bool_o[i] = value[i];   //bool o/p sc_int_bitref[i]
    }
}

};

To demonstrate assume we have the class below that takes a single bit input.

//Some random module take takes a single bit input SC_MODULE(ModuleBit){

sc_in_clk clk_i;        //just to make it go
sc_in<bool> bool_i;     //bit input

SC_CTOR(ModuleBit){
    SC_METHOD(proc);    //a proc just to print out the bit
    sensitive << clk_i.pos();
    dont_initialize();
}

void proc(){ cout << bool_i; }  

};

And this block that outputs an sc_uint

//Some random module with data of sc_uint SC_MODULE(ModuleBitsW){

sc_in_clk clk_i;            //just to make it go
sc_out<UintType> uint_o;    //the sc_uint

SC_CTOR(ModuleBitsW){
    SC_METHOD(proc);        //proc just to change the output
    sensitive << clk_i.pos();
    uint_o.initialize(0);
    dont_initialize();
}

void proc(){
    uint_o = uint_o->read() + 1;    //output current value + 1
    cout << '\n'; //emit nl to make seperate bool modules o/ps
}

};

Then we can connect them together using the intermediary converter module.

int sc_main(int, char**){

const int W = 4; //Assume we have 4 bits
typedef UintToBits<W>::UintType UintType;


sc_clock clock("clock", 1.0, SC_SEC);   //randomly chosen one second period clock 

//create the sc_uint module, the bool modules and the converter module
UintToBits<W> convert("convert");   //converts sc_uint signal to W x bool signals
ModuleBitsW bitsw_m("bitsw_m");     //module with sc_uint output
ModuleBit* bit_m[W];                //W x modules needing single bit input

//connect the single bit modules
for(int i = 0; i < W; ++i){
    bit_m[i] = new ModuleBit(("m" + to_string(i)).c_str());
    bit_m[i]->bool_i(convert.bool_o[W-i-1]);    //reverse them to print 'normally' (not guaranteed)
    bit_m[i]->clk_i(clock);
}
bitsw_m.uint_o(convert.uint_i); //connect output of sc_uint module to converter module
bitsw_m.clk_i(clock);           //just to drive it


sc_start(20.0, SC_SEC);     //run it for 20 cycles and see what we get
return 0;

//let process clear up memory am too lazy }

Which when I ran it gave the output 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0000 0001 0010 0011

I used these includes <systemc>, <iostream> and imported these namespaces sc_core, sc_dt, std and compiled with g++ -std=c++11 FullAdder.cpp -lsystemc with gcc 4.9.2` on linux64

This should get you past your problem for now but if you expect to be doing a lot of serial-parallel conversions it might be worth your while designing a small set of templates (or more likely template-template classes). And finally don't forget the very useful sc_int_bitref returned from sc_int[] operator but you'll need a signal (not just a bool or int) to get change notifications to drive processes.

Upvotes: 1

Kurt Stutsman
Kurt Stutsman

Reputation: 4034

You are passing sum[0] as the 4th argument in (*fa0_ptr) (a[0],b[0], c0,sum[0],c0) which is of type sc_uint but the 4th member of full_adder is of type bool.

Upvotes: 0

Related Questions