Packages

Introduction

First, we need to define some global configuration elements, such as internal opcodes values and so on.

This is done in the packages !

Common

common

common.vhd

common package

Enums

Enum list 3 elements

instructions 48 values

! @brief Type listings to define the decoder outputs, per opcodes.

• i_NOP

Value : 0

• i_LUI

Value : 1

• i_AUIPC

Value : 2

• i_ADDI

Value : 3

• i_SLTI

Value : 4

• i_SLTIU

Value : 5

• i_XORI

Value : 6

• i_ANDI

Value : 7

• i_SLLI

Value : 8

• i_SRLI

Value : 9

• i_SRAI

Value : 10

• i_ORI

Value : 11

• i_ADD

Value : 12

• i_SUB

Value : 13

• i_SLL

Value : 14

• i_SLT

Value : 15

• i_SLTU

Value : 16

• i_XOR

Value : 17

• i_SRL

Value : 18

• i_SRA

Value : 19

• i_OR

Value : 20

• i_AND

Value : 21

• i_FENCE

Value : 22

• i_BEQ

Value : 23

• i_BNE

Value : 24

• i_BLT

Value : 25

• i_BGE

Value : 26

• i_BLTU

Value : 27

• i_BGEU

Value : 28

• i_SB

Value : 29

• i_SH

Value : 30

• i_SW

Value : 31

• i_LB

Value : 32

• i_LH

Value : 33

• i_LW

Value : 34

• i_LBU

Value : 35

• i_LHU

Value : 36

• i_JAL

Value : 37

• i_JALR

Value : 38

• i_ECALL

Value : 39

• i_EBREAK

Value : 40

• i_MRET

Value : 41

• i_CSRRW

Value : 42

• i_CSRRS

Value : 43

• i_CSRRC

Value : 44

• i_CSRRWI

Value : 45

• i_CSRRSI

Value : 46

• i_CSRRCI

Value : 47

commands 11 values

! @brief Type listings to define the controller outputs feed into the ALU.

• c_ADD

Value : 0

• c_SUB

Value : 1

• c_SLL

Value : 2

• c_SRL

Value : 3

• c_SRA

Value : 4

• c_SLT

Value : 5

• c_SLTU

Value : 6

• c_AND

Value : 7

• c_OR

Value : 8

• c_XOR

Value : 9

• c_NONE

Value : 10

csr_register 17 values

! @brief Type listings to define the names of the different CSR registers names.

• r_MSTATUS

Value : 0

• r_MISA

Value : 1

• r_MIE

Value : 2

• r_MTVEC

Value : 3

• r_MSCRATCH

Value : 4

• r_MEPC

Value : 5

• r_MCAUSE

Value : 6

• r_MTVAL

Value : 7

• r_MIP

Value : 8

• r_CYCLE

Value : 9

• r_CYCLEH

Value : 10

• r_INSTR

Value : 11

• r_INSTRH

Value : 12

• r_MVENDORID

Value : 13

• r_MARCHID

Value : 14

• r_MIMPID

Value : 15

• r_MHARTID

Value : 16

Source

Raw source Full file

--------------------------------------------------------------------
--------------------------------------------------------------------

--! @brief Package to define some wirings types to make easier the transfer between modules, by using names rather than obscur std_logic_vector values.
PACKAGE common IS

    --! @brief Type listings to define the decoder outputs, per opcodes.
    TYPE instructions IS (
        i_NOP,

        i_LUI, i_AUIPC,

        i_ADDI, i_SLTI, i_SLTIU, i_XORI,
        i_ANDI, i_SLLI, i_SRLI, i_SRAI,
        i_ORI,

        i_ADD, i_SUB, i_SLL, i_SLT,
        i_SLTU, i_XOR, i_SRL, i_SRA,
        i_OR, i_AND,

        i_FENCE,

        i_BEQ, i_BNE, i_BLT, i_BGE,
        i_BLTU, i_BGEU,

        i_SB, i_SH, i_SW, i_LB,
        i_LH, i_LW, i_LBU, i_LHU,

        i_JAL, i_JALR,

        i_ECALL, i_EBREAK, i_MRET,

        i_CSRRW, i_CSRRS, i_CSRRC, i_CSRRWI,
        i_CSRRSI, i_CSRRCI
    );

    --! @brief Type listings to define the controller outputs feed into the ALU.
    TYPE commands IS (
        c_ADD, c_SUB,

        c_SLL, c_SRL, c_SRA,

        c_SLT, c_SLTU,

        c_AND, c_OR, c_XOR,

        c_NONE
    );

    --! @brief Type listings to define the names of the different CSR registers names.
    TYPE csr_register IS (
        r_MSTATUS,
        r_MISA,
        r_MIE,
        r_MTVEC,
        r_MSCRATCH,
        r_MEPC,
        r_MCAUSE,
        r_MTVAL,
        r_MIP,
        r_CYCLE, r_CYCLEH,
        r_INSTR, r_INSTRH,
        r_MVENDORID,
        r_MARCHID,
        r_MIMPID,
        r_MHARTID
    );

END common;

PACKAGE BODY common IS
END common;

Records

records

records.vhd

records package

Imports

Imports 1 element

  • ieee std_logic_1164

Structures

Structure list 1 element

alu_feedback 8 elements

! @brief This records group the status flags out of the ALU, feed into the controller to decide if an exception or a branch must be taken.

• zero STD_LOGIC

• overflow STD_LOGIC

• beq STD_LOGIC

• bne STD_LOGIC

• blt STD_LOGIC

• bge STD_LOGIC

• bltu STD_LOGIC

• bgeu STD_LOGIC

Source

Raw source Full file

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

PACKAGE records IS

    --! @brief This records group the status flags out of the ALU, feed into the controller to decide if an exception or a branch must be taken.
    TYPE alu_feedback IS RECORD
        zero : STD_LOGIC; --! ALU produced a zero output                                                      
        overflow : STD_LOGIC; --! ALU overflow (the result is then WRONG)
        beq : STD_LOGIC; --! Indicate that the BEQ condition is valid for jump
        bne : STD_LOGIC; --! Indicate that the BNE condition is valid for jump
        blt : STD_LOGIC; --! Indicate that the BLT condition is valid for jump
        bge : STD_LOGIC; --! Indicate that the BGE condition is valid for jump
        bltu : STD_LOGIC; --! Indicate that the BLTU condition is valid for jump
        bgeu : STD_LOGIC; --! Indicate that the BGEU condition is valid for jump

    END RECORD alu_feedback;
END PACKAGE records;