Jump to content

Module that convert an sc_vector input into sc_signal


Recommended Posts

Sure. Just add a method reading all bool sc_in and write to the output. You need to make it sensitive to all inputs Something like:

SC_MODULE(conv){
    sc_vector<sc_in<bool> > input{"input"};
    sc_out<bool> ouput{"ouput"};

    SC_CTOR(conv){
        SC_HAS_PROCESS(conv);
        SC_METHOD(method);
        for(auto& in: input){
            sensitive<<in;
        }
    }

    void method(){
        unsigned res = input[1]?2:0+input[0]?1:0;
        output=res;
    }
};

 

Link to post
Share on other sites
12 hours ago, Eyck said:

Sure. Just add a method reading all bool sc_in and write to the output. You need to make it sensitive to all inputs Something like:


SC_MODULE(conv){
    sc_vector<sc_in<bool> > input{"input"};
    sc_out<bool> ouput{"ouput"};

    SC_CTOR(conv){
        SC_HAS_PROCESS(conv);
        SC_METHOD(method);
        for(auto& in: input){
            sensitive<<in;
        }
    }

    void method(){
        unsigned res = input[1]?2:0+input[0]?1:0;
        output=res;
    }
};

 

Thanks a lot but, your code use a bool as output.

I need to put together all the bool line in input as one line in output.

For istance if I have a vector of 2 bool input I want to took the two bit (i.e. a and b) and convert into a sc_uint<2> in out a*2^1+b*2^0

with 3 input, a,b, and c it would be a sc_uint<3> with a*2^2+b*2^1+c*2^0 and so on

Link to post
Share on other sites
  • 2 weeks later...

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...