Search the Community
Showing results for tags 'next_trigger'.
-
fsm FSM implementation in SystemC using SC_METHOD and next_trigger
ARI posted a topic in SystemC Language
Hello Everyone, I was trying to implement FSM in SystemC using SC_METHOD and next_trigger(). In the requirement it is mentioned i can't use SC_THREAD and static sensitivity (except reset_input). I am facing one problem here, which mentioned in screen-shot. In the attached screen-shot, whenever the current_state is FIRST then next_state could be SECOND, THIRED, and FOURTH (the priority of next_state is SECOND > THIRED > FOURTH). I am able to write a code using next_trigger when next_state is only one and not many. Here is the raw code: sc_in<bool> Reset_in; sc_in<bool> First_in ; sc_in<bool> Common_in; sc_in<bool> Second_in; sc_in<bool> Third_In; sc_in<bool> Fourth_in; SC_METHOD(FSMMethod) sensitive << Reset_in; async_reset_signal_is(Reset_in, false); dont_initialize(); void FSMMethod() { if (Reset_in == false) { current_state = RESET; next_trigger(); } else { switch (current_state) { case RESET: next_state = FIRST; next_trigger(First_in.posedge_event()); // now you can see when FSM is in RESET state then if First_in signal value become one //then FSM method will call again due to next_trigger and that time the next_state would be FIRST. break; case FIRST: // I am stuck here, if Common_in and Second_in signal true then next_state should be SECOND but the problem // is during the execution it will go inside the if block, if block not executed then next_trigger condtion // will not trigger the sc_method again and FSM will not in next_state. if (Common_in && Second_in) { next_state = SECOND; next_trigger(Common_in.value_changed_event() & Second_in.value_changed_event()); } else if (Common_in && Third_in) { next_state = THIRD; next_trigger(Common_in.value_changed_event() & Third_in.value_changed_event()); } else if (Common_in && Fourth_in) { next_state = FOURTH; next_trigger(Common_in.value_changed_event() & Fourth_in.value_changed_event()); } break } current_state = next_state; } } Hope i am able to put my question but if you guys need more clarification then please let me know. ultimatly i am not able to call FSMMethod beacuse next_trigger not executed in FIRST state, first we to have evalaute the transition condition then only next_trigger will execute. if in FIRST state if next_state were only one then it would be easy to use next_trigger (just in case we used in RESET to FIEST state) Please give me your valauble suggestions so it help to implement this FSM design. Thanks and Regards, ARI- 7 replies
-
- systemc
- next_trigger
-
(and 2 more)
Tagged with: