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_mul.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 multiplier.
6
 * @details    Implemented algorithm provides 4 clocks per instruction
7
 */
8
 
9
#ifndef __DEBUGGER_RIVERLIB_INT_MUL_H__
10
#define __DEBUGGER_RIVERLIB_INT_MUL_H__
11
 
12
#include <systemc.h>
13
#include "../../river_cfg.h"
14
 
15
namespace debugger {
16
 
17
SC_MODULE(IntMul) {
18
    sc_in<bool> i_clk;
19
    sc_in<bool> i_nrst;
20
    sc_in<bool> i_ena;                      // Enable bit
21
    sc_in<bool> i_unsigned;                 // Unsigned operands
22
    sc_in<bool> i_high;                     // High multiplied bits [127:64]
23
    sc_in<bool> i_rv32;                     // 32-bits operands enabled
24
    sc_in<sc_uint<RISCV_ARCH>> i_a1;        // Operand 1
25
    sc_in<sc_uint<RISCV_ARCH>> i_a2;        // Operand 2
26
    sc_out<sc_uint<RISCV_ARCH>> o_res;      // Result
27
    sc_out<bool> o_valid;                   // Result is valid
28
    sc_out<bool> o_busy;                    // Multiclock instruction under processing
29
 
30
    void comb();
31
    void registers();
32
 
33
    SC_HAS_PROCESS(IntMul);
34
 
35
    IntMul(sc_module_name name_);
36
 
37
    void generateVCD(sc_trace_file *i_vcd, sc_trace_file *o_vcd);
38
 
39
private:
40
    uint64_t compute_reference(bool unsign, bool rv32, uint64_t a1, uint64_t a2);
41
 
42
    struct Level0Type {
43
        sc_biguint<66> arr[32];
44
    };
45
 
46
    struct Level1Type {
47
        sc_biguint<69> arr[16];
48
    };
49
 
50
    struct Level2Type {
51
        sc_biguint<74> arr[8];
52
    };
53
 
54
    struct Level3Type {
55
        sc_biguint<83> arr[4];
56
    };
57
 
58
    struct Level4Type {
59
        sc_biguint<100> arr[2];
60
    };
61
 
62
    struct RegistersType {
63
        sc_signal<bool> busy;
64
        sc_signal<sc_uint<4>> ena;
65
        sc_uint<RISCV_ARCH> a1;
66
        sc_uint<RISCV_ARCH> a2;
67
        sc_signal<bool> unsign;
68
        sc_signal<bool> high;
69
        sc_signal<bool> rv32;
70
        Level1Type lvl1;
71
        Level3Type lvl3;
72
        sc_signal<sc_biguint<128>> result;
73
 
74
        sc_uint<RISCV_ARCH> a1_dbg;
75
        sc_uint<RISCV_ARCH> a2_dbg;
76
        sc_uint<RISCV_ARCH> reference_mul;          // Used for run-time comparision
77
    } v, r;
78
 
79
};
80
 
81
 
82
}  // namespace debugger
83
 
84
#endif  // __DEBUGGER_RIVERLIB_INT_MUL_H__

powered by: WebSVN 2.1.0

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