def test_axi4_w(): cfg = axi4.Axi4Config(16, 32) dut = axi4.axi4_w(cfg, 0) assert len(dut) == 3 assert "data" in get_names(dut) assert "strb" in get_names(dut) assert "user" not in get_names(dut) assert R.compose(get_width, get_item_by_name("data"))(dut) == 32 assert R.compose(get_width, get_item_by_name("last"))(dut) == 1
def test_axi4_b(): cfg = axi4.Axi4Config(16, 32) dut = axi4.axi4_b(cfg, 0) assert len(dut) == 2 assert "id" in get_names(dut) assert "resp" in get_names(dut) assert R.compose(get_width, get_item_by_name("resp"))(dut) == 2
def test_axi4_arw(): cfg = axi4.Axi4Config(16, 32, use_region=False, use_lock=False) dut = axi4.axi4_arw(cfg, 0) assert len(dut) == 9 assert "region" not in get_names(dut) assert "write" in get_names(dut) assert R.compose(get_width, get_item_by_name("write"))(dut) == 1
def test_flip_sebastienfilion(): # add :: Number → [Number] → Number add = reduce(lambda a, b: a + b) # multiply :: Number → [Number] → Number multiply = reduce(lambda a, b: a * b) total = compose(flip(multiply)([1, 2, 3]), flip(add)([1, 2, 3]))(0) assert total == 36
def reductive_validator_factory(validator_type: vf.SliceValidator, reducer: Callable, predicate: Callable) -> Callable: return lambda x, **slice_kwargs: validator_type( R.compose(predicate(x), reducer), MSG_TEMPLATE.format(s=slice_kwargs, q=REDUCERS[reducer], v=VALIDATORS[validator_type], p=PREDICATES[predicate].format(x=repr(x))), ** slice_kwargs)
def get_item_by_name(name): return R.find(R.compose(R.equals(name), get_name))