OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [socsim_plugin/] [rfctrl.cpp] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2017 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      RF front-end black-box model.
6
 */
7
 
8
#include "api_core.h"
9
#include "rfctrl.h"
10
 
11
namespace debugger {
12
 
13
RfController::RfController(const char *name)  : IService(name) {
14
    registerInterface(static_cast<IMemoryOperation *>(this));
15
 
16
    memset(&regs_, 0, sizeof(regs_));
17
}
18
 
19
RfController::~RfController() {
20
}
21
 
22
void RfController::postinitService() {
23
}
24
 
25
ETransStatus RfController::b_transport(Axi4TransactionType *trans) {
26
    uint64_t mask = (length_.to_uint64() - 1);
27
    uint64_t off = ((trans->addr - getBaseAddress()) & mask) / 4;
28
    trans->response = MemResp_Valid;
29
    if (trans->action == MemAction_Write) {
30
        for (uint64_t i = 0; i < trans->xsize/4; i++) {
31
            if ((trans->wstrb & (0xf << 4*i)) == 0) {
32
                continue;
33
            }
34
            switch (off + i) {
35
            case (0x2c >> 2):
36
                RISCV_info("Run channel %d", trans->wpayload.b32[i]);
37
                regs_.run = 0xf;    // simulate loading delay
38
                break;
39
            case (0x3c >> 2): //rw_ant_status
40
                regs_.rw_ant_status &= ~0x3;  //enable power ant1/2
41
                regs_.rw_ant_status |= trans->wpayload.b32[i];
42
                break;
43
            default:;
44
            }
45
        }
46
    } else {
47
        for (uint64_t i = 0; i < trans->xsize/4; i++) {
48
            switch (off + i) {
49
            case (0x2c >> 2): // run
50
                regs_.run >>= 1;
51
                trans->rpayload.b32[i] = regs_.run;
52
                break;
53
            case (0x3c >> 2): //rw_ant_status
54
                trans->rpayload.b32[i] = regs_.rw_ant_status;
55
                break;
56
            default:
57
                trans->rpayload.b32[i] = ~0;
58
            }
59
        }
60
    }
61
    return TRANS_OK;
62
}
63
 
64
}  // namespace debugger

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.