Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zbs and DecoderManager docstrings #470

Merged
merged 9 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 35 additions & 45 deletions coreblocks/fu/fu_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ def elaborate(self, platform):


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

"""
Type[IntFlag]
Expand All @@ -55,62 +53,54 @@ class DecoderManager:
"""
Fn: Type[IntFlag]
lekcyjna123 marked this conversation as resolved.
Show resolved Hide resolved

"""
Method providing list of valid instruction.

Returns
-------
return : Sequence[tuple]
List of implemented instructions, each following format:
(IntFlag, OpType, Funct3 (optional), Funct7 (optional))

"""

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 op types from listed instructions.

"""
Method returning auto generated instruction decoder.

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