documentation
This commit is contained in:
parent
64030a7cc3
commit
7c263419a8
|
@ -27,6 +27,7 @@ Brief description of the modules:
|
||||||
* Simulator: Top-level entity that builds & starts the simulation
|
* Simulator: Top-level entity that builds & starts the simulation
|
||||||
* BusCtrl: Simple bus manager
|
* BusCtrl: Simple bus manager
|
||||||
* Trace: Simple trace peripheral
|
* Trace: Simple trace peripheral
|
||||||
|
* Timer: Simple IRQ programable real-time counter peripheral
|
||||||
|
|
||||||
Helper classes:
|
Helper classes:
|
||||||
* Performance: Performance indicators stores here (singleton class)
|
* Performance: Performance indicators stores here (singleton class)
|
||||||
|
@ -90,9 +91,9 @@ In the asm directory there are some basic assembly examples.
|
||||||
I "compile" one file with the follwing command:
|
I "compile" one file with the follwing command:
|
||||||
```
|
```
|
||||||
$ cd asm
|
$ cd asm
|
||||||
$ riscv32-unknown-linux-gnu-as EternalLoop.asm -o EternalLoop.o
|
$ riscv32-unknown-elf-as EternalLoop.asm -o EternalLoop.o
|
||||||
$ riscv32-unknown-linux-gnu-ld -T ../my_linker_script.ld EternalLoop.o -o EternalLoop.elf
|
$ riscv32-unknown-elf-ld -T ../my_linker_script.ld EternalLoop.o -o EternalLoop.elf
|
||||||
$ objcopy -O ihex EternalLoop.elf EternalLoop.hex
|
$ riscv32-unknown-elf-objcopy -O ihex EternalLoop.elf EternalLoop.hex
|
||||||
$ cd ..
|
$ cd ..
|
||||||
$ ./RISCV_SCTLM asm/EternalLoop.hex
|
$ ./RISCV_SCTLM asm/EternalLoop.hex
|
||||||
```
|
```
|
||||||
|
|
29
inc/Timer.h
29
inc/Timer.h
|
@ -36,19 +36,36 @@ public:
|
||||||
tlm_utils::simple_target_socket<Timer> socket;
|
tlm_utils::simple_target_socket<Timer> socket;
|
||||||
sc_out<bool> timer_irq;
|
sc_out<bool> timer_irq;
|
||||||
|
|
||||||
// Constructor
|
/**
|
||||||
|
*
|
||||||
|
* @brief Constructor
|
||||||
|
* @param name module name
|
||||||
|
*/
|
||||||
Timer(sc_module_name name);
|
Timer(sc_module_name name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Waits for event timer_event and triggers an IRQ
|
||||||
|
*
|
||||||
|
* Waits for event timer_event and triggers an IRQ (if it is not already
|
||||||
|
* triggered).
|
||||||
|
* After that, it posts the timer_event to 20 ns in the future to clear the IRQ
|
||||||
|
* line.
|
||||||
|
*
|
||||||
|
*/
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
// TLM-2 blocking transport method
|
/**
|
||||||
|
*
|
||||||
|
* @brief TLM-2.0 socket implementaiton
|
||||||
|
* @param trans TLM-2.0 transaction
|
||||||
|
* @param delay transactino delay time
|
||||||
|
*/
|
||||||
virtual void b_transport( tlm::tlm_generic_payload& trans, sc_time& delay );
|
virtual void b_transport( tlm::tlm_generic_payload& trans, sc_time& delay );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sc_uint<64> m_mtime;
|
sc_uint<64> m_mtime; /**< mtime register */
|
||||||
sc_uint<64> m_mtimecmp;
|
sc_uint<64> m_mtimecmp; /**< mtimecmp register */
|
||||||
sc_event timer_event;
|
sc_event timer_event; /**< event */
|
||||||
bool irq_value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,22 +2,16 @@
|
||||||
|
|
||||||
SC_HAS_PROCESS(Timer);
|
SC_HAS_PROCESS(Timer);
|
||||||
Timer::Timer(sc_module_name name): sc_module(name)
|
Timer::Timer(sc_module_name name): sc_module(name)
|
||||||
,socket("timer_socket"), m_mtime(0), m_mtimecmp(0), irq_value(false) {
|
,socket("timer_socket"), m_mtime(0), m_mtimecmp(0) {
|
||||||
|
|
||||||
socket.register_b_transport(this, &Timer::b_transport);
|
socket.register_b_transport(this, &Timer::b_transport);
|
||||||
|
|
||||||
SC_THREAD(run);
|
SC_THREAD(run);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Waits for event timer_event and triggers an IRQ
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void Timer::run() {
|
void Timer::run() {
|
||||||
while(true) {
|
while(true) {
|
||||||
|
|
||||||
// timer_event.notify( sc_time(10000, SC_NS) );
|
|
||||||
|
|
||||||
wait(timer_event);
|
wait(timer_event);
|
||||||
|
|
||||||
if (timer_irq.read() == true) {
|
if (timer_irq.read() == true) {
|
||||||
|
@ -32,12 +26,6 @@ void Timer::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @brief TLM-2.0 socket implementaiton
|
|
||||||
* @param trans TLM-2.0 transaction
|
|
||||||
* @param delay transactino delay time
|
|
||||||
*/
|
|
||||||
void Timer::b_transport( tlm::tlm_generic_payload& trans, sc_time& delay ) {
|
void Timer::b_transport( tlm::tlm_generic_payload& trans, sc_time& delay ) {
|
||||||
tlm::tlm_command cmd = trans.get_command();
|
tlm::tlm_command cmd = trans.get_command();
|
||||||
sc_dt::uint64 addr = trans.get_address();
|
sc_dt::uint64 addr = trans.get_address();
|
||||||
|
@ -66,9 +54,6 @@ void Timer::b_transport( tlm::tlm_generic_payload& trans, sc_time& delay ) {
|
||||||
m_mtimecmp.range(63,32) = aux_value;
|
m_mtimecmp.range(63,32) = aux_value;
|
||||||
// notify needs relative time, mtimecmp works in absolute time
|
// notify needs relative time, mtimecmp works in absolute time
|
||||||
notify_time = m_mtimecmp - m_mtime;
|
notify_time = m_mtimecmp - m_mtime;
|
||||||
// cout << "time: " << sc_core::sc_time_stamp()
|
|
||||||
// << ": interrupt will be in " << dec << notify_time
|
|
||||||
// << " ns" << endl;
|
|
||||||
timer_event.notify( sc_time(notify_time, SC_NS) );
|
timer_event.notify( sc_time(notify_time, SC_NS) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue