// example 9 <' type bus_state_t : [busy, idle, waiting, error]; struct bus { // These are the interface or 'public' methods and fields. They are not prefixed // with anything since 'public' access level is the default reset()@clk_sys is { // "reset" can be called from other structs like the data driver or the CPU model. 'reset_bus' = '0'; // drive '0' to the reset pin 'reset bus' wait 3*cycle; // wait 3 'clk_sys' cycles for reset to finish state = idle; // "state" is a private struct member (see below). Therefore other users can not access it directly. }; bus_state_t get_state() is { //To get the current state, users from other structs must call "get_state()" since state is private // and they can not access it directly. return state; }; send_data (l: list of bit)@clk_sys is { // send data calls some private TCMs that take care of actually sending the data. if check_data(l) { signal_data_start(); drive_data(l); signal_data_end(); }; }; // Below are the private methods and fields. Nobody is supposed to use them except the owner of the struct. private state : bus_state_t; // other structs can change "state" or see its value only through "reset()" or "get_bus_state()" keep state == idle; // All the methods below are hidden from other users. They can not use them or they will get a compilation error. private bool check_data (l: list of bit) is { //... }; private signal_data_start () is { //... }; private drive_data (l: list of bit) is { //... }; private signal_data_end (l: list of bit) is { //... }; }; '>