X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Ffu%2Fcompunits%2Ftest%2Ftest_compunit.py;h=e1c7a8caf5026ba4ae35c43a998b0a7d5d865c13;hb=9453f40b89aa4cdcc7a2ba841ac83a4a6dd9fcda;hp=93df11e50a78956d8a2ac3cb20439700960cdde9;hpb=7e2999fdb4a418f044d768c1e94e8451760572bc;p=soc.git diff --git a/src/soc/fu/compunits/test/test_compunit.py b/src/soc/fu/compunits/test/test_compunit.py index 93df11e5..e1c7a8ca 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: @@ -87,19 +95,54 @@ def get_cu_outputs(cu, code): return res -def get_cu_rd_mask(n_src, inp): - mask = 0 #((1<