generic: Place a single SLICE
Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
parent
fd3ad75598
commit
50fd8aa01f
@ -81,34 +81,6 @@ template <> struct string_converter<PortRef &>
|
||||
|
||||
} // namespace PythonConversion
|
||||
|
||||
struct loc_from_tuple
|
||||
{
|
||||
loc_from_tuple() { converter::registry::push_back(&convertible, &construct, boost::python::type_id<Loc>()); }
|
||||
|
||||
static void *convertible(PyObject *obj_ptr)
|
||||
{
|
||||
if (!PyTuple_Check(obj_ptr))
|
||||
return 0;
|
||||
return obj_ptr;
|
||||
}
|
||||
|
||||
static void construct(PyObject *obj_ptr, converter::rvalue_from_python_stage1_data *data)
|
||||
{
|
||||
int val[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
PyObject *pyo = PyTuple_GetItem(obj_ptr, i);
|
||||
if (!pyo)
|
||||
throw_error_already_set();
|
||||
NPNR_ASSERT(PyLong_Check(pyo));
|
||||
val[i] = int(PyLong_AsLong(pyo));
|
||||
}
|
||||
|
||||
void *storage = ((converter::rvalue_from_python_storage<Loc> *)data)->storage.bytes;
|
||||
new (storage) Loc(val[0], val[1], val[2]);
|
||||
data->convertible = storage;
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(MODULE_NAME)
|
||||
{
|
||||
register_exception_translator<assertion_failure>(&translate_assertfail);
|
||||
@ -136,8 +108,11 @@ BOOST_PYTHON_MODULE(MODULE_NAME)
|
||||
|
||||
class_<BaseCtx, BaseCtx *, boost::noncopyable>("BaseCtx", no_init);
|
||||
|
||||
auto loc_cls =
|
||||
class_<Loc>("Loc").def_readwrite("x", &Loc::x).def_readwrite("y", &Loc::y).def_readwrite("z", &Loc::z);
|
||||
auto loc_cls = class_<Loc>("Loc")
|
||||
.def(init<int, int, int>())
|
||||
.def_readwrite("x", &Loc::x)
|
||||
.def_readwrite("y", &Loc::y)
|
||||
.def_readwrite("z", &Loc::z);
|
||||
|
||||
auto ci_cls = class_<ContextualWrapper<CellInfo &>>("CellInfo", no_init);
|
||||
readwrite_wrapper<CellInfo &, decltype(&CellInfo::name), &CellInfo::name, conv_to_str<IdString>,
|
||||
|
@ -174,12 +174,14 @@ void arch_wrap_python()
|
||||
pass_through<DecalXY>>::def_wrap(ctx_cls, "setGroupDecal", (arg("group"), "decalxy"));
|
||||
|
||||
fn_wrapper_3a_v<Context, decltype(&Context::setWireAttr), &Context::setWireAttr, conv_from_str<DecalId>,
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setWireAttr", (arg("wire"), "key", "value"));
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setWireAttr",
|
||||
(arg("wire"), "key", "value"));
|
||||
fn_wrapper_3a_v<Context, decltype(&Context::setBelAttr), &Context::setBelAttr, conv_from_str<DecalId>,
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setBelAttr", (arg("bel"), "key", "value"));
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setBelAttr",
|
||||
(arg("bel"), "key", "value"));
|
||||
fn_wrapper_3a_v<Context, decltype(&Context::setPipAttr), &Context::setPipAttr, conv_from_str<DecalId>,
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setPipAttr", (arg("pip"), "key", "value"));
|
||||
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setPipAttr",
|
||||
(arg("pip"), "key", "value"));
|
||||
|
||||
WRAP_MAP_UPTR(CellMap, "IdCellMap");
|
||||
WRAP_MAP_UPTR(NetMap, "IdNetMap");
|
||||
|
3
generic/examples/simple.py
Normal file
3
generic/examples/simple.py
Normal file
@ -0,0 +1,3 @@
|
||||
ctx.addBel(name="SLICE_X1Y1", type="SLICE_LUT4", loc=Loc(1, 1, 0), gb=False)
|
||||
ctx.addBel(name="IO0_I", type="$nextpnr_ibuf", loc=Loc(0, 0, 0), gb=False)
|
||||
ctx.addBel(name="IO1_O", type="$nextpnr_obuf", loc=Loc(1, 0, 0), gb=False)
|
15
generic/examples/simple.v
Normal file
15
generic/examples/simple.v
Normal file
@ -0,0 +1,15 @@
|
||||
(* blackbox *)
|
||||
module SLICE_LUT4(
|
||||
input I0, I1, I2, I3,
|
||||
input CLK,
|
||||
output Q
|
||||
);
|
||||
parameter INIT = 16'h0000;
|
||||
parameter FF_USED = 1'b0;
|
||||
endmodule
|
||||
|
||||
module top(input a, output q);
|
||||
|
||||
SLICE_LUT4 sl_i(.I0(a), .Q(q));
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user