Пример #1
0
Vga::Vga(sc_core::sc_module_name name) :
	sc_core::sc_module(name), address(0), intr(false)
{
	SC_THREAD(thread);

	if(SDL_Init(SDL_INIT_VIDEO) < 0) {
		SC_REPORT_FATAL(sc_module::name(), SDL_GetError());
	}

	atexit(SDL_Quit);

	SDL_SetEventFilter(filter);

	screen = SDL_SetVideoMode(VGA_WIDTH, VGA_HEIGHT, 16,
				  SDL_DOUBLEBUF | SDL_HWSURFACE);

	if(screen->format->BytesPerPixel != 2) {
		SC_REPORT_FATAL(sc_module::name(), SDL_GetError());
	}

	black = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
	white = SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF);

	SDL_WM_SetCaption(sc_module::name(), NULL);

#ifdef DEBUG
	std::cout << "Debug: " << sc_module::name() <<
		": LCD controller TLM model\n";
#endif
}
Пример #2
0
void uvm_phase_controller::do_prerun(void) {

    std::string          phase_name;
    std::ostringstream   outmsg;
    uvm_phase_state state;
    uvm_phase *     pcurrent_phase = m_pcommon_schedule->get_current_phase();

    // Note:  Get all tops as pure sc_modules, in case they have uvm_comp children
    std::vector<sc_core::sc_module *> all_tops = uvm_get_tops();
    //int result;


    if (pcurrent_phase == NULL)
    {
        SC_REPORT_FATAL(UVM_PHASE_CTRL_PHASE_UNSPECIFIED,"");
        exit(1);
    }
    if(pcurrent_phase->get_phase_type() != UVM_PRERUN_PHASE) 
    {
        outmsg << pcurrent_phase->get_name() << endl;
        SC_REPORT_FATAL(UVM_PHASE_CTRL_PHASE_TYPE,outmsg.str().c_str());
        exit(1);
    }

    //  Loop over pre-run phases
    while((pcurrent_phase != NULL) &&(pcurrent_phase->get_phase_type() == UVM_PRERUN_PHASE))
    {
        phase_name = pcurrent_phase->get_name();
        state = pcurrent_phase->get_phase_state();

        // Loop over states per phase
        while(state != UVM_PHASE_DONE)
        {
            // For SystemC phases, call once per phase/state
            // TODO - check 'result' for errors (1=OK, 0=error)
            //result = m_pcommon_schedule->execute_quasi_static_phase(phase_name, state); 
            m_pcommon_schedule->execute_quasi_static_phase(phase_name, state); 

            for (unsigned int i = 0; i < all_tops.size(); i++)
            {
               m_pcommon_schedule->execute_nonruntime_phase(all_tops[i]);  // setting the phase state
               // TODO:  Any results to check here?
            }
            state = m_pcommon_schedule->update_phase_state();
        }
        pcurrent_phase = m_pcommon_schedule->get_current_phase();
    }

    // TODO - check for fatal errors here (try/catch?)
    //        Note:  Needs to work in ML as well...
}
Пример #3
0
	void thread()
	{
		sc_report_handler::set_actions(SC_FATAL,SC_DISPLAY);
		sc_report_handler::stop_after(SC_FATAL,-1);
		for (;;)
		{
			wait();
			SC_REPORT_FATAL("Oh no!","A bad thing has happened");
		}
	}
