From: klehman Date: Tue, 14 Sep 2021 15:43:10 +0000 (-0400) Subject: factory add and intro doc string X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8e4d86cf105f8ab790982c87c65bc52ea228fd90;p=soc.git factory add and intro doc string --- diff --git a/src/soc/simple/test/teststate.py b/src/soc/simple/test/teststate.py index b5071ea8..12694d2c 100644 --- a/src/soc/simple/test/teststate.py +++ b/src/soc/simple/test/teststate.py @@ -1,7 +1,30 @@ +""" Power ISA test API + +This module implements the creation, inspection and comparison +of test states from different sources. + +The basic premise is to create a test state using the TestState method. +The TestState method returns a test state object initialized with a +basic set of registers pulled from the 'to_test' object. The +state created can then be tested against other test states using the +'compare' method. + +The SimState class provides an example of needed registers and naming. + +The TestState method relies on the 'state_factory' dictionary for lookup +of associated test class creation. The dictionary can be added to using +the state_add method. + +Also note when creating and accessing test state classes and object +methods, the use of yield from/yield is required. + + +""" + + from openpower.decoder.power_enums import XER_bits from openpower.util import log - class State: def get_state(self): yield from self.get_intregs() @@ -129,6 +152,11 @@ global state_factory state_factory = {'sim': SimState, 'hdl': HDLState} +global state_add +def state_add(sdic): + state_factory.update(sdic) + + def TestState(state_type, to_test, dut, code): state_class = state_factory[state_type] state = state_class(to_test)