documentation

This commit is contained in:
mariusmonton 2019-01-13 18:39:35 +01:00
parent 64030a7cc3
commit 7c263419a8
3 changed files with 28 additions and 25 deletions

View File

@ -27,6 +27,7 @@ Brief description of the modules:
* Simulator: Top-level entity that builds & starts the simulation
* BusCtrl: Simple bus manager
* Trace: Simple trace peripheral
* Timer: Simple IRQ programable real-time counter peripheral
Helper classes:
* 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:
```
$ cd asm
$ riscv32-unknown-linux-gnu-as EternalLoop.asm -o EternalLoop.o
$ riscv32-unknown-linux-gnu-ld -T ../my_linker_script.ld EternalLoop.o -o EternalLoop.elf
$ objcopy -O ihex EternalLoop.elf EternalLoop.hex
$ riscv32-unknown-elf-as EternalLoop.asm -o EternalLoop.o
$ riscv32-unknown-elf-ld -T ../my_linker_script.ld EternalLoop.o -o EternalLoop.elf
$ riscv32-unknown-elf-objcopy -O ihex EternalLoop.elf EternalLoop.hex
$ cd ..
$ ./RISCV_SCTLM asm/EternalLoop.hex
```

View File

@ -36,19 +36,36 @@ public:
tlm_utils::simple_target_socket<Timer> socket;
sc_out<bool> timer_irq;
// Constructor
/**
*
* @brief Constructor
* @param name module 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();
// 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 );
private:
sc_uint<64> m_mtime;
sc_uint<64> m_mtimecmp;
sc_event timer_event;
bool irq_value;
sc_uint<64> m_mtime; /**< mtime register */
sc_uint<64> m_mtimecmp; /**< mtimecmp register */
sc_event timer_event; /**< event */
};
#endif

View File

@ -2,22 +2,16 @@
SC_HAS_PROCESS(Timer);
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);
SC_THREAD(run);
}
/**
* @brief Waits for event timer_event and triggers an IRQ
*
*/
void Timer::run() {
while(true) {
// timer_event.notify( sc_time(10000, SC_NS) );
wait(timer_event);
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 ) {
tlm::tlm_command cmd = trans.get_command();
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;
// notify needs relative time, mtimecmp works in absolute time
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) );
break;
}