X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Ffu%2Fcompunits%2Ftest%2Ftest_compunit.py;h=1265ba94ae1c785963a4a0ad585da4dca083fb89;hb=2565a10fa87f402b2bb433d641228d8f9067d444;hp=62d2f2aaa9e4329c4ae1a75857038e5f4525c72e;hpb=3924f545019e566c5af1d7d067286ee374a3c7ed;p=soc.git diff --git a/src/soc/fu/compunits/test/test_compunit.py b/src/soc/fu/compunits/test/test_compunit.py index 62d2f2aa..1265ba94 100644 --- a/src/soc/fu/compunits/test/test_compunit.py +++ b/src/soc/fu/compunits/test/test_compunit.py @@ -1,19 +1,15 @@ -from nmigen import Module, Signal +from nmigen import Module, Signal, ResetSignal from nmigen.back.pysim import Simulator, Delay, Settle -from nmigen.test.utils import FHDLTestCase +from nmutil.formaltest import FHDLTestCase from nmigen.cli import rtlil import unittest -from soc.decoder.isa.caller import ISACaller, special_sprs from soc.decoder.power_decoder import (create_pdecode) from soc.decoder.power_decoder2 import (PowerDecode2) -from soc.decoder.power_enums import (XER_bits, Function, InternalOp) -from soc.decoder.selectable_int import SelectableInt -from soc.simulator.program import Program +from soc.decoder.power_enums import Function from soc.decoder.isa.all import ISA -from soc.fu.alu.test.test_pipe_caller import TestCase, ALUTestCase, test_data from soc.experiment.compalu_multi import find_ok # hack -import random + def set_cu_input(cu, idx, data): rdop = cu.get_in_name(idx) @@ -33,6 +29,7 @@ def set_cu_input(cu, idx, data): print ("rd_rel %d wait HI" % idx, rd_rel_o) yield yield cu.rd.go[idx].eq(0) + yield cu.src_i[idx].eq(0) def get_cu_output(cu, idx, code): @@ -59,6 +56,7 @@ def get_cu_output(cu, idx, code): yield yield cu.wr.go[idx].eq(0) print ("result", repr(code), idx, wrop, wrok, hex(result)) + return result @@ -77,6 +75,16 @@ def set_operand(cu, dec2, sim): def get_cu_outputs(cu, code): res = {} + wrmask = yield cu.wrmask + print ("get_cu_outputs", cu.n_dst, wrmask) + if not wrmask: # no point waiting (however really should doublecheck wr.rel) + return {} + # wait for at least one result + while True: + wr_rel_o = yield cu.wr.rel + if wr_rel_o: + break + yield for i in range(cu.n_dst): wr_rel_o = yield cu.wr.rel[i] if wr_rel_o: @@ -95,13 +103,6 @@ def get_inp_indexed(cu, inp): res[i] = inp[wrop] return res -def get_cu_rd_mask(n_src, inp): - mask = 0 - for i in range(n_src): - if i in inp: - mask |= (1<