【发布时间】:2019-12-03 10:24:29
【问题描述】:
我想创建一个非常紧凑的并行到串行移位寄存器。
我已经手动设计了一个逻辑图块。
我希望 yosys/nextpnr 只做这个 tile 和 io 引脚之间的路由。
我已将代码设计为使用 yosys 原语,但 nextpnr 无法将 LUT 与进位融合。
代码如下:
module top (
output PIN_21, PIN_22, PIN_23, PIN_24, USBPU,
input CLK, PIN_1, PIN_2, PIN_3, PIN_4, PIN_5, PIN_6, PIN_7, PIN_8, PIN_9, PIN_10, PIN_11, PIN_12, PIN_13
);
wire[12:0] loop;
wire[12:0] carry;
MyCell #(.LUT_INIT('h0F0F)) sRegBorder(loop[0], carry[0], 0, loop[0], PIN_13, 0, 0, CLK);
MyCell #(.LUT_INIT('hFAFA)) sRegA(loop[1], carry[1], loop[0], loop[1], PIN_13, PIN_1, carry[0], CLK);
MyCell #(.LUT_INIT('hFAFA)) sRegB(loop[2], carry[2], loop[1], loop[2], PIN_13, PIN_2, carry[1], CLK);
MyCell #(.LUT_INIT('hFAFA)) sRegC(loop[3], carry[3], loop[2], loop[3], PIN_13, PIN_3, carry[2], CLK);
MyCell #(.LUT_INIT('hFAFA)) sRegD(loop[4], carry[4], loop[3], loop[4], PIN_13, PIN_4, carry[3], CLK);
MyCell #(.LUT_INIT('hFAFA)) sRegE(PIN_24, carry[5], loop[4], PIN_24, PIN_13, PIN_5, carry[4], CLK);
SB_LUT4 #(.LUT_INIT('hFFFF)) sRegFin (PIN_22,0,0,0,carry[5]);
endmodule
module MyCell(output O, CO, input I0, I1, I2, I3, CI, CLK);
parameter [15:0] LUT_INIT = 0;
wire lo;
SB_LUT4 #(.LUT_INIT(LUT_INIT)) lut (lo, I0, I1, I2, I3);
SB_CARRY cr (CO, I1, I2, CI);
SB_DFF dff (O, CLK, lo);
endmodule
预期的结果是只有一个带有 7 个 LUT 堆栈的图块。
* PIN_13 should be connected to I2 of the first 6 LUTS.
* PIN_[1-6] should be connected to I3 of the first 6 LUTS, respectivelly.
* every output of the first 6 LUTs should be buffered (DFF) and the buffered output should loop to the I1 of the same LUT.
* every output of the first 5 LUTs shoud also be routed to the I0 of the next LUT in sequence.
* the carry logic should be enabled and flow through the first 6 LUTs and at LUT7 should be captured as an output.
我从 yosys 得到的结果看起来还不错,但是 nextpnr 将 LUT 到处杀掉,并为进位分配了单独的 LUT,使使用的 LUT 数量增加了一倍。
所以基本上,如果我知道我想要的输出,至少到特定的磁贴配置,我应该写什么作为输入?
我尝试在 TinyFPGA.BX 上编译代码。
【问题讨论】:
-
PIN_22将始终为1'b1,因为sRegFin的 LUT 值为 16'hFFFF。这可能不是你想要的。 (另外,PIN_21、PIN_23和USBPU没有连接到任何东西)。我是否正确假设您希望PIN_22显示移位寄存器是否为 6'h0? -
yes sRegFin 是 16'hFF00,它用于捕获进位并将其暴露为输出。
-
PIN_1到PIN_5连接到 SB_LUT4 I3 对电路没有输入,因为 LUT 值为 16'hfafa,这可能不是您想要的。所描述的PIN_6不参与代码? -
所以FAFA想给出这个语义,也许我做错了。 O=I2?I3:I0 。即使 I1 不用于 lut,但它实际上用于进位功能,lut 也会忽略该输入。