Пример #4
0
void uvm_phase_controller::do_postrun(void) 
{
    std::string     phase_name;
    std::ostringstream   outmsg;
    uvm_phase_state state;
    puvm_phase      pcurrent_phase = m_pcommon_schedule->get_current_phase();

    // Note:  Get all tops including pure sc_modules, in case they have uvm_comp children
    std::vector<sc_core::sc_module *> all_tops = uvm_get_tops();


    // Set common schedule to first postrun phase (ie. 'extract')
    // Note:  set to the first postrun phase after 'run' phase;
    //        accounts for cases where run phase terminates early due to timeout or errors 
    pcurrent_phase = m_pcommon_schedule->get_phase("extract");      // first postrun phase after run

    if (pcurrent_phase == NULL)
    {
        SC_REPORT_INFO(UVM_PHASE_CTRL_POST_RUN_NONE,"");
        return;     // No post-run schedules to execute
    }
    if(pcurrent_phase->get_phase_type() != UVM_POSTRUN_PHASE) 
    {
        outmsg << pcurrent_phase->get_name() << endl;
        SC_REPORT_FATAL(UVM_PHASE_CTRL_PHASE_TYPE,outmsg.str().c_str());
        exit(1);
    }
    m_pcommon_schedule->set_current_phase(pcurrent_phase);


    //  Loop over post-run phases
    while((pcurrent_phase != NULL) &&(pcurrent_phase->get_phase_type() == UVM_POSTRUN_PHASE))
    {
        phase_name = pcurrent_phase->get_name();
        state = pcurrent_phase->get_phase_state();

        while(state != UVM_PHASE_DONE)
        {
            for (unsigned int i = 0; i < all_tops.size(); i++)
            {
               m_pcommon_schedule->execute_nonruntime_phase(all_tops[i]);  // setting the phase state
               // TODO:  Any results to check here?
            }
            state = m_pcommon_schedule->update_phase_state();
        }
        pcurrent_phase = m_pcommon_schedule->get_current_phase();
    }

    // TODO - check for fatal errors here (try/catch?)
    //        Note:  Needs to work in ML as well...
}
Пример #5
0
    void peq_cb(tlm::tlm_generic_payload& trans, const tlm::tlm_phase& phase){
        tlm::tlm_sync_enum status;
        sc_time delay;

        switch (phase){
            case tlm::BEGIN_REQ:
                status = send_end_req(trans);
            break;

            case tlm::END_RESP:
                //std::cerr << "tlm::END_RESP in memory peq_cb" << std::endl;
                this->transactionInProgress = false;
                this->transactionCompleted.notify();
            break;

            case tlm::END_REQ:
            case tlm::BEGIN_RESP:
                SC_REPORT_FATAL("TLM-2", "Illegal transaction phase received by target");
            break;

            default:
                if (phase == internal_ph){
                    // Execute the read or write commands
                    tlm::tlm_command cmd = trans.get_command();
                    sc_dt::uint64    adr = trans.get_address();
                    unsigned char*   ptr = trans.get_data_ptr();
                    unsigned int     len = trans.get_data_length();

                    if(cmd == tlm::TLM_READ_COMMAND){
                        for(int i = 0; i < len; i++, ptr++)
                            *ptr = this->mem[adr + i];
                    }
                    else if(cmd == tlm::TLM_WRITE_COMMAND){
                        for(int i = 0; i < len; i++, ptr++)
                            this->mem[adr + i] = *ptr;
                    }


                    trans.set_response_status(tlm::TLM_OK_RESPONSE);

                    // Target must honor BEGIN_RESP/END_RESP exclusion rule
                    // i.e. must not send BEGIN_RESP until receiving previous END_RESP or BEGIN_REQ
                    send_response(trans);
                    //std::cerr << "Memory reading address in memory " << std::hex << std::showbase << adr << std::endl;
                }
            break;
        }
    }
Пример #6
0
//------------------------------------------------------------------------------
// Function: process_state_executing_nonruntime
//
// Parameters:
//------------------------------------------------------------------------------
void uvm_common_phase::process_state_executing_nonruntime(sc_core::sc_module *pmod)
{
    std::ostringstream outmsg;

    if (get_phase_type() != UVM_POSTRUN_PHASE) { // postrun phases are not generalized yet
        int result = do_execute(pmod);

        if (result && (CHECK_STOP_AT_PHASE_END() == true)) {
            SC_REPORT_INFO(UVM_PHASE_CTRL_STOP_USER, "");
#ifdef UVM_ML_PORTABLE
            // TODO - should be be incorporated into the phase controller instead?
            sc_get_curr_simcontext()->stop();
#endif
	    //  result = 0;
        }
    }
    else {
        uvm_component* pcomp = DCAST<uvm_component*>(pmod); 
        if (pcomp != NULL) {
            if (_name.compare("final") == 0)
                pcomp->final_phase(this);
            else if (_name.compare("extract") == 0)
                pcomp->extract_phase(this);
            else if (_name.compare("check") == 0)
                pcomp->check_phase(this);
            else if (_name.compare("report") == 0)
                pcomp->report_phase(this);
            else
            {
                outmsg << _name << endl;
                SC_REPORT_FATAL(UVM_PHASE_UNKNOWN, outmsg.str().c_str());
                exit(1);        // TODO - is 'exit()' needed here after a FATAL?
            }
        }
    }
}