//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// $Id: wb_dreq_periph.v,v 1.2 2008-03-05 05:50:59 hharte Exp $////
|
//// $Id: wb_dreq_periph.v,v 1.2 2008-03-05 05:50:59 hharte Exp $////
|
//// wb_dreq_periph.v - Wishbone DMA Requestor for LPC Peripheral////
|
//// wb_dreq_periph.v - Wishbone DMA Requestor for LPC Peripheral////
|
//// ////
|
//// ////
|
//// This file is part of the Wishbone LPC Bridge project ////
|
//// This file is part of the Wishbone LPC Bridge project ////
|
//// http://www.opencores.org/projects/wb_lpc/ ////
|
//// http://www.opencores.org/projects/wb_lpc/ ////
|
//// ////
|
//// ////
|
//// Author: ////
|
//// Author: ////
|
//// - Howard M. Harte (hharte@opencores.org) ////
|
//// - Howard M. Harte (hharte@opencores.org) ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2008 Howard M. Harte ////
|
//// Copyright (C) 2008 Howard M. Harte ////
|
//// ////
|
//// ////
|
//// 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; ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// later version. ////
|
//// later version. ////
|
//// ////
|
//// ////
|
//// 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. ////
|
//// details. ////
|
//// ////
|
//// ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// Public License along with this source; if not, download it ////
|
//// Public License along with this source; if not, download it ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
|
|
`timescale 1 ns / 1 ns
|
`timescale 1 ns / 1 ns
|
|
|
`include "../../rtl/verilog/wb_lpc_defines.v"
|
`include "../../rtl/verilog/wb_lpc_defines.v"
|
|
|
module wb_dreq_periph(clk_i, nrst_i,
|
module wb_dreq_periph(clk_i, nrst_i,
|
dma_chan_i, dma_req_i,
|
dma_chan_i, dma_req_i,
|
ldrq_o
|
ldrq_o
|
);
|
);
|
// Wishbone Slave Interface
|
// Wishbone Slave Interface
|
input clk_i;
|
input clk_i;
|
input nrst_i; // Active low reset.
|
input nrst_i; // Active low reset.
|
|
|
// Private DMA Interface
|
// Private DMA Interface
|
input [2:0] dma_chan_i;
|
input [2:0] dma_chan_i;
|
input dma_req_i;
|
input dma_req_i;
|
|
|
// LPC Bus DMA Request Output
|
// LPC Bus DMA Request Output
|
output reg ldrq_o;
|
output reg ldrq_o;
|
|
|
reg [1:0] adr_cnt;
|
reg [1:0] adr_cnt;
|
reg [3:0] state;
|
reg [3:0] state;
|
|
|
always @(posedge clk_i or negedge nrst_i)
|
always @(posedge clk_i or negedge nrst_i)
|
if(~nrst_i)
|
if(~nrst_i)
|
begin
|
begin
|
state <= `LDRQ_ST_IDLE;
|
state <= `LDRQ_ST_IDLE;
|
ldrq_o <= 1'b1; // LDRQ# Idle
|
ldrq_o <= 1'b1; // LDRQ# Idle
|
adr_cnt <= 2'b00;
|
adr_cnt <= 2'b00;
|
end
|
end
|
else begin
|
else begin
|
case(state)
|
case(state)
|
`LDRQ_ST_IDLE:
|
`LDRQ_ST_IDLE:
|
begin
|
begin
|
if(dma_req_i) begin
|
if(dma_req_i) begin
|
ldrq_o <= 1'b0;
|
ldrq_o <= 1'b0;
|
state <= `LDRQ_ST_ADDR;
|
state <= `LDRQ_ST_ADDR;
|
adr_cnt <= 2'h2;
|
adr_cnt <= 2'h2;
|
end
|
end
|
end
|
end
|
`LDRQ_ST_ADDR:
|
`LDRQ_ST_ADDR:
|
begin
|
begin
|
ldrq_o <= dma_chan_i[adr_cnt];
|
ldrq_o <= dma_chan_i[adr_cnt];
|
adr_cnt <= adr_cnt - 1;
|
adr_cnt <= adr_cnt - 1;
|
|
|
if(adr_cnt == 2'h0)
|
if(adr_cnt == 2'h0)
|
state <= `LDRQ_ST_ACT;
|
state <= `LDRQ_ST_ACT;
|
end
|
end
|
`LDRQ_ST_ACT:
|
`LDRQ_ST_ACT:
|
begin
|
begin
|
ldrq_o <= 1'b1;
|
ldrq_o <= 1'b1;
|
state <= `LDRQ_ST_DONE;
|
state <= `LDRQ_ST_DONE;
|
end
|
end
|
`LDRQ_ST_DONE:
|
`LDRQ_ST_DONE:
|
begin
|
begin
|
ldrq_o <= 1'b1;
|
ldrq_o <= 1'b1;
|
state <= `LDRQ_ST_IDLE;
|
state <= `LDRQ_ST_IDLE;
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|
|
|