SRL(移位寄存器)資源,在FPGA中都有,不過(guò)是叫不同的名字。Xilinx FPGA內(nèi)部的LUT有個(gè)特殊功能,就是可以配置成可變長(zhǎng)度SRL。
5輸入的一個(gè)LUT可以變成32bit 的SRL
6輸入的,可以變成64bit的SRL
所以,你寫(xiě)的SRL可能被綜合成LUT。
可以定義移位長(zhǎng)度的移位寄存器。
就是用一個(gè)lut可以實(shí)現(xiàn)16位的移位寄存器。
SRL16 的是 16bit移位寄存器查找表 // 16-Bit Shift Register Look-Up-Table (LUT)
在一個(gè)LUT中可以實(shí)現(xiàn)16個(gè)FF移位的功能!
SSRL16 SRL16_inst (
.Q(Q), // SRL data output
.A0(A0), // Select[0] input
.A1(A1), // Select[1] input
.A2(A2), // Select[2] input
.A3(A3), // Select[3] input
.CLK(CLK), // Clock input
.D(D) // SRL data input
);
Xilinx 官網(wǎng)的說(shuō)明——原理
SRL16 is a shift register look up table (LUT)。 The inputs A3, A2, A1, and A0 select the output length of the shift register. The shift register may be of a fixed, static length or it may be dynamically adjusted.
The shift register LUT contents are initialized by assigning a four-digit hexadecimal number to an INIT attribute. The first, or the left-most, hexadecimal digit is the most significant bit. If an INIT value is not specified, it defaults to a value of four zeros (0000) so that the shift register LUT is cleared during configuration.
The data (D) is loaded into the first bit of the shift register during the Low-to-High clock (CLK) transition. During subsequent Low-to-High clock transitions data is shifted to the next highest bit position as new data is loaded. The data appears on the Q output when the shift register length determined by the address inputs is reached.
這里說(shuō)了幾點(diǎn),
- 移位寄存器的初始值可以用INIT屬性初始化;
- 移位寄存器的長(zhǎng)度由地址線的取值決定;
- 移位數(shù)據(jù)從D端輸入,Q端輸出
- 先移入的數(shù)據(jù)是MSB
Xilinx 官網(wǎng)的說(shuō)明——Static Length Mode
To get a fixed length shift register, drive the A3 through A0 inputs with static values. The length of the shift register can vary from 1 bit to 16 bits as determined from the following formula:
Length = (8*A3) +(4*A2) + (2*A1) + A0 +1
If A3, A2, A1, and A0 are all zeros (0000), the shift register is one bit long. If they are all ones (1111), it is 16 bits long.
Xilinx 官網(wǎng)的說(shuō)明——Dynamic Length Mode
The length of the shift register can be changed dynamically by changing the values driving the A3 through A0 inputs. For example, if A2, A1, and A0 are all ones (111) and A3 toggles between a one (1) and a zero (0), the length of the shift register changes from 16 bits to 8 bits.
Internally, the length of the shift register is always 16 bits and the input lines A3 through A0 select which of the 16 bits reach the output.
Inputs Output
Am CLK D Q
Am X X Q(Am)
Am ↑ D Q(Am-1)
m= 0, 1, 2, 3
這里提示了幾個(gè)要點(diǎn):
- 移位寄存器是可變長(zhǎng)度的
- 長(zhǎng)度的改變由地址線來(lái)指定
- 內(nèi)部的寄存器長(zhǎng)度是不變的,只是截取的長(zhǎng)度變了
- 數(shù)據(jù)先移入到A0,然后到A1,以此類推,最后從指定長(zhǎng)度的Am-1處輸出,比如A=8,則數(shù)據(jù)從地址0輸入,從地址7輸出,這樣有效的移位長(zhǎng)度就為8。
Xilinx 官網(wǎng)的說(shuō)明——VHDL例化實(shí)例
-- SRL16: 16-bit shift register LUT operating on posedge of clock
-- All FPGAs
-- Xilinx HDL Libraries Guide version 7.1i
SRL16_inst : SRL16
-- The following generic declaration is only necessary if you wish to
-- change the initial contents of the SRL to anything other than all
-- zero‘s.
generic map (
INIT =》 X“0000”)
port map (
Q =》 Q, -- SRL data output
A0 =》 A0, -- Select[0] input
A1 =》 A1, -- Select[1] input
A2 =》 A2, -- Select[2] input
A3 =》 A3, -- Select[3] input
CLK =》 CLK, -- Clock input
D =》 D -- SRL data input
);
-- End of SRL16_inst instantiation
復(fù)制代碼
Xilinx 官網(wǎng)的說(shuō)明——Verilog例化實(shí)例
-- SRL16: 16-bit shift register LUT operating on posedge of clock
- All FPGAs
-- Xilinx HDL Libraries Guide version 7.1i
SSRL16 SRL16_inst (
.Q(Q), // SRL data output
.A0(A0), // Select[0] input
.A1(A1), // Select[1] input
.A2(A2), // Select[2] input
.A3(A3), // Select[3] input
.CLK(CLK), // Clock input
.D(D) // SRL data input
);
// The following defparam declaration is only necessary if you wish to
// change the initial contents of the SRL to anything other than all
// zero’s. If the instance name to the SRL is changed, that change
// needs to be reflected in the defparam statements.
defparam SRL16_inst.INIT = 16‘h0000;
// End of SRL16_inst instantiation
然后具體例子:
基于SRL16的分布式RAM不再支持V5、S6和V6等器件,但是SRL16是所有XIlinx器件都支持的,并且在設(shè)計(jì)中應(yīng)用非常頻繁,因此可通過(guò)調(diào)用原語(yǔ)的方法來(lái)調(diào)用SRL16E甚至SRL32E來(lái)實(shí)現(xiàn)原來(lái)ISE分布式RAM IP核的設(shè)計(jì)。下面給出一段示例代碼
module s2p_8channels_srl16(
a, d, clk, we, qspo
);
input [3:0] a;
input [4:0] d;
input clk;
input we;
output [4:0] qspo;
SRL16E #(
.INIT(16’h0000) // Initial Value of Shift Register
) SRL16_inst_1 (
.Q(qspo[0]), // SRL data output
.A0(a[0]), // Select[0] input
.A1(a[1]), // Select[1] input
.A2(a[2]), // Select[2] input
.A3(a[3]), // Select[3] input
.CE(we),
.CLK(clk), // Clock input
.D(d[0]) // SRL data input
);
SRL16E #(
.INIT(16‘h0000) // Initial Value of Shift Register
) SRL16_inst_2 (
.Q(qspo[1]), // SRL data output
.A0(a[0]), // Select[0] input
.A1(a[1]), // Select[1] input
.A2(a[2]), // Select[2] input
.A3(a[3]), // Select[3] input
.CE(we),
.CLK(clk), // Clock input
.D(d[1]) // SRL data input
);
SRL16E #(
.INIT(16’h0000) // Initial Value of Shift Register
) SRL16_inst_3 (
.Q(qspo[2]), // SRL data output
.A0(a[0]), // Select[0] input
.A1(a[1]), // Select[1] input
.A2(a[2]), // Select[2] input
.A3(a[3]), // Select[3] input
.CE(we),
.CLK(clk), // Clock input
.D(d[2]) // SRL data input
);
SRL16E #(
.INIT(16‘h0000) // Initial Value of Shift Register
) SRL16_inst_4 (
.Q(qspo[3]), // SRL data output
.A0(a[0]), // Select[0] input
.A1(a[1]), // Select[1] input
.A2(a[2]), // Select[2] input
.A3(a[3]), // Select[3] input
.CE(we),
.CLK(clk), // Clock input
.D(d[3]) // SRL data input
);
SRL16E #(
.INIT(16’h0000) // Initial Value of Shift Register
) SRL16_inst_5 (
.Q(qspo[4]), // SRL data output
.A0(a[0]), // Select[0] input
.A1(a[1]), // Select[1] input
.A2(a[2]), // Select[2] input
.A3(a[3]), // Select[3] input
.CE(we),
.CLK(clk), // Clock input
.D(d[4]) // SRL data input
);
評(píng)論
查看更多