//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// eth_cop.v ////
|
//// eth_cop.v ////
|
//// ////
|
//// ////
|
//// This file is part of the Ethernet IP core project ////
|
//// This file is part of the Ethernet IP core project ////
|
//// http://www.opencores.org/project,ethmac ////
|
//// http://www.opencores.org/project,ethmac ////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Igor Mohor (igorM@opencores.org) ////
|
//// - Igor Mohor (igorM@opencores.org) ////
|
//// ////
|
//// ////
|
//// All additional information is avaliable in the Readme.txt ////
|
//// All additional information is avaliable in the Readme.txt ////
|
//// file. ////
|
//// file. ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2001, 2002 Authors ////
|
//// Copyright (C) 2001, 2002 Authors ////
|
//// ////
|
//// ////
|
//// 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 ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
// Revision 1.3 2002/10/10 16:43:59 mohor
|
// Revision 1.3 2002/10/10 16:43:59 mohor
|
// Minor $display change.
|
// Minor $display change.
|
//
|
//
|
// Revision 1.2 2002/09/09 12:54:13 mohor
|
// Revision 1.2 2002/09/09 12:54:13 mohor
|
// error acknowledge cycle termination added to display.
|
// error acknowledge cycle termination added to display.
|
//
|
//
|
// Revision 1.1 2002/08/14 17:16:07 mohor
|
// Revision 1.1 2002/08/14 17:16:07 mohor
|
// Traffic cop with 2 wishbone master interfaces and 2 wishbona slave
|
// Traffic cop with 2 wishbone master interfaces and 2 wishbona slave
|
// interfaces:
|
// interfaces:
|
// - Host connects to the master interface
|
// - Host connects to the master interface
|
// - Ethernet master (DMA) connects to the second master interface
|
// - Ethernet master (DMA) connects to the second master interface
|
// - Memory interface connects to the slave interface
|
// - Memory interface connects to the slave interface
|
// - Ethernet slave interface (access to registers and BDs) connects to second
|
// - Ethernet slave interface (access to registers and BDs) connects to second
|
// slave interface
|
// slave interface
|
//
|
//
|
//
|
//
|
//
|
//
|
//
|
//
|
//
|
//
|
|
|
`include "eth_defines.v"
|
|
`include "timescale.v"
|
`include "timescale.v"
|
|
|
module eth_cop
|
module eth_cop
|
(
|
(
|
// WISHBONE common
|
// WISHBONE common
|
wb_clk_i, wb_rst_i,
|
wb_clk_i, wb_rst_i,
|
|
|
// WISHBONE MASTER 1
|
// WISHBONE MASTER 1
|
m1_wb_adr_i, m1_wb_sel_i, m1_wb_we_i, m1_wb_dat_o,
|
m1_wb_adr_i, m1_wb_sel_i, m1_wb_we_i, m1_wb_dat_o,
|
m1_wb_dat_i, m1_wb_cyc_i, m1_wb_stb_i, m1_wb_ack_o,
|
m1_wb_dat_i, m1_wb_cyc_i, m1_wb_stb_i, m1_wb_ack_o,
|
m1_wb_err_o,
|
m1_wb_err_o,
|
|
|
// WISHBONE MASTER 2
|
// WISHBONE MASTER 2
|
m2_wb_adr_i, m2_wb_sel_i, m2_wb_we_i, m2_wb_dat_o,
|
m2_wb_adr_i, m2_wb_sel_i, m2_wb_we_i, m2_wb_dat_o,
|
m2_wb_dat_i, m2_wb_cyc_i, m2_wb_stb_i, m2_wb_ack_o,
|
m2_wb_dat_i, m2_wb_cyc_i, m2_wb_stb_i, m2_wb_ack_o,
|
m2_wb_err_o,
|
m2_wb_err_o,
|
|
|
// WISHBONE slave 1
|
// WISHBONE slave 1
|
s1_wb_adr_o, s1_wb_sel_o, s1_wb_we_o, s1_wb_cyc_o,
|
s1_wb_adr_o, s1_wb_sel_o, s1_wb_we_o, s1_wb_cyc_o,
|
s1_wb_stb_o, s1_wb_ack_i, s1_wb_err_i, s1_wb_dat_i,
|
s1_wb_stb_o, s1_wb_ack_i, s1_wb_err_i, s1_wb_dat_i,
|
s1_wb_dat_o,
|
s1_wb_dat_o,
|
|
|
// WISHBONE slave 2
|
// WISHBONE slave 2
|
s2_wb_adr_o, s2_wb_sel_o, s2_wb_we_o, s2_wb_cyc_o,
|
s2_wb_adr_o, s2_wb_sel_o, s2_wb_we_o, s2_wb_cyc_o,
|
s2_wb_stb_o, s2_wb_ack_i, s2_wb_err_i, s2_wb_dat_i,
|
s2_wb_stb_o, s2_wb_ack_i, s2_wb_err_i, s2_wb_dat_i,
|
s2_wb_dat_o
|
s2_wb_dat_o
|
);
|
);
|
|
|
parameter Tp=1;
|
parameter Tp=1;
|
|
parameter ETH_BASE = 32'hd0000000;
|
|
parameter ETH_WIDTH = 32'h800;
|
|
parameter MEMORY_BASE = 32'h2000;
|
|
parameter MEMORY_WIDTH = 32'h10000;
|
|
|
// WISHBONE common
|
// WISHBONE common
|
input wb_clk_i, wb_rst_i;
|
input wb_clk_i, wb_rst_i;
|
|
|
// WISHBONE MASTER 1
|
// WISHBONE MASTER 1
|
input [31:0] m1_wb_adr_i, m1_wb_dat_i;
|
input [31:0] m1_wb_adr_i, m1_wb_dat_i;
|
input [3:0] m1_wb_sel_i;
|
input [3:0] m1_wb_sel_i;
|
input m1_wb_cyc_i, m1_wb_stb_i, m1_wb_we_i;
|
input m1_wb_cyc_i, m1_wb_stb_i, m1_wb_we_i;
|
output [31:0] m1_wb_dat_o;
|
output [31:0] m1_wb_dat_o;
|
output m1_wb_ack_o, m1_wb_err_o;
|
output m1_wb_ack_o, m1_wb_err_o;
|
|
|
// WISHBONE MASTER 2
|
// WISHBONE MASTER 2
|
input [31:0] m2_wb_adr_i, m2_wb_dat_i;
|
input [31:0] m2_wb_adr_i, m2_wb_dat_i;
|
input [3:0] m2_wb_sel_i;
|
input [3:0] m2_wb_sel_i;
|
input m2_wb_cyc_i, m2_wb_stb_i, m2_wb_we_i;
|
input m2_wb_cyc_i, m2_wb_stb_i, m2_wb_we_i;
|
output [31:0] m2_wb_dat_o;
|
output [31:0] m2_wb_dat_o;
|
output m2_wb_ack_o, m2_wb_err_o;
|
output m2_wb_ack_o, m2_wb_err_o;
|
|
|
// WISHBONE slave 1
|
// WISHBONE slave 1
|
input [31:0] s1_wb_dat_i;
|
input [31:0] s1_wb_dat_i;
|
input s1_wb_ack_i, s1_wb_err_i;
|
input s1_wb_ack_i, s1_wb_err_i;
|
output [31:0] s1_wb_adr_o, s1_wb_dat_o;
|
output [31:0] s1_wb_adr_o, s1_wb_dat_o;
|
output [3:0] s1_wb_sel_o;
|
output [3:0] s1_wb_sel_o;
|
output s1_wb_we_o, s1_wb_cyc_o, s1_wb_stb_o;
|
output s1_wb_we_o, s1_wb_cyc_o, s1_wb_stb_o;
|
|
|
// WISHBONE slave 2
|
// WISHBONE slave 2
|
input [31:0] s2_wb_dat_i;
|
input [31:0] s2_wb_dat_i;
|
input s2_wb_ack_i, s2_wb_err_i;
|
input s2_wb_ack_i, s2_wb_err_i;
|
output [31:0] s2_wb_adr_o, s2_wb_dat_o;
|
output [31:0] s2_wb_adr_o, s2_wb_dat_o;
|
output [3:0] s2_wb_sel_o;
|
output [3:0] s2_wb_sel_o;
|
output s2_wb_we_o, s2_wb_cyc_o, s2_wb_stb_o;
|
output s2_wb_we_o, s2_wb_cyc_o, s2_wb_stb_o;
|
|
|
reg m1_in_progress;
|
reg m1_in_progress;
|
reg m2_in_progress;
|
reg m2_in_progress;
|
reg [31:0] s1_wb_adr_o;
|
reg [31:0] s1_wb_adr_o;
|
reg [3:0] s1_wb_sel_o;
|
reg [3:0] s1_wb_sel_o;
|
reg s1_wb_we_o;
|
reg s1_wb_we_o;
|
reg [31:0] s1_wb_dat_o;
|
reg [31:0] s1_wb_dat_o;
|
reg s1_wb_cyc_o;
|
reg s1_wb_cyc_o;
|
reg s1_wb_stb_o;
|
reg s1_wb_stb_o;
|
reg [31:0] s2_wb_adr_o;
|
reg [31:0] s2_wb_adr_o;
|
reg [3:0] s2_wb_sel_o;
|
reg [3:0] s2_wb_sel_o;
|
reg s2_wb_we_o;
|
reg s2_wb_we_o;
|
reg [31:0] s2_wb_dat_o;
|
reg [31:0] s2_wb_dat_o;
|
reg s2_wb_cyc_o;
|
reg s2_wb_cyc_o;
|
reg s2_wb_stb_o;
|
reg s2_wb_stb_o;
|
|
|
reg m1_wb_ack_o;
|
reg m1_wb_ack_o;
|
reg [31:0] m1_wb_dat_o;
|
reg [31:0] m1_wb_dat_o;
|
reg m2_wb_ack_o;
|
reg m2_wb_ack_o;
|
reg [31:0] m2_wb_dat_o;
|
reg [31:0] m2_wb_dat_o;
|
|
|
reg m1_wb_err_o;
|
reg m1_wb_err_o;
|
reg m2_wb_err_o;
|
reg m2_wb_err_o;
|
|
|
wire m_wb_access_finished;
|
wire m_wb_access_finished;
|
wire m1_addressed_s1 = (m1_wb_adr_i >= `ETH_BASE) &
|
wire m1_addressed_s1 = (m1_wb_adr_i >= ETH_BASE) &
|
(m1_wb_adr_i < (`ETH_BASE + `ETH_WIDTH));
|
(m1_wb_adr_i < (ETH_BASE + ETH_WIDTH));
|
wire m1_addressed_s2 = (m1_wb_adr_i >= `MEMORY_BASE) &
|
wire m1_addressed_s2 = (m1_wb_adr_i >= MEMORY_BASE) &
|
(m1_wb_adr_i < (`MEMORY_BASE + `MEMORY_WIDTH));
|
(m1_wb_adr_i < (MEMORY_BASE + MEMORY_WIDTH));
|
wire m2_addressed_s1 = (m2_wb_adr_i >= `ETH_BASE) &
|
wire m2_addressed_s1 = (m2_wb_adr_i >= ETH_BASE) &
|
(m2_wb_adr_i < (`ETH_BASE + `ETH_WIDTH));
|
(m2_wb_adr_i < (ETH_BASE + ETH_WIDTH));
|
wire m2_addressed_s2 = (m2_wb_adr_i >= `MEMORY_BASE) &
|
wire m2_addressed_s2 = (m2_wb_adr_i >= MEMORY_BASE) &
|
(m2_wb_adr_i < (`MEMORY_BASE + `MEMORY_WIDTH));
|
(m2_wb_adr_i < (MEMORY_BASE + MEMORY_WIDTH));
|
|
|
wire m1_req = m1_wb_cyc_i & m1_wb_stb_i & (m1_addressed_s1 | m1_addressed_s2);
|
wire m1_req = m1_wb_cyc_i & m1_wb_stb_i & (m1_addressed_s1 | m1_addressed_s2);
|
wire m2_req = m2_wb_cyc_i & m2_wb_stb_i & (m2_addressed_s1 | m2_addressed_s2);
|
wire m2_req = m2_wb_cyc_i & m2_wb_stb_i & (m2_addressed_s1 | m2_addressed_s2);
|
|
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
begin
|
begin
|
if(wb_rst_i)
|
if(wb_rst_i)
|
begin
|
begin
|
m1_in_progress <=#Tp 0;
|
m1_in_progress <=#Tp 0;
|
m2_in_progress <=#Tp 0;
|
m2_in_progress <=#Tp 0;
|
s1_wb_adr_o <=#Tp 0;
|
s1_wb_adr_o <=#Tp 0;
|
s1_wb_sel_o <=#Tp 0;
|
s1_wb_sel_o <=#Tp 0;
|
s1_wb_we_o <=#Tp 0;
|
s1_wb_we_o <=#Tp 0;
|
s1_wb_dat_o <=#Tp 0;
|
s1_wb_dat_o <=#Tp 0;
|
s1_wb_cyc_o <=#Tp 0;
|
s1_wb_cyc_o <=#Tp 0;
|
s1_wb_stb_o <=#Tp 0;
|
s1_wb_stb_o <=#Tp 0;
|
s2_wb_adr_o <=#Tp 0;
|
s2_wb_adr_o <=#Tp 0;
|
s2_wb_sel_o <=#Tp 0;
|
s2_wb_sel_o <=#Tp 0;
|
s2_wb_we_o <=#Tp 0;
|
s2_wb_we_o <=#Tp 0;
|
s2_wb_dat_o <=#Tp 0;
|
s2_wb_dat_o <=#Tp 0;
|
s2_wb_cyc_o <=#Tp 0;
|
s2_wb_cyc_o <=#Tp 0;
|
s2_wb_stb_o <=#Tp 0;
|
s2_wb_stb_o <=#Tp 0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
case({m1_in_progress, m2_in_progress, m1_req, m2_req, m_wb_access_finished}) // synopsys_full_case synopsys_paralel_case
|
case({m1_in_progress, m2_in_progress, m1_req, m2_req, m_wb_access_finished}) // synopsys_full_case synopsys_paralel_case
|
5'b00_10_0, 5'b00_11_0 :
|
5'b00_10_0, 5'b00_11_0 :
|
begin
|
begin
|
m1_in_progress <=#Tp 1'b1; // idle: m1 or (m1 & m2) want access: m1 -> m
|
m1_in_progress <=#Tp 1'b1; // idle: m1 or (m1 & m2) want access: m1 -> m
|
if(m1_addressed_s1)
|
if(m1_addressed_s1)
|
begin
|
begin
|
s1_wb_adr_o <=#Tp m1_wb_adr_i;
|
s1_wb_adr_o <=#Tp m1_wb_adr_i;
|
s1_wb_sel_o <=#Tp m1_wb_sel_i;
|
s1_wb_sel_o <=#Tp m1_wb_sel_i;
|
s1_wb_we_o <=#Tp m1_wb_we_i;
|
s1_wb_we_o <=#Tp m1_wb_we_i;
|
s1_wb_dat_o <=#Tp m1_wb_dat_i;
|
s1_wb_dat_o <=#Tp m1_wb_dat_i;
|
s1_wb_cyc_o <=#Tp 1'b1;
|
s1_wb_cyc_o <=#Tp 1'b1;
|
s1_wb_stb_o <=#Tp 1'b1;
|
s1_wb_stb_o <=#Tp 1'b1;
|
end
|
end
|
else if(m1_addressed_s2)
|
else if(m1_addressed_s2)
|
begin
|
begin
|
s2_wb_adr_o <=#Tp m1_wb_adr_i;
|
s2_wb_adr_o <=#Tp m1_wb_adr_i;
|
s2_wb_sel_o <=#Tp m1_wb_sel_i;
|
s2_wb_sel_o <=#Tp m1_wb_sel_i;
|
s2_wb_we_o <=#Tp m1_wb_we_i;
|
s2_wb_we_o <=#Tp m1_wb_we_i;
|
s2_wb_dat_o <=#Tp m1_wb_dat_i;
|
s2_wb_dat_o <=#Tp m1_wb_dat_i;
|
s2_wb_cyc_o <=#Tp 1'b1;
|
s2_wb_cyc_o <=#Tp 1'b1;
|
s2_wb_stb_o <=#Tp 1'b1;
|
s2_wb_stb_o <=#Tp 1'b1;
|
end
|
end
|
else
|
else
|
$display("(%t)(%m)WISHBONE ERROR: Unspecified address space accessed", $time);
|
$display("(%t)(%m)WISHBONE ERROR: Unspecified address space accessed", $time);
|
end
|
end
|
5'b00_01_0 :
|
5'b00_01_0 :
|
begin
|
begin
|
m2_in_progress <=#Tp 1'b1; // idle: m2 wants access: m2 -> m
|
m2_in_progress <=#Tp 1'b1; // idle: m2 wants access: m2 -> m
|
if(m2_addressed_s1)
|
if(m2_addressed_s1)
|
begin
|
begin
|
s1_wb_adr_o <=#Tp m2_wb_adr_i;
|
s1_wb_adr_o <=#Tp m2_wb_adr_i;
|
s1_wb_sel_o <=#Tp m2_wb_sel_i;
|
s1_wb_sel_o <=#Tp m2_wb_sel_i;
|
s1_wb_we_o <=#Tp m2_wb_we_i;
|
s1_wb_we_o <=#Tp m2_wb_we_i;
|
s1_wb_dat_o <=#Tp m2_wb_dat_i;
|
s1_wb_dat_o <=#Tp m2_wb_dat_i;
|
s1_wb_cyc_o <=#Tp 1'b1;
|
s1_wb_cyc_o <=#Tp 1'b1;
|
s1_wb_stb_o <=#Tp 1'b1;
|
s1_wb_stb_o <=#Tp 1'b1;
|
end
|
end
|
else if(m2_addressed_s2)
|
else if(m2_addressed_s2)
|
begin
|
begin
|
s2_wb_adr_o <=#Tp m2_wb_adr_i;
|
s2_wb_adr_o <=#Tp m2_wb_adr_i;
|
s2_wb_sel_o <=#Tp m2_wb_sel_i;
|
s2_wb_sel_o <=#Tp m2_wb_sel_i;
|
s2_wb_we_o <=#Tp m2_wb_we_i;
|
s2_wb_we_o <=#Tp m2_wb_we_i;
|
s2_wb_dat_o <=#Tp m2_wb_dat_i;
|
s2_wb_dat_o <=#Tp m2_wb_dat_i;
|
s2_wb_cyc_o <=#Tp 1'b1;
|
s2_wb_cyc_o <=#Tp 1'b1;
|
s2_wb_stb_o <=#Tp 1'b1;
|
s2_wb_stb_o <=#Tp 1'b1;
|
end
|
end
|
else
|
else
|
$display("(%t)(%m)WISHBONE ERROR: Unspecified address space accessed", $time);
|
$display("(%t)(%m)WISHBONE ERROR: Unspecified address space accessed", $time);
|
end
|
end
|
5'b10_10_1, 5'b10_11_1 :
|
5'b10_10_1, 5'b10_11_1 :
|
begin
|
begin
|
m1_in_progress <=#Tp 1'b0; // m1 in progress. Cycle is finished. Send ack or err to m1.
|
m1_in_progress <=#Tp 1'b0; // m1 in progress. Cycle is finished. Send ack or err to m1.
|
if(m1_addressed_s1)
|
if(m1_addressed_s1)
|
begin
|
begin
|
s1_wb_cyc_o <=#Tp 1'b0;
|
s1_wb_cyc_o <=#Tp 1'b0;
|
s1_wb_stb_o <=#Tp 1'b0;
|
s1_wb_stb_o <=#Tp 1'b0;
|
end
|
end
|
else if(m1_addressed_s2)
|
else if(m1_addressed_s2)
|
begin
|
begin
|
s2_wb_cyc_o <=#Tp 1'b0;
|
s2_wb_cyc_o <=#Tp 1'b0;
|
s2_wb_stb_o <=#Tp 1'b0;
|
s2_wb_stb_o <=#Tp 1'b0;
|
end
|
end
|
end
|
end
|
5'b01_01_1, 5'b01_11_1 :
|
5'b01_01_1, 5'b01_11_1 :
|
begin
|
begin
|
m2_in_progress <=#Tp 1'b0; // m2 in progress. Cycle is finished. Send ack or err to m2.
|
m2_in_progress <=#Tp 1'b0; // m2 in progress. Cycle is finished. Send ack or err to m2.
|
if(m2_addressed_s1)
|
if(m2_addressed_s1)
|
begin
|
begin
|
s1_wb_cyc_o <=#Tp 1'b0;
|
s1_wb_cyc_o <=#Tp 1'b0;
|
s1_wb_stb_o <=#Tp 1'b0;
|
s1_wb_stb_o <=#Tp 1'b0;
|
end
|
end
|
else if(m2_addressed_s2)
|
else if(m2_addressed_s2)
|
begin
|
begin
|
s2_wb_cyc_o <=#Tp 1'b0;
|
s2_wb_cyc_o <=#Tp 1'b0;
|
s2_wb_stb_o <=#Tp 1'b0;
|
s2_wb_stb_o <=#Tp 1'b0;
|
end
|
end
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
|
|
// Generating Ack for master 1
|
// Generating Ack for master 1
|
always @ (m1_in_progress or m1_wb_adr_i or s1_wb_ack_i or s2_wb_ack_i or s1_wb_dat_i or s2_wb_dat_i or m1_addressed_s1 or m1_addressed_s2)
|
always @ (m1_in_progress or m1_wb_adr_i or s1_wb_ack_i or s2_wb_ack_i or s1_wb_dat_i or s2_wb_dat_i or m1_addressed_s1 or m1_addressed_s2)
|
begin
|
begin
|
if(m1_in_progress)
|
if(m1_in_progress)
|
begin
|
begin
|
if(m1_addressed_s1) begin
|
if(m1_addressed_s1) begin
|
m1_wb_ack_o <= s1_wb_ack_i;
|
m1_wb_ack_o <= s1_wb_ack_i;
|
m1_wb_dat_o <= s1_wb_dat_i;
|
m1_wb_dat_o <= s1_wb_dat_i;
|
end
|
end
|
else if(m1_addressed_s2) begin
|
else if(m1_addressed_s2) begin
|
m1_wb_ack_o <= s2_wb_ack_i;
|
m1_wb_ack_o <= s2_wb_ack_i;
|
m1_wb_dat_o <= s2_wb_dat_i;
|
m1_wb_dat_o <= s2_wb_dat_i;
|
end
|
end
|
end
|
end
|
else
|
else
|
m1_wb_ack_o <= 0;
|
m1_wb_ack_o <= 0;
|
end
|
end
|
|
|
|
|
// Generating Ack for master 2
|
// Generating Ack for master 2
|
always @ (m2_in_progress or m2_wb_adr_i or s1_wb_ack_i or s2_wb_ack_i or s1_wb_dat_i or s2_wb_dat_i or m2_addressed_s1 or m2_addressed_s2)
|
always @ (m2_in_progress or m2_wb_adr_i or s1_wb_ack_i or s2_wb_ack_i or s1_wb_dat_i or s2_wb_dat_i or m2_addressed_s1 or m2_addressed_s2)
|
begin
|
begin
|
if(m2_in_progress)
|
if(m2_in_progress)
|
begin
|
begin
|
if(m2_addressed_s1) begin
|
if(m2_addressed_s1) begin
|
m2_wb_ack_o <= s1_wb_ack_i;
|
m2_wb_ack_o <= s1_wb_ack_i;
|
m2_wb_dat_o <= s1_wb_dat_i;
|
m2_wb_dat_o <= s1_wb_dat_i;
|
end
|
end
|
else if(m2_addressed_s2) begin
|
else if(m2_addressed_s2) begin
|
m2_wb_ack_o <= s2_wb_ack_i;
|
m2_wb_ack_o <= s2_wb_ack_i;
|
m2_wb_dat_o <= s2_wb_dat_i;
|
m2_wb_dat_o <= s2_wb_dat_i;
|
end
|
end
|
end
|
end
|
else
|
else
|
m2_wb_ack_o <= 0;
|
m2_wb_ack_o <= 0;
|
end
|
end
|
|
|
|
|
// Generating Err for master 1
|
// Generating Err for master 1
|
always @ (m1_in_progress or m1_wb_adr_i or s1_wb_err_i or s2_wb_err_i or m2_addressed_s1 or m2_addressed_s2 or
|
always @ (m1_in_progress or m1_wb_adr_i or s1_wb_err_i or s2_wb_err_i or m2_addressed_s1 or m2_addressed_s2 or
|
m1_wb_cyc_i or m1_wb_stb_i)
|
m1_wb_cyc_i or m1_wb_stb_i)
|
begin
|
begin
|
if(m1_in_progress) begin
|
if(m1_in_progress) begin
|
if(m1_addressed_s1)
|
if(m1_addressed_s1)
|
m1_wb_err_o <= s1_wb_err_i;
|
m1_wb_err_o <= s1_wb_err_i;
|
else if(m1_addressed_s2)
|
else if(m1_addressed_s2)
|
m1_wb_err_o <= s2_wb_err_i;
|
m1_wb_err_o <= s2_wb_err_i;
|
end
|
end
|
else if(m1_wb_cyc_i & m1_wb_stb_i & ~m1_addressed_s1 & ~m1_addressed_s2)
|
else if(m1_wb_cyc_i & m1_wb_stb_i & ~m1_addressed_s1 & ~m1_addressed_s2)
|
m1_wb_err_o <= 1'b1;
|
m1_wb_err_o <= 1'b1;
|
else
|
else
|
m1_wb_err_o <= 1'b0;
|
m1_wb_err_o <= 1'b0;
|
end
|
end
|
|
|
|
|
// Generating Err for master 2
|
// Generating Err for master 2
|
always @ (m2_in_progress or m2_wb_adr_i or s1_wb_err_i or s2_wb_err_i or m2_addressed_s1 or m2_addressed_s2 or
|
always @ (m2_in_progress or m2_wb_adr_i or s1_wb_err_i or s2_wb_err_i or m2_addressed_s1 or m2_addressed_s2 or
|
m2_wb_cyc_i or m2_wb_stb_i)
|
m2_wb_cyc_i or m2_wb_stb_i)
|
begin
|
begin
|
if(m2_in_progress) begin
|
if(m2_in_progress) begin
|
if(m2_addressed_s1)
|
if(m2_addressed_s1)
|
m2_wb_err_o <= s1_wb_err_i;
|
m2_wb_err_o <= s1_wb_err_i;
|
else if(m2_addressed_s2)
|
else if(m2_addressed_s2)
|
m2_wb_err_o <= s2_wb_err_i;
|
m2_wb_err_o <= s2_wb_err_i;
|
end
|
end
|
else if(m2_wb_cyc_i & m2_wb_stb_i & ~m2_addressed_s1 & ~m2_addressed_s2)
|
else if(m2_wb_cyc_i & m2_wb_stb_i & ~m2_addressed_s1 & ~m2_addressed_s2)
|
m2_wb_err_o <= 1'b1;
|
m2_wb_err_o <= 1'b1;
|
else
|
else
|
m2_wb_err_o <= 1'b0;
|
m2_wb_err_o <= 1'b0;
|
end
|
end
|
|
|
|
|
assign m_wb_access_finished = m1_wb_ack_o | m1_wb_err_o | m2_wb_ack_o | m2_wb_err_o;
|
assign m_wb_access_finished = m1_wb_ack_o | m1_wb_err_o | m2_wb_ack_o | m2_wb_err_o;
|
|
|
|
|
// Activity monitor
|
// Activity monitor
|
integer cnt;
|
integer cnt;
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
begin
|
begin
|
if(wb_rst_i)
|
if(wb_rst_i)
|
cnt <=#Tp 0;
|
cnt <=#Tp 0;
|
else
|
else
|
if(s1_wb_ack_i | s1_wb_err_i | s2_wb_ack_i | s2_wb_err_i)
|
if(s1_wb_ack_i | s1_wb_err_i | s2_wb_ack_i | s2_wb_err_i)
|
cnt <=#Tp 0;
|
cnt <=#Tp 0;
|
else
|
else
|
if(s1_wb_cyc_o | s2_wb_cyc_o)
|
if(s1_wb_cyc_o | s2_wb_cyc_o)
|
cnt <=#Tp cnt+1;
|
cnt <=#Tp cnt+1;
|
end
|
end
|
|
|
always @ (posedge wb_clk_i)
|
always @ (posedge wb_clk_i)
|
begin
|
begin
|
if(cnt==1000) begin
|
if(cnt==1000) begin
|
$display("(%0t)(%m) ERROR: WB activity ??? ", $time);
|
$display("(%0t)(%m) ERROR: WB activity ??? ", $time);
|
if(s1_wb_cyc_o) begin
|
if(s1_wb_cyc_o) begin
|
$display("s1_wb_dat_o = 0x%0x", s1_wb_dat_o);
|
$display("s1_wb_dat_o = 0x%0x", s1_wb_dat_o);
|
$display("s1_wb_adr_o = 0x%0x", s1_wb_adr_o);
|
$display("s1_wb_adr_o = 0x%0x", s1_wb_adr_o);
|
$display("s1_wb_sel_o = 0x%0x", s1_wb_sel_o);
|
$display("s1_wb_sel_o = 0x%0x", s1_wb_sel_o);
|
$display("s1_wb_we_o = 0x%0x", s1_wb_we_o);
|
$display("s1_wb_we_o = 0x%0x", s1_wb_we_o);
|
end
|
end
|
else if(s2_wb_cyc_o) begin
|
else if(s2_wb_cyc_o) begin
|
$display("s2_wb_dat_o = 0x%0x", s2_wb_dat_o);
|
$display("s2_wb_dat_o = 0x%0x", s2_wb_dat_o);
|
$display("s2_wb_adr_o = 0x%0x", s2_wb_adr_o);
|
$display("s2_wb_adr_o = 0x%0x", s2_wb_adr_o);
|
$display("s2_wb_sel_o = 0x%0x", s2_wb_sel_o);
|
$display("s2_wb_sel_o = 0x%0x", s2_wb_sel_o);
|
$display("s2_wb_we_o = 0x%0x", s2_wb_we_o);
|
$display("s2_wb_we_o = 0x%0x", s2_wb_we_o);
|
end
|
end
|
|
|
$stop;
|
$stop;
|
end
|
end
|
end
|
end
|
|
|
|
|
always @ (posedge wb_clk_i)
|
always @ (posedge wb_clk_i)
|
begin
|
begin
|
if(s1_wb_err_i & s1_wb_cyc_o) begin
|
if(s1_wb_err_i & s1_wb_cyc_o) begin
|
$display("(%0t) ERROR: WB cycle finished with error acknowledge ", $time);
|
$display("(%0t) ERROR: WB cycle finished with error acknowledge ", $time);
|
$display("s1_wb_dat_o = 0x%0x", s1_wb_dat_o);
|
$display("s1_wb_dat_o = 0x%0x", s1_wb_dat_o);
|
$display("s1_wb_adr_o = 0x%0x", s1_wb_adr_o);
|
$display("s1_wb_adr_o = 0x%0x", s1_wb_adr_o);
|
$display("s1_wb_sel_o = 0x%0x", s1_wb_sel_o);
|
$display("s1_wb_sel_o = 0x%0x", s1_wb_sel_o);
|
$display("s1_wb_we_o = 0x%0x", s1_wb_we_o);
|
$display("s1_wb_we_o = 0x%0x", s1_wb_we_o);
|
$stop;
|
$stop;
|
end
|
end
|
if(s2_wb_err_i & s2_wb_cyc_o) begin
|
if(s2_wb_err_i & s2_wb_cyc_o) begin
|
$display("(%0t) ERROR: WB cycle finished with error acknowledge ", $time);
|
$display("(%0t) ERROR: WB cycle finished with error acknowledge ", $time);
|
$display("s2_wb_dat_o = 0x%0x", s2_wb_dat_o);
|
$display("s2_wb_dat_o = 0x%0x", s2_wb_dat_o);
|
$display("s2_wb_adr_o = 0x%0x", s2_wb_adr_o);
|
$display("s2_wb_adr_o = 0x%0x", s2_wb_adr_o);
|
$display("s2_wb_sel_o = 0x%0x", s2_wb_sel_o);
|
$display("s2_wb_sel_o = 0x%0x", s2_wb_sel_o);
|
$display("s2_wb_we_o = 0x%0x", s2_wb_we_o);
|
$display("s2_wb_we_o = 0x%0x", s2_wb_we_o);
|
$stop;
|
$stop;
|
end
|
end
|
end
|
end
|
|
|
|
|
|
|
endmodule
|
endmodule
|
|
|