rtl/idecode.py
def IDecodeStage():
    """The instruction decode stage for Geode.

    This stage consumes the instruction produced by the most recent imem access
    and produces control signals and a sign-extended immediate value. In
    addition, this module contains the register file and produces read values
    for register source data.
    """

    io = Io({
        'if_id': Input(if_id_bundle),
        'inst': Input(Bits(32)),
        'reg_write': Input(reg_write_bundle),
        'id_ex': Output(id_ex_bundle)
    })

    inst = Wire(Bits(32))

    #
    # The ifetch stage may read an invalid instruction in the case where a
    # branch is taken. This is indicated by io.if_id.valid. If it's 0, replace
    # the instruction to decode with 0 (which will result in a nop).
    #

    with io.if_id.valid:
        inst <<= io.inst
    with otherwise:
        inst <<= 0

    regfile = Instance(RegisterFile())

    itype = Wire(Bits(ITypes.bitwidth))

    regfile.r0_addr <<= Rs1(inst)
    regfile.r1_addr <<= Rs2(inst)

    regfile.w0_addr <<= io.reg_write.w_addr
    regfile.w0_en <<= io.reg_write.w_en
    regfile.w0_data <<= io.reg_write.w_data

    #
    # inst_data is metadata about the current instruction that is passed through
    # the pipeline unrelated to control signals. It's primary use is for hazard
    # detection and data forwarding.
    #

    io.id_ex.inst_data.inst <<= inst
    io.id_ex.inst_data.pc <<= io.if_id.pc
    io.id_ex.inst_data.rs1 <<= Rs1(inst)
    io.id_ex.inst_data.rs2 <<= Rs2(inst)
    io.id_ex.inst_data.rd <<= Rd(inst)

    #
    # Hook up the register read outputs.
    #

    io.id_ex.rs1_data <<= regfile.r0_data
    io.id_ex.rs2_data <<= regfile.r1_data

    #
    # Control is a Python function that produces the primary decode logic. It
    # matches against a set of known instructions to produce control signals for
    # later stages in the pipeline. The known instructions are encoded in the
    # 'instructions' variable above.
    #

    Control(
        inst,
        itype,
        io.id_ex.ex_ctrl,
        io.id_ex.mem_ctrl,
        io.id_ex.wb_ctrl)

    #
    # GenerateImmediate produces logic that consume the itype (instruction
    # type, which is R, I, S, B, U, or J) and produces the immediate value for
    # this instruction.
    #

    io.id_ex.imm <<= GenerateImmediate(inst, itype)

    NameSignals(locals())
The instruction decode stage for Geode.

    This stage consumes the instruction produced by the most recent imem access
    and produces control signals and a sign-extended immediate value. In
    addition, this module contains the register file and produces read values
    for register source data.
    
