xilinx verilog語法技巧 一
硬件描述語言(HDL)編碼技術(shù)讓您:
?描述數(shù)字邏輯電路中最常見的功能。
?充分利用Xilinx?器件的架構(gòu)特性。
1 Flip-Flops and Registers :
Vivado綜合根據(jù)HDL代碼的編寫方式推斷出四種類型的寄存器原語:
?FDCE:具有時鐘使能和異步清除的D觸發(fā)器
?FDPE:具有時鐘使能和異步預(yù)設(shè)的D觸發(fā)器
?FDSE:具有時鐘使能和同步設(shè)置的D觸發(fā)器
?FDRE:具有時鐘使能和同步復(fù)位的D觸發(fā)器
Register with Rising-Edge Coding Example (Verilog)
// 8-bit Register with
// Rising-edge Clock
// Active-high Synchronous Clear
// Active-high Clock Enable
// File: registers_1.v
module registers_1(d_in,ce,clk,clr,dout);
input [7:0] d_in;
input ce;
input clk;
input clr;
output [7:0] dout;
reg [7:0] d_reg;
always @ (posedge clk)
begin
if(clr)
d_reg else if(ce)
d_reg end
assign dout = d_reg;
endmodule
2 Latches
// Latch with Positive Gate and Asynchronous Reset
// File: latches.v
module latches (
input G, input D, input CLR, output reg Q );
always @ *
begin
if(CLR) Q = 0; else if(G) Q = D;
end
endmodule
3 Shift Registers
移位寄存器是一系列觸發(fā)器,允許跨固定(靜態(tài))數(shù)量的延遲級傳播數(shù)據(jù)。 相反,在動態(tài)移位寄存器中,傳播鏈的長度在電路操作期間動態(tài)變化。
Vivado綜合在SRL類資源上實現(xiàn)了推斷的移位寄存器,例如:
?SRL16E
?SRLC32E
8-Bit Shift Register Coding Example One (Verilog)
// 8-bit Shift Register
// Rising edge clock
// Active high clock enable
// Concatenation-based template
// File: shift_registers_0.v
module shift_registers_0 (clk, clken, SI, SO);
parameter WIDTH = 32;
input clk, clken, SI;
output SO;
reg [WIDTH-1:0] shreg;
always @(posedge clk)
begin if (clken) shreg assign SO = shreg[WIDTH-1];
endmodule
32-Bit Shift Register Coding Example Two (Verilog)
// 32-bit Shift Register
// Rising edge clock
// Active high clock enable
// For-loop based template
// File: shift_registers_1.v
module shift_registers_1 (clk, clken, SI, SO);
parameter WIDTH = 32;
input clk, clken, SI;
output SO;
reg [WIDTH-1:0] shreg;
integer i;
always @(posedge clk)
begin
if (clken) begin for (i = 0; i end
assign SO = shreg[WIDTH-1];
endmodule
Dynamic Shift Registers
動態(tài)移位寄存器是移位寄存器,其長度可在電路操作期間動態(tài)變化。
動態(tài)移位寄存器可以看作:
?一系列觸發(fā)器,它們在電路工作期間可以接受的最大長度。
?多路復(fù)用器,在給定的時鐘周期內(nèi)選擇從傳播鏈中提取數(shù)據(jù)的階段。
32-Bit Dynamic Shift Registers Coding Example (Verilog)
// 32-bit dynamic shift register.
// Download:
// File: dynamic_shift_registers_1.v
module dynamic_shift_register_1 (CLK, CE, SEL, SI, DO);
parameter SELWIDTH = 5;
input CLK, CE, SI;
input [SELWIDTH-1:0] SEL;
output DO;
localparam DATAWIDTH = 2**SELWIDTH;
reg [DATAWIDTH-1:0] data;
assign DO = data[SEL];
always @(posedge CLK)
begin if (CE == 1'b1) data endmodule
編輯:hfy
-
移位寄存器
+關(guān)注
關(guān)注
3文章
270瀏覽量
22352
發(fā)布評論請先 登錄
相關(guān)推薦
Verilog HDL硬件描述語言(非常經(jīng)典的教材)
VERILOG HDL硬件描述語言
Verilog HDL硬件描述語言【書籍
Verilog HDL硬件描述語言_Verilog語言要素
使用Verilog/SystemVerilog硬件描述語言練習(xí)數(shù)字硬件設(shè)計
二十進(jìn)制編碼器及Verilog HDL描述 Verilog HDL程序的基本結(jié)構(gòu)及特點
![二十進(jìn)制<b class='flag-5'>編碼</b>器及<b class='flag-5'>Verilog</b> <b class='flag-5'>HDL</b><b class='flag-5'>描述</b> <b class='flag-5'>Verilog</b> <b class='flag-5'>HDL</b>程序的基本結(jié)構(gòu)及特點](https://file1.elecfans.com/web2/M00/A0/38/wKgZomTr_rGACKVfAAAOC0Y73xs441.jpg)
評論