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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [cpu_sysc_plugin/] [riverlib/] [core/] [arith/] [int_div.h] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2016 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      Integer divider.
6
 */
7
 
8
#ifndef __DEBUGGER_RIVERLIB_INT_DIV_H__
9
#define __DEBUGGER_RIVERLIB_INT_DIV_H__
10
 
11
#include <systemc.h>
12
#include "../../river_cfg.h"
13
 
14
namespace debugger {
15
 
16
SC_MODULE(IntDiv) {
17
    sc_in<bool> i_clk;
18
    sc_in<bool> i_nrst;                 // Reset: active LOW
19
    sc_in<bool> i_ena;                  // Enable pulse
20
    sc_in<bool> i_unsigned;             // Unsigned operands
21
    sc_in<bool> i_rv32;                 // 32-bits instruction flag
22
    sc_in<bool> i_residual;             // Compute: 0 =division; 1=residual
23
    sc_in<sc_uint<RISCV_ARCH>> i_a1;    // Operand 1
24
    sc_in<sc_uint<RISCV_ARCH>> i_a2;    // Operand 2
25
    sc_out<sc_uint<RISCV_ARCH>> o_res;  // Result
26
    sc_out<bool> o_valid;               // Result is valid
27
    sc_out<bool> o_busy;                // Multiclock instruction processing
28
 
29
    void comb();
30
    void registers();
31
 
32
    SC_HAS_PROCESS(IntDiv);
33
 
34
    IntDiv(sc_module_name name_);
35
 
36
    void generateVCD(sc_trace_file *i_vcd, sc_trace_file *o_vcd);
37
 
38
private:
39
    uint64_t compute_reference(bool unsign, bool rv32, bool resid,
40
                               uint64_t a1, uint64_t a2);
41
 
42
    struct RegistersType {
43
        sc_signal<bool> rv32;
44
        sc_signal<bool> resid;
45
        sc_signal<bool> invert;
46
        sc_signal<bool> busy;
47
        sc_signal<sc_uint<34>> ena;
48
        sc_signal<sc_uint<RISCV_ARCH>> result;
49
        sc_uint<RISCV_ARCH> reference_div;
50
        sc_biguint<128> qr;
51
        sc_biguint<65> divider;
52
 
53
        sc_uint<64> a1_dbg;     // Store this value for output in a case of error
54
        sc_uint<64> a2_dbg;
55
    } v, r;
56
 
57
    // 2 stages per one clock to improve divider performance
58
    sc_biguint<65> wb_diff1;
59
    sc_biguint<65> wb_diff2;
60
    sc_biguint<128> wb_qr1;
61
    sc_biguint<128> wb_qr2;
62
};
63
 
64
 
65
}  // namespace debugger
66
 
67
#endif  // __DEBUGGER_RIVERLIB_INT_DIV_H__

powered by: WebSVN 2.1.0

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