The instruction decode stage for Geode.
This stage consumes the instruction produced by the most recent imem access
and produces control signals and a sign-extended immediate value. In
addition, this module contains the register file and produces read values
for register source data.
The instruction decode stage for Geode . This stage consumes the instruction produced by the most recent imem access and produces control signals and a sign - extended immediate value . In addition this module contains the register file and produces read values for register source data .
def IDecodeStage():
    io = Io({
        'if_id': Input(if_id_bundle),
        'inst': Input(Bits(32)),
        'reg_write': Input(reg_write_bundle),
        'id_ex': Output(id_ex_bundle)
    })
    inst = Wire(Bits(32))
     The ifetch stage may read an invalid instruction in the case where a
     branch is taken. This is indicated by io.if_id.valid. If it's 0, replace
     the instruction to decode with 0 (which will result in a nop).
    with io.if_id.valid:
        inst <<= io.inst
    with otherwise:
        inst <<= 0
    regfile = Instance(RegisterFile())
    itype = Wire(Bits(ITypes.bitwidth))
    regfile.r0_addr <<= Rs1(inst)
    regfile.r1_addr <<= Rs2(inst)
    regfile.w0_addr <<= io.reg_write.w_addr
    regfile.w0_en <<= io.reg_write.w_en
    regfile.w0_data <<= io.reg_write.w_data
     inst_data is metadata about the current instruction that is passed through
     the pipeline unrelated to control signals. It's primary use is for hazard
     detection and data forwarding.
    io.id_ex.inst_data.inst <<= inst
    io.id_ex.inst_data.pc <<= io.if_id.pc
    io.id_ex.inst_data.rs1 <<= Rs1(inst)
    io.id_ex.inst_data.rs2 <<= Rs2(inst)
    io.id_ex.inst_data.rd <<= Rd(inst)
     Hook up the register read outputs.
    io.id_ex.rs1_data <<= regfile.r0_data
    io.id_ex.rs2_data <<= regfile.r1_data
     Control is a Python function that produces the primary decode logic. It
     matches against a set of known instructions to produce control signals for
     later stages in the pipeline. The known instructions are encoded in the
     'instructions' variable above.
    Control(
        inst,
        itype,
        io.id_ex.ex_ctrl,
        io.id_ex.mem_ctrl,
        io.id_ex.wb_ctrl)
     GenerateImmediate produces logic that consume the itype (instruction
     type, which is R, I, S, B, U, or J) and produces the immediate value for
     this instruction.
    io.id_ex.imm <<= GenerateImmediate(inst, itype)
    NameSignals(locals())
def IDecodeStage ( ) : io = Io ( { 'if_id' : Input ( if_id_bundle ) , 'inst' : Input ( Bits ( 32 ) ) , 'reg_write' : Input ( reg_write_bundle ) , 'id_ex' : Output ( id_ex_bundle ) } ) inst = Wire ( Bits ( 32 ) ) with io . if_id . valid : inst <<= io . inst with otherwise : inst <<= 0 regfile = Instance ( RegisterFile ( ) ) itype = Wire ( Bits ( ITypes . bitwidth ) ) regfile . r0_addr <<= Rs1 ( inst ) regfile . r1_addr <<= Rs2 ( inst ) regfile . w0_addr <<= io . reg_write . w_addr regfile . w0_en <<= io . reg_write . w_en regfile . w0_data <<= io . reg_write . w_data io . id_ex . inst_data . inst <<= inst io . id_ex . inst_data . pc <<= io . if_id . pc io . id_ex . inst_data . rs1 <<= Rs1 ( inst ) io . id_ex . inst_data . rs2 <<= Rs2 ( inst ) io . id_ex . inst_data . rd <<= Rd ( inst ) io . id_ex . rs1_data <<= regfile . r0_data io . id_ex . rs2_data <<= regfile . r1_data Control ( inst , itype , io . id_ex . ex_ctrl , io . id_ex . mem_ctrl , io . id_ex . wb_ctrl ) io . id_ex . imm <<= GenerateImmediate ( inst , itype ) NameSignals ( locals ( ) )
The instruction decode stage for Geode.
The instruction decode stage for Geode .
"""The instruction decode stage for Geode.

    This stage consumes the instruction produced by the most recent imem access
    and produces control signals and a sign-extended immediate value. In
    addition, this module contains the register file and produces read values
    for register source data.
    """ # # The ifetch stage may read an invalid instruction in the case where a # branch is taken. This is indicated by io.if_id.valid. If it's 0, replace # the instruction to decode with 0 (which will result in a nop). # # # inst_data is metadata about the current instruction that is passed through # the pipeline unrelated to control signals. It's primary use is for hazard # detection and data forwarding. # # # Hook up the register read outputs. # # # Control is a Python function that produces the primary decode logic. It # matches against a set of known instructions to produce control signals for # later stages in the pipeline. The known instructions are encoded in the # 'instructions' variable above. # # # GenerateImmediate produces logic that consume the itype (instruction # type, which is R, I, S, B, U, or J) and produces the immediate value for # this instruction. #