?? write_ptr.v
字號:
//寫指針邏輯模塊
module write_ptr
#(
parameter
ADDR_WIDTH = 4
)
(
output reg [ADDR_WIDTH-1 : 0] w_ptr,
input wire rst_n,
input wire w_clk,
input wire w_req,
//讀空標志
input wire asyn_full,
output reg w_full
);
reg [ADDR_WIDTH-1 : 0] wbin;
wire [ADDR_WIDTH-1 : 0] wgnext, wbnext;
//寄存輸出gray碼寫地址指針
always @ (posedge w_clk or negedge rst_n)
if(rst_n == 1'b0)
begin
w_ptr <= 0;
wbin <= 0;
end
else
begin
w_ptr <= wgnext;
wbin <= wbnext;
end
//輸出寫滿標志
reg w_full1;
always @ (posedge w_clk or negedge asyn_full or negedge rst_n)
if(rst_n == 1'b0)
begin
w_full <= 1'b0;
w_full1 <= 1'b0;
end
else if(asyn_full == 1'b0)
begin
w_full <= 1'b1;
w_full1 <= 1'b1;
end
else
begin
w_full1 <= ~asyn_full;
w_full <= w_full1;
end
//寫地址計數
assign wbnext = (w_full == 1'b0) ? (wbin + w_req) : wbin;
//二進制到gray碼轉換
assign wgnext = (wbnext >> 1) ^ wbnext;
endmodule
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -