NicoCaldo Posted June 6, 2020 Report Share Posted June 6, 2020 I was wondering if it's possible to create a module that given as input an sc_vector<sc_in<bool> > containing a known number of sc_in<bool> (let's say 2) it would convert into a sc_out<sc_uint<2> > Quote Link to comment Share on other sites More sharing options...
Eyck Posted June 6, 2020 Report Share Posted June 6, 2020 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; } }; David Black 1 Quote Link to comment Share on other sites More sharing options...
NicoCaldo Posted June 7, 2020 Author Report Share Posted June 7, 2020 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 Quote Link to comment Share on other sites More sharing options...
Eyck Posted June 16, 2020 Report Share Posted June 16, 2020 That is a typo as the method() function shows. it Should read sc_out<sc_uint<2> > Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.