Decoder¶
Yet, the decoder is one of the piece that hold quite nicely. The systemverilog version is way faster, but this one was reasonable.
decoder_vhd¶
decoder.vhd
decoder_vhd module Multiple Clock Domains
Imports¶
Imports 3 elements
IEEE std_logic_1164 numeric_std
work common
Parameters¶
Parameters 1 element
- • XLEN Type : INTEGER Default : 32
! @brief Configure the data width in the core. DOES NOT configure the instruction lenght, which is fixed to 32 bits.
Ports¶
Ports list 13 elements
Name |
Direction |
Description |
Type |
Size |
Kind |
Polarity |
Fanout |
|---|---|---|---|---|---|---|---|
instruction |
Input |
! @brief Address of the program counter. This is actually the NEXT address for this implementation. |
|
|
Combinatorial |
- |
Fanout : 0 |
act_addr |
Input |
|
|
|
Register clock |
- |
Fanout : 0 |
rs1 |
Output |
! @brief Register selection 1 output. |
|
|
Combinatorial |
- |
Fanout : 0 |
rs2 |
Output |
! @brief Register selection 1 output. |
|
|
Combinatorial |
- |
Fanout : 0 |
rd |
Output |
! @brief Register selection 1 output. |
|
|
Combinatorial |
- |
Fanout : 0 |
imm |
Output |
! @brief Register selection 1 output. |
|
|
Combinatorial |
- |
Fanout : 0 |
addr |
Output |
! @brief Register selection 1 output. |
|
|
Register clock nRST |
- |
Fanout : 0 |
opcode |
Output |
! @brief Register selection 1 output. |
|
- |
Combinatorial nRST |
- |
Fanout : 0 |
illegal |
Output |
! @brief Register selection 1 output. |
|
- |
Combinatorial |
- |
Fanout : 0 |
pause |
Output |
|
|
- |
Combinatorial |
- |
Fanout : 0 |
clock |
Input |
! @brief clock enable from the core clock controller. Used to not create two clock domains from the master clock and the auxilliary clock. |
|
- |
Combinatorial |
- |
Fanout : 0 |
clock_en |
Input |
! @brief reset input, active low. When held to '0', the system will remain in the reset state until set to '1'. |
|
- |
Register clock |
- |
Fanout : 0 |
nRST |
Input |
|
|
- |
Combinatorial |
Negative |
Fanout : 0 |
Enums¶
Enum list 1 element
decocders_type 9 values
• U
Value : 0
• I
Value : 1
• R
Value : 2
• B
Value : 3
• S
Value : 4
• J
Value : 5
• default_t
Value : 6
• illegal_t
Value : 7
• NOP
Value : 8
Modules¶
Modules 1 element
• endianess : U1
Processes¶
Process list 4 elements
• P0 Clocked Clocked by clock Reset by nRST
- -
• P1 Clocked Clocked by clock Reset by nRST
- -
• P2 Clocked Clocked by clock Reset by nRST
- -
• P3 Combinatorial Reset by nRST
- -
Signals¶
Signals list 20 elements
Name |
Description |
Type |
Size |
Kind |
Fanout |
|---|---|---|---|---|---|
selected_decoder |
! @brief Registered selected decoder, |
|
- |
Combinatorial nRST |
Fanout : 0 |
rs1_internal |
! @brief RS2 output before getting assigned (to enable illegal zeroing). |
|
|
Combinatorial nRST |
Fanout : 0 |
rs2_internal |
! @brief RD output before getting assigned (to enable illegal zeroing). |
|
|
Combinatorial nRST |
Fanout : 0 |
rd_internal |
! @brief Immediate output before getting assigned (to enable illegal zeroing). |
|
|
Combinatorial nRST |
Fanout : 0 |
imm_internal |
|
|
|
Combinatorial nRST |
Fanout : 0 |
i_instruction |
! @brief Registered instruction to be treated within the second process (copy of i1, one cycle later). |
|
|
Register clock nRST |
Fanout : 0 |
i2_instruction |
! @brief Raw instruction, output of the endianess corrector. |
|
|
Combinatorial nRST |
Fanout : 0 |
i0_addr |
! @brief Second stage of the address registration. |
|
|
Register clock nRST |
Fanout : 0 |
i1_addr |
|
|
|
Register clock nRST |
Fanout : 0 |
first_flag |
! @brief A pause is required for this instruction, because it WILL need more than a CPU cycle to be executed. |
|
- |
Register clock nRST |
Fanout : 0 |
req_pause |
! @brief Pause cycles that are required for the current instruction. |
|
- |
Register clock nRST |
Fanout : 0 |
pause_cycles |
! @brief Paused flag, asserted when the logic acknowledged the pause_req status. |
|
Register clock nRST |
Fanout : 0 |
|
paused |
|
|
- |
Register clock nRST |
Fanout : 0 |
shift_auth |
|
|
- |
Register clock nRST |
Fanout : 0 |
paused_cycles |
|
|
Register clock nRST |
Fanout : 0 |
illegal 3 elements
Name |
Description |
Type |
Size |
Kind |
Fanout |
|---|---|---|---|---|---|
illegal_internal |
! @brief Illegal flag issued from the second process. |
|
- |
Register clock nRST |
Fanout : 0 |
illegal_internal2 |
! @brief Output illegal state (used because we can't readback an output port). Generate by ORing both of the previous signals. |
|
- |
Combinatorial nRST |
Fanout : 0 |
illegal_internal_out |
|
|
- |
Combinatorial |
Fanout : 0 |
r 2 elements
Name |
Description |
Type |
Size |
Kind |
Fanout |
|---|---|---|---|---|---|
r_selected_decoder |
|
|
- |
Combinatorial |
Fanout : 0 |
r_instruction |
|
|
|
Register clock nRST |
Fanout : 0 |
Assignments¶
Assignment list 8 elements
- • illegal_internal_out Combinatorial
Compute the illegal status
<br>Sources : illegal_internal illegal_internal2- • illegal Combinatorial
Output signals, while encouting for illegal state.
<br>Source : illegal_internal_out- • rs1 Combinatorial
Sources : illegal_internal_out rs1 rs1_internal
- • rs2 Combinatorial
Sources : illegal_internal_out rs2 rs2_internal
- • rd Combinatorial
Sources : illegal_internal_out rd rd_internal
- • imm Combinatorial
Sources : illegal_internal_out imm imm_internal
- • shift_auth Combinatorial
Output the pause combinational output
<br>Sources : paused req_pause- • pause Combinatorial
Source : shift_auth
Instantiation templates¶
Instantiation templates 2 elements
decoder_vhd <name> #(
.XLEN ( 32)
)(
.instruction (i_instruction),
.act_addr (i_act_addr),
.rs1 (i_rs1),
.rs2 (i_rs2),
.rd (i_rd),
.imm (i_imm),
.addr (i_addr),
.opcode (i_opcode),
.illegal (i_illegal),
.pause (i_pause),
.clock (i_clock),
.clock_en (i_clock_en),
.nRST (i_nRST)
);
<name>: entity work.decoder_vhd
generic map (
XLEN => 32
)
port map (
instruction => i_instruction,
act_addr => i_act_addr,
rs1 => i_rs1,
rs2 => i_rs2,
rd => i_rd,
imm => i_imm,
addr => i_addr,
opcode => i_opcode,
illegal => i_illegal,
pause => i_pause,
clock => i_clock,
clock_en => i_clock_en,
nRST => i_nRST
);
Source¶
Raw source Full file
--! @file src/core/core.vhd
--! @brief The base file that assemble all of the components of the core. Does not include any form of memory.
--! @author l.heywang <leonard.heywang@proton.me>
--! @date 05-10-2025
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
USE IEEE.numeric_std.ALL;
USE work.common.ALL;
ENTITY decoder_vhd IS
GENERIC (
--! @brief Configure the data width in the core. DOES NOT configure the instruction lenght, which is fixed to 32 bits.
XLEN : INTEGER := 32
);
PORT (
--------------------------------------------------------------------------------------------------------
-- Inputs
--------------------------------------------------------------------------------------------------------
--! @brief Instruction input, to be decoded.
instruction : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
--! @brief Address of the program counter. This is actually the NEXT address for this implementation.
act_addr : IN STD_LOGIC_VECTOR((XLEN - 1) DOWNTO 0);
--------------------------------------------------------------------------------------------------------
-- Outputs
--------------------------------------------------------------------------------------------------------
--! @brief Register selection 1 output.
rs1 : OUT STD_LOGIC_VECTOR((XLEN / 8) DOWNTO 0) := (OTHERS => '0');
--! @brief Register selection 1 output.
rs2 : OUT STD_LOGIC_VECTOR((XLEN / 8) DOWNTO 0) := (OTHERS => '0');
--! @brief Register selection 1 output.
rd : OUT STD_LOGIC_VECTOR((XLEN / 8) DOWNTO 0) := (OTHERS => '0');
--! @brief Register selection 1 output.
imm : OUT STD_LOGIC_VECTOR((XLEN - 1) DOWNTO 0) := (OTHERS => '0');
--! @brief Register selection 1 output.
addr : OUT STD_LOGIC_VECTOR((XLEN - 1) DOWNTO 0) := (OTHERS => '0');
--! @brief Register selection 1 output.
opcode : OUT instructions;
--! @brief Register selection 1 output.
illegal : OUT STD_LOGIC;
--! @brief Register selection 1 output.
pause : OUT STD_LOGIC;
--------------------------------------------------------------------------------------------------------
-- Clocks & controls
--------------------------------------------------------------------------------------------------------
--! @brief clock input of the core. Must match the INPUT_FREQ generics within some tolerance.
clock : IN STD_LOGIC;
--! @brief clock enable from the core clock controller. Used to not create two clock domains from the master clock and the auxilliary clock.
clock_en : IN STD_LOGIC;
--! @brief reset input, active low. When held to '0', the system will remain in the reset state until set to '1'.
nRST : IN STD_LOGIC
);
END ENTITY;
ARCHITECTURE behavioral OF decoder_vhd IS
--------------------------------------------------------------------------------------------------------
-- Types definitions
--------------------------------------------------------------------------------------------------------
--! @brief Custom types to define a name for the different decoders to be used.
TYPE decocders_type IS (U, I, R, B, S, J, default_t, illegal_t, NOP);
--------------------------------------------------------------------------------------------------------
-- Internal states
--------------------------------------------------------------------------------------------------------
--! @brief Illegal flag issued from the first process.
SIGNAL illegal_internal : STD_LOGIC := '0';
--! @brief Illegal flag issued from the second process.
SIGNAL illegal_internal2 : STD_LOGIC := '0';
--! @brief Output illegal state (used because we can't readback an output port). Generate by ORing both of the previous signals.
SIGNAL illegal_internal_out : STD_LOGIC := '0';
--------------------------------------------------------------------------------------------------------
-- Internal states
--------------------------------------------------------------------------------------------------------
--! @brief Selected decoder issued by the first process. Depends on the custom type defined before.
SIGNAL selected_decoder : decocders_type := default_t;
--! @brief Registered selected decoder,
SIGNAL r_selected_decoder : decocders_type := default_t;
--------------------------------------------------------------------------------------------------------
-- Latchs outputs
--------------------------------------------------------------------------------------------------------
--! @brief RS1 output before getting assigned (to enable illegal zeroing).
SIGNAL rs1_internal : STD_LOGIC_VECTOR(4 DOWNTO 0) := (OTHERS => '0');
--! @brief RS2 output before getting assigned (to enable illegal zeroing).
SIGNAL rs2_internal : STD_LOGIC_VECTOR(4 DOWNTO 0) := (OTHERS => '0');
--! @brief RD output before getting assigned (to enable illegal zeroing).
SIGNAL rd_internal : STD_LOGIC_VECTOR(4 DOWNTO 0) := (OTHERS => '0');
--! @brief Immediate output before getting assigned (to enable illegal zeroing).
SIGNAL imm_internal : STD_LOGIC_VECTOR((XLEN - 1) DOWNTO 0) := (OTHERS => '0');
--------------------------------------------------------------------------------------------------------
-- Internal instruction bus, with the right endianess
--------------------------------------------------------------------------------------------------------
--! @brief Registered instruction to be treated within the first process.
SIGNAL i_instruction : STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS => '0');
--! @brief Registered instruction to be treated within the second process (copy of i1, one cycle later).
SIGNAL i2_instruction : STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS => '0');
--! @brief Raw instruction, output of the endianess corrector.
SIGNAL r_instruction : STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS => '0');
--------------------------------------------------------------------------------------------------------
-- Internal address bus, for instruction corrections
--------------------------------------------------------------------------------------------------------
--! @brief First stage of the address registration.
SIGNAL i0_addr : STD_LOGIC_VECTOR((XLEN - 1) DOWNTO 0) := (OTHERS => '0');
--! @brief Second stage of the address registration.
SIGNAL i1_addr : STD_LOGIC_VECTOR((XLEN - 1) DOWNTO 0) := (OTHERS => '0');
--------------------------------------------------------------------------------------------------------
-- remove the first decoder cycle glitch
--------------------------------------------------------------------------------------------------------
--! @brief Flag to prevent from the input register to getting the data. This prevent from a duplication of the first instruction.
--! Memory is responding within a clock cycle, before the first cycle of the decoder. And memory won't output the next instruction
--! before three cycle, which will effectively read the instruction twice.
SIGNAL first_flag : STD_LOGIC := '0';
--! @brief A pause is required for this instruction, because it WILL need more than a CPU cycle to be executed.
SIGNAL req_pause : STD_LOGIC := '0';
--! @brief Pause cycles that are required for the current instruction.
SIGNAL pause_cycles : INTEGER RANGE 0 TO 3 := 0;
--! @brief Paused flag, asserted when the logic acknowledged the pause_req status.
SIGNAL paused : STD_LOGIC := '0';
--------------------------------------------------------------------------------------------------------
-- Evolution auth
--------------------------------------------------------------------------------------------------------
--! @brief Enable or disable the registration of new values, to prevent from skipping instructions.
SIGNAL shift_auth : STD_LOGIC := '0';
BEGIN
-- Endianess correctors
U1 : ENTITY work.endianess(rtl)
GENERIC MAP(
XLEN => 32
)
PORT MAP(
datain => instruction,
dataout => r_instruction
);
--========================================================================================
--! @brief this first process, P0 handles address registration for the output, as well as
--! instruction registering.
--! @details
--! This first process register inputs if the shift_auth bit is active. This enable the
--! clocking of a new ONLY enough
--! stall cycles for the previous instruction has been elapsed.
--========================================================================================
P0 : PROCESS (clock, nRST)
BEGIN
IF (nRST = '0') THEN
i_instruction <= (OTHERS => '0');
first_flag <= '1';
i0_addr <= (OTHERS => '0');
i1_addr <= (OTHERS => '0');
ELSIF rising_edge(clock) AND (clock_en = '1') AND (shift_auth = '1') THEN
IF (first_flag <= '0') THEN
i_instruction <= r_instruction;
-- Registering the address synchronously with the decoder.
-- This enable the output of a clean address bus that match with the actual execution code.
i0_addr <= act_addr;
i1_addr <= i0_addr;
addr <= i1_addr;
ELSE
first_flag <= '0';
END IF;
END IF;
END PROCESS;
--========================================================================================
--! @brief This second process, P2 will handle the decoder selection.
--! @details
--! This second process look to the 7 LSB of the instruction, and decide which decoder
--! shall be used for this instruction.
--! A second role is to handle the number of stall cycles required for an instruction,
--! which won't enable the ability to
--! react extremely fast ON the pipeline, and thus, remove complex logic on the core
--! controller (which would need
--! to stall 6 stages of pipeline).
--! The only drawback is that we can't predict the output, so, instructions that could
--! take 2 or 3 cycles will ALWAYS take 3.
--! On such a simple core, the performance loss is more than acceptable, but could be
--! quite big if we need higher performances.
--========================================================================================
P1 : PROCESS (nRST, clock)
VARIABLE paused_cycles : INTEGER RANGE 0 TO 3 := 0;
BEGIN
IF (nRST = '0') THEN
illegal_internal <= '0';
selected_decoder <= NOP;
req_pause <= '0';
pause_cycles <= 0;
paused_cycles := 0;
paused <= '0';
ELSIF rising_edge(clock) AND (clock_en = '1') THEN
IF (req_pause = '0') AND (paused = '0') THEN
-- Select the opcode, and perform an instruction size check (last two bits must be "11").
CASE i_instruction(6 DOWNTO 0) IS
WHEN "0110111" => -- LUI
selected_decoder <= U;
illegal_internal <= '0';
req_pause <= '0';
pause_cycles <= 0;
WHEN "0010111" => -- AUIPC
selected_decoder <= U;
illegal_internal <= '0';
req_pause <= '0';
pause_cycles <= 0;
WHEN "0010011" => -- Immediates
selected_decoder <= I;
illegal_internal <= '0';
req_pause <= '0';
pause_cycles <= 0;
WHEN "0001111" => -- FENCE
selected_decoder <= I;
illegal_internal <= '0';
req_pause <= '0';
pause_cycles <= 0;
WHEN "1100111" => --(JALR)
selected_decoder <= I;
illegal_internal <= '0';
req_pause <= '1';
pause_cycles <= 1;
WHEN "1110011" => -- Calls
selected_decoder <= I;
illegal_internal <= '0';
req_pause <= '1';
pause_cycles <= 1;
WHEN "0000011" => -- Store
selected_decoder <= I;
illegal_internal <= '0';
req_pause <= '0';
pause_cycles <= 0;
WHEN "0110011" => -- Register operations
selected_decoder <= R;
illegal_internal <= '0';
req_pause <= '0';
pause_cycles <= 0;
WHEN "1100011" => -- Branchs
selected_decoder <= B;
illegal_internal <= '0';
req_pause <= '1';
pause_cycles <= 1;
WHEN "0100011" => -- Loads
selected_decoder <= S;
illegal_internal <= '0';
req_pause <= '0';
pause_cycles <= 0;
WHEN "1101111" => -- Jumps
selected_decoder <= J;
illegal_internal <= '0';
req_pause <= '1';
pause_cycles <= 1;
WHEN "0000000" => -- All zero, seen as NOP
selected_decoder <= NOP;
illegal_internal <= '0';
req_pause <= '0';
pause_cycles <= 0;
WHEN OTHERS =>
selected_decoder <= illegal_t;
illegal_internal <= '1';
req_pause <= '0';
pause_cycles <= 0;
END CASE;
-- Handle the pause system
ELSE
-- First pause request
IF (req_pause = '1') THEN
-- Store the state
paused_cycles := pause_cycles - 1;
-- Enable to "skip" the paused status if the stall lenght is one cycle.
-- This step is, in fact already handled by the state we're here.
IF (pause_cycles /= 1) THEN
paused <= '1';
END IF;
-- ACK the pause request
pause_cycles <= 0;
req_pause <= '0';
ELSIF (paused = '1') THEN
-- Check if we need to unlock the state, or continue to decrement the counter
IF (paused_cycles /= 0) THEN
paused_cycles := paused_cycles - 1;
END IF;
IF (paused_cycles = 0) THEN
paused <= '0';
END IF;
END IF;
END IF;
END IF;
END PROCESS;
--========================================================================================
--! @brief This third process cut the decoding process into two halves, each one with a
--! dedicated job
--! by registering the outputs from the first process to feed them into the second stage.
--! @details
--! In fact, this process gave us extremely high performance gain (+125% Core frequency),
--! because the decoder is one of the elements that has a massive influcence on the
--! critical path.
--========================================================================================
P2 : PROCESS (clock, nRST, clock_en)
BEGIN
IF (nRST = '0') THEN
i2_instruction <= (OTHERS => '0');
ELSIF rising_edge(clock) AND (clock_en = '1') AND (shift_auth = '1') THEN
i2_instruction <= i_instruction;
END IF;
END PROCESS;
--========================================================================================
--! @brief This last process produce the output of the decoder, to the core controller.
--! @details
--! With the selected decoder previously selected, we can directly jump into slicing the
--! instruction into smaller parts, and doing to SEXT operation on immediates.
--! Some combinational selection occurs to choose the right opcode.
--========================================================================================
P3 : PROCESS (nRST, r_selected_decoder, i2_instruction)
BEGIN
IF (nRST = '0') THEN
rs1_internal <= (OTHERS => '0');
rs2_internal <= (OTHERS => '0');
imm_internal <= (OTHERS => '0');
rd_internal <= (OTHERS => '0');
opcode <= i_NOP;
illegal_internal2 <= '0';
ELSE
CASE selected_decoder IS
-- Register to register operation
WHEN R =>
rd_internal <= i2_instruction(11 DOWNTO 7);
rs1_internal <= i2_instruction(19 DOWNTO 15);
rs2_internal <= i2_instruction(24 DOWNTO 20);
imm_internal <= (OTHERS => '0');
-- i_instruction identification
CASE i2_instruction(31 DOWNTO 25) IS
WHEN "0000000" => -- ADD SLL SLT XOR SRL OR AND
CASE i2_instruction(14 DOWNTO 12) IS
WHEN "000" =>
opcode <= i_ADD;
illegal_internal2 <= '0';
WHEN "001" =>
opcode <= i_SLL;
illegal_internal2 <= '0';
WHEN "010" =>
opcode <= i_SLT;
illegal_internal2 <= '0';
WHEN "011" =>
opcode <= i_SLTU;
illegal_internal2 <= '0';
WHEN "100" =>
opcode <= i_XOR;
illegal_internal2 <= '0';
WHEN "101" =>
opcode <= i_SRL;
illegal_internal2 <= '0';
WHEN "110" =>
opcode <= i_OR;
illegal_internal2 <= '0';
WHEN "111" =>
opcode <= i_AND;
illegal_internal2 <= '0';
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
WHEN "0100000" => -- SUB SRA
CASE i2_instruction(14 DOWNTO 12) IS
WHEN "000" =>
opcode <= i_SUB;
illegal_internal2 <= '0';
WHEN "101" =>
opcode <= i_SRA;
illegal_internal2 <= '0';
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
-- Immediate to register operation
WHEN I =>
rd_internal <= i2_instruction(11 DOWNTO 7);
rs1_internal <= i2_instruction(19 DOWNTO 15);
rs2_internal <= (OTHERS => '0');
imm_internal <= (OTHERS => i2_instruction(31));
imm_internal(11 DOWNTO 0) <= i2_instruction(31 DOWNTO 20);
-- i_instruction identification
CASE i2_instruction(6 DOWNTO 2) IS
WHEN "00100" =>
CASE i2_instruction(14 DOWNTO 12) IS
WHEN "000" =>
opcode <= i_ADDI;
illegal_internal2 <= '0';
WHEN "001" =>
opcode <= i_SLLI;
illegal_internal2 <= '0';
WHEN "010" =>
opcode <= i_SLTI;
illegal_internal2 <= '0';
WHEN "011" =>
opcode <= i_SLTIU;
illegal_internal2 <= '0';
WHEN "100" =>
opcode <= i_XORI;
illegal_internal2 <= '0';
WHEN "110" =>
opcode <= i_ORI;
illegal_internal2 <= '0';
WHEN "101" =>
IF (i2_instruction(30) = '1') THEN
opcode <= i_SRAI;
illegal_internal2 <= '0';
ELSE
opcode <= i_SRLI;
illegal_internal2 <= '0';
END IF;
WHEN "111" =>
opcode <= i_ANDI;
illegal_internal2 <= '0';
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '0';
END CASE;
WHEN "00011" =>
opcode <= i_FENCE;
illegal_internal2 <= '0';
WHEN "00000" =>
CASE i2_instruction(14 DOWNTO 12) IS
WHEN "000" =>
opcode <= i_LB;
illegal_internal2 <= '0';
WHEN "001" =>
opcode <= i_LH;
illegal_internal2 <= '0';
WHEN "010" =>
opcode <= i_LW;
illegal_internal2 <= '0';
WHEN "100" =>
opcode <= i_LBU;
illegal_internal2 <= '0';
WHEN "101" =>
opcode <= i_LHU;
illegal_internal2 <= '0';
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
WHEN "11001" =>
IF (i2_instruction(14 DOWNTO 12) = "000") THEN
opcode <= i_JALR;
illegal_internal2 <= '0';
ELSE
opcode <= i_NOP;
illegal_internal2 <= '1';
END IF;
WHEN "11100" =>
CASE i2_instruction(14 DOWNTO 12) IS
WHEN "001" =>
opcode <= i_CSRRW;
illegal_internal2 <= '0';
WHEN "010" =>
opcode <= i_CSRRS;
illegal_internal2 <= '0';
WHEN "011" =>
opcode <= i_CSRRC;
illegal_internal2 <= '0';
WHEN "101" =>
opcode <= i_CSRRWI;
illegal_internal2 <= '0';
WHEN "110" =>
opcode <= i_CSRRSI;
illegal_internal2 <= '0';
WHEN "111" =>
opcode <= i_CSRRCI;
illegal_internal2 <= '0';
WHEN "000" =>
CASE i2_instruction(31 DOWNTO 20) IS
WHEN X"000" =>
opcode <= i_ECALL;
illegal_internal2 <= '0';
WHEN X"001" =>
opcode <= i_EBREAK;
illegal_internal2 <= '0';
WHEN X"302" =>
opcode <= i_MRET;
illegal_internal2 <= '0';
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
-- Memory operation
WHEN S =>
rd_internal <= (OTHERS => '0');
rs1_internal <= i2_instruction(19 DOWNTO 15);
rs2_internal <= i2_instruction(24 DOWNTO 20);
imm_internal <= (OTHERS => i2_instruction(31));
imm_internal(11 DOWNTO 0) <= i2_instruction(31 DOWNTO 25)
& i2_instruction(11 DOWNTO 7);
-- i_instruction identification
CASE i2_instruction(14 DOWNTO 12) IS
WHEN "000" =>
opcode <= i_SB;
illegal_internal2 <= '0';
WHEN "001" =>
opcode <= i_SH;
illegal_internal2 <= '0';
WHEN "010" =>
opcode <= i_SW;
illegal_internal2 <= '0';
WHEN OTHERS =>
END CASE;
-- Branches
WHEN B =>
rd_internal <= (OTHERS => '0');
rs1_internal <= i2_instruction(19 DOWNTO 15);
rs2_internal <= i2_instruction(24 DOWNTO 20);
imm_internal <= (OTHERS => i2_instruction(31));
imm_internal(12 DOWNTO 1) <= i2_instruction(31)
& i2_instruction(7)
& i2_instruction(30 DOWNTO 25)
& i2_instruction(11 DOWNTO 8);
imm_internal(0) <= '0';
-- i_instruction identification
CASE i2_instruction(14 DOWNTO 12) IS
WHEN "000" =>
opcode <= i_BEQ;
illegal_internal2 <= '0';
WHEN "001" =>
opcode <= i_BNE;
illegal_internal2 <= '0';
WHEN "100" =>
opcode <= i_BLT;
illegal_internal2 <= '0';
WHEN "101" =>
opcode <= i_BGE;
illegal_internal2 <= '0';
WHEN "110" =>
opcode <= i_BLTU;
illegal_internal2 <= '0';
WHEN "111" =>
opcode <= i_BGEU;
illegal_internal2 <= '0';
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
-- Immediates values loading
WHEN U =>
rd_internal <= i2_instruction(11 DOWNTO 7);
rs1_internal <= (OTHERS => '0');
rs2_internal <= (OTHERS => '0');
imm_internal <= i2_instruction(31 DOWNTO 12)
& "000000000000";
-- i_instruction identification
CASE i2_instruction(6 DOWNTO 2) IS
WHEN "01101" =>
opcode <= i_LUI;
illegal_internal2 <= '0';
WHEN "00101" =>
opcode <= i_AUIPC;
illegal_internal2 <= '0';
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
-- Jumps
WHEN J =>
rd_internal <= i2_instruction(11 DOWNTO 7);
rs1_internal <= (OTHERS => '0');
rs2_internal <= (OTHERS => '0');
imm_internal <= (OTHERS => i2_instruction(31));
imm_internal(20 DOWNTO 1) <= i2_instruction(31)
& i2_instruction(19 DOWNTO 12)
& i2_instruction(20)
& i2_instruction(30 DOWNTO 21);
imm_internal(0) <= '0';
-- i_instruction identification
CASE i2_instruction(6 DOWNTO 2) IS
WHEN "11011" =>
opcode <= i_JAL;
illegal_internal2 <= '0';
WHEN OTHERS =>
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
WHEN NOP =>
rd_internal <= (OTHERS => '0');
rs1_internal <= (OTHERS => '0');
rs2_internal <= (OTHERS => '0');
imm_internal <= (OTHERS => '0');
opcode <= i_NOP;
illegal_internal2 <= '0';
WHEN OTHERS =>
rd_internal <= (OTHERS => '0');
rs1_internal <= (OTHERS => '0');
rs2_internal <= (OTHERS => '0');
imm_internal <= (OTHERS => '0');
opcode <= i_NOP;
illegal_internal2 <= '1';
END CASE;
END IF;
END PROCESS;
-- Compute the illegal status
illegal_internal_out <= illegal_internal OR illegal_internal2;
-- Output signals, while encouting for illegal state.
illegal <= illegal_internal_out;
rs1 <= rs1_internal WHEN (illegal_internal_out = '0') ELSE
STD_LOGIC_VECTOR(to_unsigned(0, rs1'length));
rs2 <= rs2_internal WHEN (illegal_internal_out = '0') ELSE
STD_LOGIC_VECTOR(to_unsigned(0, rs2'length));
rd <= rd_internal WHEN (illegal_internal_out = '0') ELSE
STD_LOGIC_VECTOR(to_unsigned(0, rd'length));
imm <= imm_internal WHEN (illegal_internal_out = '0') ELSE
STD_LOGIC_VECTOR(to_unsigned(0, imm'length));
-- Output the pause combinational output
shift_auth <= NOT (req_pause OR paused);
pause <= shift_auth;
END ARCHITECTURE;
decoder_tb¶
decoder_tb.vhd
decoder_tb testbench
Imports¶
Imports 3 elements
IEEE std_logic_1164 numeric_std
work common
Signals¶
Signals list 9 elements
Name |
Description |
Type |
Size |
Kind |
Fanout |
|---|---|---|---|---|---|
instruction_t |
|
|
|
Combinatorial |
Fanout : 0 |
rs1_t |
|
|
|
Combinatorial |
Fanout : 0 |
rs2_t |
|
|
|
Combinatorial |
Fanout : 0 |
rd_t |
|
|
|
Combinatorial |
Fanout : 0 |
imm_t |
|
|
|
Combinatorial |
Fanout : 0 |
opcode_t |
|
|
- |
Combinatorial |
Fanout : 0 |
illegal_t |
|
|
- |
Combinatorial |
Fanout : 0 |
clock_t |
|
|
- |
Combinatorial |
Fanout : 0 |
nRST_t |
|
|
- |
Combinatorial |
Fanout : 0 |
Modules¶
Processes¶
Process list 3 elements
• P1
- -
• P2
- -
• P3
- -
Source¶
Raw source Full file
-- recommended simulation duration : 2us
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
USE IEEE.numeric_std.ALL;
USE work.common.ALL;
ENTITY decoder_tb IS
END ENTITY;
ARCHITECTURE behavioral OF decoder_tb IS
SIGNAL instruction_t : STD_LOGIC_VECTOR(31 DOWNTO 0) := X"00000000";
SIGNAL rs1_t : STD_LOGIC_VECTOR(4 DOWNTO 0);
SIGNAL rs2_t : STD_LOGIC_VECTOR(4 DOWNTO 0);
SIGNAL rd_t : STD_LOGIC_VECTOR(4 DOWNTO 0);
SIGNAL imm_t : STD_LOGIC_VECTOR(31 DOWNTO 0);
SIGNAL opcode_t : instructions;
SIGNAL illegal_t : STD_LOGIC;
SIGNAL clock_t : STD_LOGIC := '0';
SIGNAL nRST_t : STD_LOGIC := '0';
BEGIN
U1 : ENTITY work.decoder(behavioral)
GENERIC MAP(
XLEN => 32
)
PORT MAP(
instruction => instruction_t,
rs1 => rs1_t,
rs2 => rs2_t,
rd => rd_t,
imm => imm_t,
opcode => opcode_t,
illegal => illegal_t,
clock => clock_t,
nRST => nRST_t
);
P1 : PROCESS
BEGIN
clock_t <= NOT clock_t;
WAIT FOR 10 ns;
END PROCESS;
P2 : PROCESS
BEGIN
nRST_t <= '0';
WAIT FOR 10 ns;
nRST_t <= '1';
WAIT FOR 1 sec;
END PROCESS;
P3 : PROCESS
BEGIN
WAIT FOR 20 ns;
--==================================================
-- RV32I
--==================================================
-- Invalid instruction
instruction_t <= B"01110100101001101010011110111101";
WAIT FOR 20 ns;
----------------------------------------------------
-- Load immediates
----------------------------------------------------
-- LUI (load upper immediate) 01110100101001101010 (value) 01111 (15) 01101 (lui) 11 (32 bits)
-- U Type format
instruction_t <= B"01110100101001101010_01111_01101_11";
WAIT FOR 20 ns;
-- AUIPC (add upper immediate to PC) 01110100101001101010 (value) 01111 (15) 00101 (auipc) 11 (32 bits)
-- U Type format
instruction_t <= B"01110100101001101010_01111_00101_11";
WAIT FOR 20 ns;
----------------------------------------------------
-- Immediates instructions
----------------------------------------------------
-- ADDI (add immediate) 011111111111 (imm) 00011 (3) 000 (funct3) 10000 (16) 00100 (imm) 11 (32 bits)
-- I Type format
instruction_t <= B"011111111111_00011_000_00001_00100_11";
WAIT FOR 20 ns;
-- SLTI (Set less than immediate) 111111111111 (imm) 00011 (3) 010 (funct3) 10000 (16) 00100 (imm) 11 (32 bits)
-- I Type format
instruction_t <= B"111111111111_01011_010_10000_00100_11";
WAIT FOR 20 ns;
-- SLTIU (Set less than immediate unsigned) 011111111111 (imm) 00011 (3) 011 (funct3) 10000 (16) 00100 (imm) 11 (32 bits)
-- I Type format
instruction_t <= B"011111111111_11111_011_10000_00100_11";
WAIT FOR 20 ns;
-- XORI (XOR immediate) 111111111111 (imm) 00011 (19) 100 (funct3) 10000 (16) 00100 (imm) 11 (32 bits)
-- I Type format
instruction_t <= B"111111111111_10011_100_10000_00100_11";
WAIT FOR 20 ns;
-- ORI (OR immediate) 111111111111 (imm) 00011 (3) 110 (funct3) 10000 (16) 00100 (imm) 11 (32 bits)
-- I Type format
instruction_t <= B"111111111111_00011_110_10000_00100_11";
WAIT FOR 20 ns;
-- ANDI (AND immediate) 011111111111 (imm) 00011 (3) 111 (funct3) 10000 (16) 00100 (imm) 11 (32 bits)
-- I Type format
instruction_t <= B"011111111111_00011_111_10000_00100_11";
WAIT FOR 20 ns;
-- SLLI (Shift left immediate) 111111111111 (imm) 00011 (3) 001 (funct3) 10000 (16) 00100 (imm) 11 (32 bits)
-- I Type format
instruction_t <= B"111111111111_00011_001_10000_00100_11";
WAIT FOR 20 ns;
-- SRLI (Shift right immediate) 01000 (imm) 01 (0X) 01111 (imm (15)) 00011 (12) 101 (funct3) 01111 (15) 00100 (imm) 11 (32 bits)
-- I Type format
instruction_t <= B"00000_01_01111_01010_101_01111_00100_11";
WAIT FOR 20 ns;
-- SRAI (Shift right arithemetic immediate) 00000 (imm) 01 (0X) 01111 (imm (15)) 00011 (12) 101 (funct3) 01111 (15) 00100 (imm) 11 (32 bits)
-- I Type format
instruction_t <= B"01000_01_01111_01010_101_01111_00100_11";
WAIT FOR 20 ns;
----------------------------------------------------
-- Register operations
----------------------------------------------------
-- ADD 00000 (funct7) 00 (0) 01111 (15) 10001 (17) 000 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"00000_00_01111_10001_000_11111_01100_11";
WAIT FOR 20 ns;
-- SUB 01000 (funct7) 00 (0) 01111 (15) 10001 (17) 000 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"01000_00_01111_10001_000_11111_01100_11";
WAIT FOR 20 ns;
-- SLL 00000 (funct7) 00 (0) 01111 (15) 10001 (17) 001 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"00000_00_01111_10011_001_11111_01100_11";
WAIT FOR 20 ns;
-- SLT 00000 (funct7) 00 (0) 01111 (15) 10001 (17) 010 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"00000_00_01111_10001_010_11111_01100_11";
WAIT FOR 20 ns;
-- SLTU 00000 (funct7) 00 (0) 01111 (15) 10001 (17) 011 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"00000_00_01111_10001_011_11111_01100_11";
WAIT FOR 20 ns;
-- XOR 00000 (funct7) 00 (0) 01111 (15) 10001 (17) 100 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"00000_00_01111_10001_100_11111_01100_11";
WAIT FOR 20 ns;
-- SRL 00000 (funct7) 00 (0) 01111 (15) 10001 (17) 101 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"00000_00_01111_10001_101_11111_01100_11";
WAIT FOR 20 ns;
-- SRA 01000 (funct7) 00 (0) 01111 (15) 10001 (17) 101 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"01000_00_01111_10001_101_11111_01100_11";
WAIT FOR 20 ns;
-- OR 00000 (funct7) 00 (0) 01111 (15) 10001 (17) 110 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"00000_00_01111_10001_110_11111_01100_11";
WAIT FOR 20 ns;
-- AND 00000 (funct7) 00 (0) 01111 (15) 10001 (17) 111 (funct3) 11111 (31) 01100 (code) 11 (32 bits)
-- R Type format
instruction_t <= B"00000_00_01111_10001_111_11111_01100_11";
WAIT FOR 20 ns;
----------------------------------------------------
-- Fences instructions
----------------------------------------------------
-- FENCE 0000 1001 1001 00000 000 00000 00011 11
-- I type
instruction_t <= B"0000_1001_1001_00000_000_00000_00011_11";
WAIT FOR 20 ns;
----------------------------------------------------
-- Conditionnals jumps
----------------------------------------------------
-- BEQ (Branch if equal) 0111111 00111 (rs2) 00110 (rs1) 000 (funct3) 11111 (offset) 11000 (branch) 11 (32 bits)
-- B Type
instruction_t <= B"0111111_00111_00110_000_11111_11000_11";
WAIT FOR 20 ns;
-- BNE (Branch if not equal) 1111111 00111 (rs2) 00110 (rs1) 001 (funct3) 11111 (offset) 11000 (branch) 11 (32 bits)
-- B Type
instruction_t <= B"1111111_00111_00110_001_11111_11000_11";
WAIT FOR 20 ns;
-- BLT (Branch if less than) 0111111 00111 (rs2) 00110 (rs1) 100 (funct3) 11111 (offset) 11000 (branch) 11 (32 bits)
-- B Type
instruction_t <= B"0111111_00111_00110_100_11111_11000_11";
WAIT FOR 20 ns;
-- BGE (Branch if greater than) 1111111 00111 (rs2) 00110 (rs1) 101 (funct3) 11111 (offset) 11000 (branch) 11 (32 bits)
-- B Type
instruction_t <= B"1111111_00111_00110_101_11111_11000_11";
WAIT FOR 20 ns;
-- BLTU (Branch if less than (unsigned)) 0111111 00111 (rs2) 00110 (rs1) 110 (funct3) 11111 (offset) 11000 (branch) 11 (32 bits)
-- B Type
instruction_t <= B"0111111_00111_00110_110_11111_11000_11";
WAIT FOR 20 ns;
-- BGEU (Branch if greater than (unsigned) 1111111 00111 (rs2) 00110 (rs1) 111 (funct3) 11111 (offset) 11000 (branch) 11 (32 bits)
-- B Type
instruction_t <= B"1111111_00111_00110_111_11111_11000_11";
WAIT FOR 20 ns;
----------------------------------------------------
-- Memory operations
----------------------------------------------------
-- SB (Store byte) 1111111 (offset 1) 00001 (rs2) 00011 (rs1) 000 (funct3) 11111 (offset 2) 01000 (op) 11 (32 bits)
-- S type
instruction_t <= B"1111111_00001_00011_000_11111_01000_11";
WAIT FOR 20 ns;
-- SH (Store halfword) 1111111 (offset 1) 00001 (rs2) 00011 (rs1) 001 (funct3) 11111 (offset 2) 01000 (op) 11 (32 bits)
-- S type
instruction_t <= B"1111111_00001_00011_001_11111_01000_11";
WAIT FOR 20 ns;
-- SW (Store word) 1111111 (offset 1) 00001 (rs2) 00011 (rs1) 010 (funct3) 11111 (offset 2) 01000 (op) 11 (32 bits)
-- S type
instruction_t <= B"1111111_00001_00011_010_11111_01000_11";
WAIT FOR 20 ns;
-- LB (Load byte) 111111111111 (offset) 00011 (rs1) 000 (funct3) 00001 (rd) 00000 (op) 11 (32 bits)
-- I Type
instruction_t <= B"111111111111_00011_000_00001_00000_11";
WAIT FOR 20 ns;
-- LH (Load halfword) 111111111111 (offset) 00011 (rs1) 001 (funct3) 00001 (rd) 00000 (op) 11 (32 bits)
-- I Type
instruction_t <= B"111111111111_00011_001_00001_00000_11";
WAIT FOR 20 ns;
-- LW (Load word) 111111111111 (offset) 00011 (rs1) 010 (funct3) 00001 (rd) 00000 (op) 11 (32 bits)
-- I Type
instruction_t <= B"111111111111_00011_010_00001_00000_11";
WAIT FOR 20 ns;
-- LBU (Load byte unsigned) 111111111111 (offset) 00011 (rs1) 100 (funct3) 00001 (rd) 00000 (op) 11 (32 bits)
-- I Type
instruction_t <= B"111111111111_00011_100_00001_00000_11";
WAIT FOR 20 ns;
-- LHU (Load halfword unsigned) 111111111111 (offset) 00011 (rs1) 101 (funct3) 00001 (rd) 00000 (op) 11 (32 bits)
-- I Type
instruction_t <= B"111111111111_00011_101_00001_00000_11";
WAIT FOR 20 ns;
----------------------------------------------------
-- Jumps
----------------------------------------------------
-- JAL (Jump and Link) 11111111111111111111 (offset) 00011 (rd) 11011 (op) 11 (32 bits)
-- J Type
instruction_t <= B"11111111111111111111_00011_11011_11";
WAIT FOR 20 ns;
-- JALR (Jump and Link Register) 111111111111 (offset) 00001 (rs1) 000 (funct3) 00011 (rd) 11001 (op) 11 (32 bits)
-- I Type
instruction_t <= B"111111111111_00001_000_00011_11001_11";
WAIT FOR 20 ns;
----------------------------------------------------
-- Syscalls
----------------------------------------------------
-- ECALL (Syscall)
-- I Type
instruction_t <= B"000000000000000000000000011100_11";
WAIT FOR 20 ns;
-- EBREAK (sysret)
-- I Type
instruction_t <= B"000000000001000000000000011100_11";
WAIT FOR 20 ns;
-- --==================================================
-- -- RV32M
-- --==================================================
-- -- MUL 0000001 (funct7) 00001 (rs2) 00011 (rs1) 000 (funct3) 11111 (rd) 01100 (op) 11 (32 bits)
-- -- R Type format
-- instruction_t <= B"0000001_00001_00011_000_11111_01100_11";
-- wait for 20 ns;
-- -- MULH 0000001 (funct7) 00001 (rs2) 00011 (rs1) 001 (funct3) 11111 (rd) 01100 (op) 11 (32 bits)
-- -- R Type format
-- instruction_t <= B"0000001_00001_00011_001_11111_01100_11";
-- wait for 20 ns;
-- -- MULHSU 0000001 (funct7) 00001 (rs2) 00011 (rs1) 010 (funct3) 11111 (rd) 01100 (op) 11 (32 bits)
-- -- R Type format
-- instruction_t <= B"0000001_00001_00011_010_11111_01100_11";
-- wait for 20 ns;
-- -- MULHU 0000001 (funct7) 00001 (rs2) 00011 (rs1) 011 (funct3) 11111 (rd) 01100 (op) 11 (32 bits)
-- -- R Type format
-- instruction_t <= B"0000001_00001_00011_011_11111_01100_11";
-- wait for 20 ns;
-- -- DIV 0000001 (funct7) 00001 (rs2) 00011 (rs1) 100 (funct3) 11111 (rd) 01100 (op) 11 (32 bits)
-- -- R Type format
-- instruction_t <= B"0000001_00001_00011_100_11111_01100_11";
-- wait for 20 ns;
-- -- DIVU 0000001 (funct7) 00001 (rs2) 00011 (rs1) 101 (funct3) 11111 (rd) 01100 (op) 11 (32 bits)
-- -- R Type format
-- instruction_t <= B"0000001_00001_00011_101_11111_01100_11";
-- wait for 20 ns;
-- -- REM 0000001 (funct7) 00001 (rs2) 00011 (rs1) 110 (funct3) 11111 (rd) 01100 (op) 11 (32 bits)
-- -- R Type format
-- instruction_t <= B"0000001_00001_00011_110_11111_01100_11";
-- wait for 20 ns;
-- -- REMU 0000001 (funct7) 00001 (rs2) 00011 (rs1) 111 (funct3) 11111 (rd) 01100 (op) 11 (32 bits)
-- -- R Type format
-- instruction_t <= B"0000001_00001_00011_111_11111_01100_11";
-- wait for 20 ns;
----------------------------------------------------
-- ILLEGALS
----------------------------------------------------
-- (ILLEGAL) SH (Store halfword) 1111111 (offset 1) 00001 (rs2) 00011 (rs1) 010 (funct3) 11111 (offset 2) 01000 (op) 11 (32 bits)
-- S type
instruction_t <= B"1111111_00001_00011_011_11111_01000_11";
WAIT FOR 20 ns;
-- (ILLEGAL) BGE (Branch if greater than) 0111111 00111 (rs2) 00110 (rs1) 101 (funct3) 11111 (offset) 11000 (branch) 11 (32 bits)
-- B Type
instruction_t <= B"0111111_00111_00110_010_11111_11000_11";
WAIT FOR 20 ns;
-- End
WAIT FOR 1 sec;
END PROCESS;
END ARCHITECTURE;
-- Instructions lists
-- Type Opcode Funct3 Funct7 Instruction Description Cycles Numbers Remarks
-- U-Type 0110111 N/A N/A LUI Load Upper Immediate 1 N/A
-- U-Type 0010111 N/A N/A AUIPC Add Upper Immediate to PC 1 N/A
-- I-Type 0010011 000 N/A ADDI Add Immediate 1 N/A
-- I-Type 0010011 010 N/A SLTI Set if Less Than Immediate 1 N/A
-- I-Type 0010011 011 N/A SLTIU Set if < Immediate (Unsigned) 1 N/A
-- I-Type 0010011 100 N/A XORI XOR Immediate 1 N/A
-- I-Type 0010011 110 N/A ORI OR Immediate 1 N/A
-- I-Type 0010011 111 N/A ANDI AND Immediate 1 N/A
-- I-Type 0010011 001 0000000 SLLI Shift Left Logical Immediate 1 N/A
-- I-Type 0010011 101 0000000 SRLI Shift Right Logical Immediate 1 N/A
-- I-Type 0010011 101 0100000 SRAI Shift Right Arithmetic Immediate 1 N/A
-- R-Type 0110011 000 0000000 ADD Add 1 N/A
-- R-Type 0110011 000 0100000 SUB Subtract 1 N/A
-- R-Type 0110011 001 0000000 SLL Shift Left Logical 1 N/A
-- R-Type 0110011 010 0000000 SLT Set if Less Than 1 N/A
-- R-Type 0110011 011 0000000 SLTU Set if < (Unsigned) 1 N/A
-- R-Type 0110011 100 0000000 XOR XOR 1 N/A
-- R-Type 0110011 101 0000000 SRL Shift Right Logical 1 N/A
-- R-Type 0110011 101 0100000 SRA Shift Right Arithmetic 1 N/A
-- R-Type 0110011 110 0000000 OR OR 1 N/A
-- R-Type 0110011 111 0000000 AND AND
-- I-Type 0001111 000 N/A FENCE Fence ? Block any unterminated IO operation
-- B-Type 1100011 000 N/A BEQ Branch if Equal ? N/A
-- B-Type 1100011 001 N/A BNE Branch if Not Equal ? N/A
-- B-Type 1100011 100 N/A BLT Branch if Less Than ? N/A
-- B-Type 1100011 101 N/A BGE Branch if Greater Than or Equal ? N/A
-- B-Type 1100011 110 N/A BLTU Branch if Less Than (Unsigned) ? N/A
-- B-Type 1100011 111 N/A BGEU Branch if >= (Unsigned) ? N/A
-- S-Type 0100011 000 N/A SB Store Byte ? May take time (how much ?). Does not block by default, FENCE op if needed.
-- S-Type 0100011 001 N/A SH Store Halfword ? May take time (how much ?). Does not block by default, FENCE op if needed.
-- S-Type 0100011 010 N/A SW Store Word ? May take time (how much ?). Does not block by default, FENCE op if needed.
-- I-Type 0000011 000 N/A LB Load Byte ? May take time (how much ?). Does not block by default, FENCE op if needed.
-- I-Type 0000011 001 N/A LH Load Halfword ? May take time (how much ?). Does not block by default, FENCE op if needed.
-- I-Type 0000011 010 N/A LW Load Word ? May take time (how much ?). Does not block by default, FENCE op if needed.
-- I-Type 0000011 100 N/A LBU Load Byte (Unsigned) ? May take time (how much ?). Does not block by default, FENCE op if needed.
-- I-Type 0000011 101 N/A LHU Load Halfword (Unsigned) ? May take time (how much ?). Does not block by default, FENCE op if needed.
-- J-Type 1101111 N/A N/A JAL Jump and Link 1 Stall the pipeline
-- I-Type 1100111 000 N/A JALR Jump and Link Register 1 Stall the pipeline
-- I-Type 1110011 000 000000000000 ECALL Environment Call 4 Stall the pipeline + execution mode to priviledged
-- I-Type 1110011 000 000000000001 EBREAK Environment Breakpoint 4 Stall the pipeline + execution mode to user
-- R-Type 0110011 000 0000001 MUL Multiply 1 N/A
-- R-Type 0110011 001 0000001 MULH Multiply High (Signed) 1 N/A
-- R-Type 0110011 010 0000001 MULHSU Multiply High (Signed x Unsigned) 1 N/A
-- R-Type 0110011 011 0000001 MULHU Multiply High (Unsigned) 1 N/A
-- R-Type 0110011 100 0000001 DIV Divide (Signed) 1 N/A
-- R-Type 0110011 101 0000001 DIVU Divide (Unsigned) 1 N/A
-- R-Type 0110011 110 0000001 REM Remainder (Signed) 1 N/A
-- R-Type 0110011 111 0000001 REMU Remainder (Unsigned) 1 N/A