1
0
rocket-chip/csrc/htif_emulator.h
Palmer Dabbelt db9de94588 Generate and use SCR address header files
This uses the new SCRFile changes to generate a header file containing a list
of all the SCRs in a core to remove the magic constant "63" (the HTIF clock
divider control register) and replace it with a generated number (which is
still 63).
2016-02-17 15:23:18 -08:00

38 lines
721 B
C++

// See LICENSE for license details.
#ifndef _HTIF_EMULATOR_H
#define _HTIF_EMULATOR_H
#include <fesvr/htif_pthread.h>
class htif_emulator_t : public htif_pthread_t
{
public:
htif_emulator_t(uint32_t memsz_mb, const std::vector<std::string>& args)
: htif_pthread_t(args)
{
this->_memsz_mb = memsz_mb;
}
void set_clock_divisor(int divisor, int hold_cycles)
{
write_cr(-1, UNCORE_SCR__HTIF_IO_CLOCK_DIVISOR, divisor | hold_cycles << 16);
}
void start()
{
set_clock_divisor(5, 2);
htif_pthread_t::start();
}
uint32_t mem_mb() {
uint32_t scr_mb = htif_pthread_t::mem_mb();
return (_memsz_mb < scr_mb) ? _memsz_mb : scr_mb;
}
private:
uint32_t _memsz_mb;
};
#endif