<##//////////////////////////////////////////////////////////////////
|
<##//////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Author: Eyal Hochberg ////
|
//// Author: Eyal Hochberg ////
|
//// eyal@provartec.com ////
|
//// eyal@provartec.com ////
|
//// ////
|
//// ////
|
//// Downloaded from: http://www.opencores.org ////
|
//// Downloaded from: http://www.opencores.org ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2010 Provartec LTD ////
|
//// Copyright (C) 2010 Provartec LTD ////
|
//// www.provartec.com ////
|
//// www.provartec.com ////
|
//// info@provartec.com ////
|
//// info@provartec.com ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer.////
|
//// the original copyright notice and the associated disclaimer.////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation.////
|
//// Public License as published by the Free Software Foundation.////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more////
|
//// PURPOSE. See the GNU Lesser General Public License for more////
|
//// details. http://www.gnu.org/licenses/lgpl.html ////
|
//// details. http://www.gnu.org/licenses/lgpl.html ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////##>
|
//////////////////////////////////////////////////////////////////##>
|
|
|
INCLUDE def_axi2apb.txt
|
INCLUDE def_axi2apb.txt
|
OUTFILE PREFIX_ctrl.v
|
OUTFILE PREFIX_ctrl.v
|
|
|
module PREFIX_ctrl (PORTS);
|
module PREFIX_ctrl (PORTS);
|
|
|
|
|
input clk;
|
input clk;
|
input reset;
|
input reset;
|
|
|
input finish_wr;
|
input finish_wr;
|
input finish_rd;
|
input finish_rd;
|
|
|
input cmd_empty;
|
input cmd_empty;
|
input cmd_read;
|
input cmd_read;
|
input WVALID;
|
input WVALID;
|
|
|
output psel;
|
output psel;
|
output penable;
|
output penable;
|
output pwrite;
|
output pwrite;
|
input pready;
|
input pready;
|
|
|
|
|
wire wstart;
|
wire wstart;
|
wire rstart;
|
wire rstart;
|
|
|
reg busy;
|
reg busy;
|
reg psel;
|
reg psel;
|
reg penable;
|
reg penable;
|
reg pwrite;
|
reg pwrite;
|
wire pack;
|
wire pack;
|
wire cmd_ready;
|
wire cmd_ready;
|
|
|
|
|
assign cmd_ready = (~busy) & (~cmd_empty);
|
assign cmd_ready = (~busy) & (~cmd_empty);
|
assign wstart = cmd_ready & (~cmd_read) & (~psel) & WVALID;
|
assign wstart = cmd_ready & (~cmd_read) & (~psel) & WVALID;
|
assign rstart = cmd_ready & cmd_read & (~psel);
|
assign rstart = cmd_ready & cmd_read & (~psel);
|
|
|
assign pack = psel & penable & pready;
|
assign pack = psel & penable & pready;
|
|
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
busy <= #FFD 1'b0;
|
busy <= #FFD 1'b0;
|
else if (psel)
|
else if (psel)
|
busy <= #FFD 1'b1;
|
busy <= #FFD 1'b1;
|
else if (finish_rd | finish_wr)
|
else if (finish_rd | finish_wr)
|
busy <= #FFD 1'b0;
|
busy <= #FFD 1'b0;
|
|
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
psel <= #FFD 1'b0;
|
psel <= #FFD 1'b0;
|
else if (pack)
|
else if (pack)
|
psel <= #FFD 1'b0;
|
psel <= #FFD 1'b0;
|
else if (wstart | rstart)
|
else if (wstart | rstart)
|
psel <= #FFD 1'b1;
|
psel <= #FFD 1'b1;
|
|
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
penable <= #FFD 1'b0;
|
penable <= #FFD 1'b0;
|
else if (pack)
|
else if (pack)
|
penable <= #FFD 1'b0;
|
penable <= #FFD 1'b0;
|
else if (psel)
|
else if (psel)
|
penable <= #FFD 1'b1;
|
penable <= #FFD 1'b1;
|
|
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
pwrite <= #FFD 1'b0;
|
pwrite <= #FFD 1'b0;
|
else if (pack)
|
else if (pack)
|
pwrite <= #FFD 1'b0;
|
pwrite <= #FFD 1'b0;
|
else if (wstart)
|
else if (wstart)
|
pwrite <= #FFD 1'b1;
|
pwrite <= #FFD 1'b1;
|
|
|
|
|
endmodule
|
endmodule
|
|
|
|
|
|
|