From: Luke Kenneth Casson Leighton Date: Thu, 4 Jun 2020 13:23:26 +0000 (+0100) Subject: add first cut at test core X-Git-Tag: div_pipeline~604 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fbc6071b90e7aee613cd70d93cd45f032aaaad7e;p=soc.git add first cut at test core --- diff --git a/src/soc/simple/test/test_core.py b/src/soc/simple/test/test_core.py new file mode 100644 index 00000000..8063b97b --- /dev/null +++ b/src/soc/simple/test/test_core.py @@ -0,0 +1,199 @@ +from nmigen import Module, Signal +from nmigen.back.pysim import Simulator, Delay, Settle +from nmutil.formaltest import FHDLTestCase +from nmigen.cli import rtlil +import unittest +from soc.decoder.power_decoder import create_pdecode +from soc.decoder.power_decoder2 import PowerDecode2 +from soc.decoder.isa.all import ISA +from soc.decoder.power_enums import Function + + +from soc.simple.core import NonProductionCore +from soc.experiment.compalu_multi import find_ok # hack + +# test with ALU data +from soc.fu.alu.test.test_pipe_caller import TestCase, ALUTestCase, test_data + + +def set_cu_input(cu, idx, data): + rdop = cu.get_in_name(idx) + yield cu.src_i[idx].eq(data) + while True: + rd_rel_o = yield cu.rd.rel[idx] + print ("rd_rel %d wait HI" % idx, rd_rel_o, rdop, hex(data)) + if rd_rel_o: + break + yield + yield cu.rd.go[idx].eq(1) + while True: + yield + rd_rel_o = yield cu.rd.rel[idx] + if rd_rel_o: + break + 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): + wrmask = yield cu.wrmask + wrop = cu.get_out_name(idx) + wrok = cu.get_out(idx) + fname = find_ok(wrok.fields) + wrok = yield getattr(wrok, fname) + print ("wr_rel mask", repr(code), idx, wrop, bin(wrmask), fname, wrok) + assert wrmask & (1<