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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [socsim_plugin/] [fsev2.cpp] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2017 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      Fast Search Engnine (FSE) black-box model.
6
 */
7
 
8
#include "api_core.h"
9
#include "fsev2.h"
10
 
11
namespace debugger {
12
 
13
static const uint32_t FSE2_CONTROL_ENA      = (1 << 31);  // 0=disable; 1=enable
14
static const uint32_t FSE2_CONTROL_ADC      = (1 << 30);  // 0=bin offset; 1=sign/magn
15
static const uint32_t FSE2_STATE_NXT_DOPLER = (1 << 21);
16
static const uint32_t FSE2_STATE_PROCESSING = (1 << 20);
17
static const uint32_t FSE2_STATE_SELCHAN    = (1 << 19);
18
static const uint32_t FSE2_STATE_WRITING    = (1 << 18);
19
static const uint32_t FSE2_STATE_WAIT_MS    = (1 << 17);
20
static const uint32_t FSE2_STATE_IDLE       = (1 << 16);
21
 
22
FseV2::FseV2(const char *name)  : IService(name) {
23
    registerInterface(static_cast<IMemoryOperation *>(this));
24
    registerAttribute("BaseAddress", &baseAddress_);
25
    registerAttribute("Length", &length_);
26
 
27
    baseAddress_.make_uint64(0);
28
    length_.make_uint64(0);
29
 
30
    memset(&regs_, 0, sizeof(regs_));
31
    regs_.hw_id = (16 << 16) | 5;   // 16 msec accum, 5=id
32
    for (int i = 0; i < FSE2_CHAN_MAX; i++) {
33
        regs_.chan[i].dopler = 1000 << 4;
34
        regs_.chan[i].noise = 1872 << 12;
35
        regs_.chan[i].ind = 100 + i;
36
    }
37
    // Check float comparision with threshold (=2.1*noise):
38
    regs_.chan[14].max = static_cast<uint32_t>(1872.0 * 2.11);
39
    regs_.chan[15].max = static_cast<uint32_t>(1872.0 * 2.09);
40
}
41
 
42
void FseV2::b_transport(Axi4TransactionType *trans) {
43
    uint64_t mask = (length_.to_uint64() - 1);
44
    uint64_t off = ((trans->addr - getBaseAddress()) & mask);
45
    trans->response = MemResp_Valid;
46
    if (trans->action == MemAction_Write) {
47
        memcpy(&reinterpret_cast<uint8_t *>(&regs_)[off], trans->wpayload.b8,
48
                trans->xsize);
49
    } else {
50
        memcpy(trans->rpayload.b8, &reinterpret_cast<uint8_t *>(&regs_)[off],
51
                trans->xsize);
52
    }
53
}
54
 
55
}  // namespace debugger

powered by: WebSVN 2.1.0

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