Skip to content

Commit

Permalink
Merge branch 'master' into tilk/fix-build-mem-2
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk authored Nov 5, 2023
2 parents 7d45ab2 + d0ebfc0 commit 9d847df
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 54 deletions.
86 changes: 36 additions & 50 deletions coreblocks/fu/fu_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,73 +44,59 @@ def elaborate(self, platform):


class DecoderManager:
"""
Class responsible for instruction management.
"""

"""
Type[IntFlag]
"""Class responsible for instruction management."""

Enumeration of instructions implemented in given functional unit.
"""
Fn: Type[IntFlag]

"""
Method providing list of valid instruction.
Returns
-------
return : Sequence[tuple]
List of implemented instructions, each following format:
(IntFlag, OpType, Funct3 (optional), Funct7 (optional))
"""
"""Enumeration of instructions implemented in given functional unit."""

def get_instructions(self) -> Sequence[tuple]:
raise NotImplementedError
"""Method providing list of valid instruction.
"""
Method returning op types from listed instructions.
Returns
-------
return : Sequence[tuple]
List of implemented instructions, each following format:
(IntFlag, OpType, Funct3 (optional), Funct7 (optional))
Returns
-------
return : set[OpType]
List of OpTypes.
"""
"""
raise NotImplementedError

def get_op_types(self) -> set[OpType]:
return {instr[1] for instr in self.get_instructions()}

"""
Method returning auto generated instruction decoder.
"""Method returning op types from listed instructions.
Parameters
----------
gen_params: GenParams
Generation parameters passed to a decoder contructor.
Returns
-------
return : set[OpType]
List of OpTypes.
"""
Returns
-------
return : set[OpType]
List of OpTypes.
"""
return {instr[1] for instr in self.get_instructions()}

def get_decoder(self, gen_params: GenParams) -> Decoder:
"""Method returning auto generated instruction decoder.
Parameters
----------
gen_params: GenParams
Generation parameters passed to a decoder contructor.
Returns
-------
return : set[OpType]
List of OpTypes.
"""
# check how many different op types are there
op_types = self.get_op_types()
multiple_op_types = len(op_types) > 1

# if multiple op types detected, request op_type check in decoder
return Decoder(gen_params, self.Fn, self.get_instructions(), check_optype=multiple_op_types)

"""
Method returning Signal Object for decoder, called function in FU blocks
Returns
-------
return : Value
Signal object.
"""

def get_function(self) -> Value:
"""Method returning Signal Object for decoder, called function in FU blocks
Returns
-------
return : Value
Signal object.
"""
return Signal(self.Fn)
12 changes: 8 additions & 4 deletions coreblocks/fu/zbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ class Zbs(Elaboratable):
First input.
in2: Signal(xlen), in
Second input.
Args:
----
gen_params: Core generation parameters.
"""

def __init__(self, gen_params: GenParams, function=ZbsFunction()):
"""
Parameters
----------
gen_params : GenParams
Core generation parameters.
function : ZbsFunction
Decoder manager to decode instruction.
"""
self.gen_params = gen_params

self.xlen = gen_params.isa.xlen
Expand Down

0 comments on commit 9d847df

Please sign in to comment.