//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// File name "pci_bench_common_tasks.v" ////
|
//// File name "pci_bench_common_tasks.v" ////
|
//// ////
|
//// ////
|
//// This file is part of the "PCI bridge" project ////
|
//// This file is part of the "PCI bridge" project ////
|
//// http://www.opencores.org/cores/pci/ ////
|
//// http://www.opencores.org/cores/pci/ ////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Miha Dolenc (mihad@opencores.org) ////
|
//// - Miha Dolenc (mihad@opencores.org) ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2003 Miha Dolenc, mihad@opencores.org ////
|
//// Copyright (C) 2003 Miha Dolenc, mihad@opencores.org ////
|
//// ////
|
//// ////
|
//// 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 $
|
//
|
//
|
|
|
task pci_configure_pci_target_image ;
|
task pci_configure_pci_target_image ;
|
input use_bus ; // selects whether to configure image with bus accesses or directly with dot notation in the configuration space
|
input use_bus ; // selects whether to configure image with bus accesses or directly with dot notation in the configuration space
|
input [2:0] image_num ; // image number
|
input [2:0] image_num ; // image number
|
input [31:0] ba ; // base address
|
input [31:0] ba ; // base address
|
input [31:0] am ; // address mask
|
input [31:0] am ; // address mask
|
input [31:0] ta ; // translation address
|
input [31:0] ta ; // translation address
|
input io_nmem ; // io/mem mapping select
|
input io_nmem ; // io/mem mapping select
|
input pref_en ; // prefetch enable
|
input pref_en ; // prefetch enable
|
input at_en ; // address translation enable
|
input at_en ; // address translation enable
|
output ok ; // finished succesfully
|
output ok ; // finished succesfully
|
|
|
reg in_use ;
|
reg in_use ;
|
reg [11:0] ctrl_offset ;
|
reg [11:0] ctrl_offset ;
|
reg [11:0] ba_offset ;
|
reg [11:0] ba_offset ;
|
reg [11:0] am_offset ;
|
reg [11:0] am_offset ;
|
reg [11:0] ta_offset ;
|
reg [11:0] ta_offset ;
|
begin:main
|
begin:main
|
if (in_use === 1'b1)
|
if (in_use === 1'b1)
|
begin
|
begin
|
$display("Time %t", $time) ;
|
$display("Time %t", $time) ;
|
$display("pci_configure_pci_target_image task re-entered") ;
|
$display("pci_configure_pci_target_image task re-entered") ;
|
ok = 0 ;
|
ok = 0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
|
|
in_use = 1'b1 ;
|
in_use = 1'b1 ;
|
if (use_bus !== 1'b0)
|
if (use_bus !== 1'b0)
|
begin
|
begin
|
if (image_num === 0)
|
if (image_num === 0)
|
begin
|
begin
|
ctrl_offset = {4'h1, `P_IMG_CTRL0_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `P_IMG_CTRL0_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA0_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA0_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM0_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM0_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA0_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA0_ADDR, 2'b00} ;
|
end
|
end
|
else if (image_num === 1)
|
else if (image_num === 1)
|
begin
|
begin
|
ctrl_offset = {4'h1, `P_IMG_CTRL1_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `P_IMG_CTRL1_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA1_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA1_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM1_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM1_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA1_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA1_ADDR, 2'b00} ;
|
end
|
end
|
else if (image_num === 2)
|
else if (image_num === 2)
|
begin
|
begin
|
ctrl_offset = {4'h1, `P_IMG_CTRL2_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `P_IMG_CTRL2_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA2_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA2_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM2_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM2_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA2_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA2_ADDR, 2'b00} ;
|
end
|
end
|
else if (image_num === 3)
|
else if (image_num === 3)
|
begin
|
begin
|
ctrl_offset = {4'h1, `P_IMG_CTRL3_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `P_IMG_CTRL3_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA3_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA3_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM3_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM3_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA3_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA3_ADDR, 2'b00} ;
|
end
|
end
|
else if (image_num === 4)
|
else if (image_num === 4)
|
begin
|
begin
|
ctrl_offset = {4'h1, `P_IMG_CTRL4_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `P_IMG_CTRL4_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA4_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA4_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM4_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM4_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA4_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA4_ADDR, 2'b00} ;
|
end
|
end
|
else if (image_num === 5)
|
else if (image_num === 5)
|
begin
|
begin
|
ctrl_offset = {4'h1, `P_IMG_CTRL5_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `P_IMG_CTRL5_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA5_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `P_BA5_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM5_ADDR, 2'b00} ;
|
am_offset = {4'h1, `P_AM5_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA5_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `P_TA5_ADDR, 2'b00} ;
|
end
|
end
|
|
|
// Set Base Address of IMAGE
|
// Set Base Address of IMAGE
|
config_write( ba_offset, ba | {31'h0, io_nmem}, 4'hF, ok ) ;
|
config_write( ba_offset, ba | {31'h0, io_nmem}, 4'hF, ok ) ;
|
if ( ok !== 1 )
|
if ( ok !== 1 )
|
begin
|
begin
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
|
|
// Set Address Mask of IMAGE
|
// Set Address Mask of IMAGE
|
config_write( am_offset, am, 4'hF, ok ) ;
|
config_write( am_offset, am, 4'hF, ok ) ;
|
if ( ok !== 1 )
|
if ( ok !== 1 )
|
begin
|
begin
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
|
|
// Set Translation Address of IMAGE
|
// Set Translation Address of IMAGE
|
config_write( ta_offset, ta, 4'hF, ok ) ;
|
config_write( ta_offset, ta, 4'hF, ok ) ;
|
if ( ok !== 1 )
|
if ( ok !== 1 )
|
begin
|
begin
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
|
|
// Set IMAGE Control Register
|
// Set IMAGE Control Register
|
config_write( ctrl_offset, {29'd0, at_en, pref_en, 1'b0}, 4'hF, ok ) ;
|
config_write( ctrl_offset, {29'd0, at_en, pref_en, 1'b0}, 4'hF, ok ) ;
|
if ( ok !== 1 )
|
if ( ok !== 1 )
|
begin
|
begin
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if (image_num === 0)
|
if (image_num === 0)
|
begin
|
begin
|
`ifdef HOST
|
`ifdef HOST
|
`ifdef NO_CNF_IMAGE
|
`ifdef NO_CNF_IMAGE
|
`ifdef PCI_IMAGE0 // if PCI bridge is HOST and IMAGE0 is assigned as general image space
|
`ifdef PCI_IMAGE0 // if PCI bridge is HOST and IMAGE0 is assigned as general image space
|
// set base address
|
// set base address
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba0_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba0_bit31_12 = ba[31:12] ;
|
// set control register
|
// set control register
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl0_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl0_bit2_1 = {at_en, pref_en} ;
|
// set memory map - part of base address
|
// set memory map - part of base address
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba0_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba0_bit0 = io_nmem ;
|
// set address mask
|
// set address mask
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am0 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am0 = am[31:12] ;
|
// set translation address
|
// set translation address
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta0 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta0 = ta[31:12] ;
|
`endif
|
`endif
|
`else // if PCI bridge is HOST and IMAGE0 is assigned to PCI configuration space
|
`else // if PCI bridge is HOST and IMAGE0 is assigned to PCI configuration space
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba0_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba0_bit31_12 = ba[31:12] ;
|
`endif
|
`endif
|
`else // if PCI bridge is GUEST, then IMAGE0 is assigned to PCI configuration space
|
`else // if PCI bridge is GUEST, then IMAGE0 is assigned to PCI configuration space
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba0_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba0_bit31_12 = ba[31:12] ;
|
`endif
|
`endif
|
end
|
end
|
else if (image_num === 1)
|
else if (image_num === 1)
|
begin
|
begin
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl1_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl1_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba1_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba1_bit31_12 = ba[31:12] ;
|
`ifdef HOST
|
`ifdef HOST
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba1_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba1_bit0 = io_nmem ;
|
`endif
|
`endif
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am1 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am1 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta1 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta1 = ta[31:12] ;
|
end
|
end
|
else if (image_num === 2)
|
else if (image_num === 2)
|
begin
|
begin
|
`ifdef PCI_IMAGE2
|
`ifdef PCI_IMAGE2
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl2_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl2_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba2_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba2_bit31_12 = ba[31:12] ;
|
`ifdef HOST
|
`ifdef HOST
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba2_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba2_bit0 = io_nmem ;
|
`endif
|
`endif
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am2 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am2 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta2 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta2 = ta[31:12] ;
|
`endif
|
`endif
|
end
|
end
|
else if (image_num === 3)
|
else if (image_num === 3)
|
begin
|
begin
|
`ifdef PCI_IMAGE3
|
`ifdef PCI_IMAGE3
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl3_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl3_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba3_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba3_bit31_12 = ba[31:12] ;
|
`ifdef HOST
|
`ifdef HOST
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba3_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba3_bit0 = io_nmem ;
|
`endif
|
`endif
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am3 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am3 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta3 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta3 = ta[31:12] ;
|
`endif
|
`endif
|
end
|
end
|
else if (image_num === 4)
|
else if (image_num === 4)
|
begin
|
begin
|
`ifdef PCI_IMAGE4
|
`ifdef PCI_IMAGE4
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl4_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl4_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba4_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba4_bit31_12 = ba[31:12] ;
|
`ifdef HOST
|
`ifdef HOST
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba4_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba4_bit0 = io_nmem ;
|
`endif
|
`endif
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am4 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am4 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta4 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta4 = ta[31:12] ;
|
`endif
|
`endif
|
end
|
end
|
else if (image_num === 5)
|
else if (image_num === 5)
|
begin
|
begin
|
`ifdef PCI_IMAGE5
|
`ifdef PCI_IMAGE5
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl5_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_img_ctrl5_bit2_1 = {at_en, pref_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba5_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba5_bit31_12 = ba[31:12] ;
|
`ifdef HOST
|
`ifdef HOST
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba5_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ba5_bit0 = io_nmem ;
|
`endif
|
`endif
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am5 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_am5 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta5 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.pci_ta5 = ta[31:12] ;
|
`endif
|
`endif
|
end
|
end
|
end
|
end
|
|
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
end
|
end
|
endtask // pci_configure_pci_target_image
|
endtask // pci_configure_pci_target_image
|
|
|
task pci_configure_wb_slave_image ;
|
task pci_configure_wb_slave_image ;
|
input use_bus ; // selects whether to configure image with bus accesses or directly with dot notation in the configuration space
|
input use_bus ; // selects whether to configure image with bus accesses or directly with dot notation in the configuration space
|
input [2:0] image_num ; // image number
|
input [2:0] image_num ; // image number
|
input [31:0] ba ; // base address
|
input [31:0] ba ; // base address
|
input [31:0] am ; // address mask
|
input [31:0] am ; // address mask
|
input [31:0] ta ; // translation address
|
input [31:0] ta ; // translation address
|
input io_nmem ; // io/mem mapping select
|
input io_nmem ; // io/mem mapping select
|
input pref_en ; // prefetch enable
|
input pref_en ; // prefetch enable
|
input at_en ; // address translation enable
|
input at_en ; // address translation enable
|
input mrl_en ; // memory read line enable
|
input mrl_en ; // memory read line enable
|
output ok ; // finished succesfully
|
output ok ; // finished succesfully
|
|
|
reg in_use ;
|
reg in_use ;
|
reg [11:0] ctrl_offset ;
|
reg [11:0] ctrl_offset ;
|
reg [11:0] ba_offset ;
|
reg [11:0] ba_offset ;
|
reg [11:0] am_offset ;
|
reg [11:0] am_offset ;
|
reg [11:0] ta_offset ;
|
reg [11:0] ta_offset ;
|
begin:main
|
begin:main
|
if (in_use === 1'b1)
|
if (in_use === 1'b1)
|
begin
|
begin
|
$display("Time %t", $time) ;
|
$display("Time %t", $time) ;
|
$display("pci_configure_wb_slave_image task re-entered") ;
|
$display("pci_configure_wb_slave_image task re-entered") ;
|
ok = 0 ;
|
ok = 0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
|
|
in_use = 1'b1 ;
|
in_use = 1'b1 ;
|
if (use_bus !== 1'b0)
|
if (use_bus !== 1'b0)
|
begin
|
begin
|
if (image_num === 1)
|
if (image_num === 1)
|
begin
|
begin
|
ctrl_offset = {4'h1, `W_IMG_CTRL1_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `W_IMG_CTRL1_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA1_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA1_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM1_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM1_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA1_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA1_ADDR, 2'b00} ;
|
end
|
end
|
else if (image_num === 2)
|
else if (image_num === 2)
|
begin
|
begin
|
ctrl_offset = {4'h1, `W_IMG_CTRL2_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `W_IMG_CTRL2_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA2_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA2_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM2_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM2_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA2_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA2_ADDR, 2'b00} ;
|
end
|
end
|
else if (image_num === 3)
|
else if (image_num === 3)
|
begin
|
begin
|
ctrl_offset = {4'h1, `W_IMG_CTRL3_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `W_IMG_CTRL3_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA3_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA3_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM3_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM3_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA3_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA3_ADDR, 2'b00} ;
|
end
|
end
|
else if (image_num === 4)
|
else if (image_num === 4)
|
begin
|
begin
|
ctrl_offset = {4'h1, `W_IMG_CTRL4_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `W_IMG_CTRL4_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA4_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA4_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM4_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM4_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA4_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA4_ADDR, 2'b00} ;
|
end
|
end
|
else if (image_num === 5)
|
else if (image_num === 5)
|
begin
|
begin
|
ctrl_offset = {4'h1, `W_IMG_CTRL5_ADDR, 2'b00} ;
|
ctrl_offset = {4'h1, `W_IMG_CTRL5_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA5_ADDR, 2'b00} ;
|
ba_offset = {4'h1, `W_BA5_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM5_ADDR, 2'b00} ;
|
am_offset = {4'h1, `W_AM5_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA5_ADDR, 2'b00} ;
|
ta_offset = {4'h1, `W_TA5_ADDR, 2'b00} ;
|
end
|
end
|
|
|
// Set Base Address of IMAGE
|
// Set Base Address of IMAGE
|
config_write( ba_offset, ba | {31'h0, io_nmem}, 4'hF, ok ) ;
|
config_write( ba_offset, ba | {31'h0, io_nmem}, 4'hF, ok ) ;
|
if ( ok !== 1 )
|
if ( ok !== 1 )
|
begin
|
begin
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
|
|
// Set Address Mask of IMAGE
|
// Set Address Mask of IMAGE
|
config_write( am_offset, am, 4'hF, ok ) ;
|
config_write( am_offset, am, 4'hF, ok ) ;
|
if ( ok !== 1 )
|
if ( ok !== 1 )
|
begin
|
begin
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
|
|
// Set Translation Address of IMAGE
|
// Set Translation Address of IMAGE
|
config_write( ta_offset, ta, 4'hF, ok ) ;
|
config_write( ta_offset, ta, 4'hF, ok ) ;
|
if ( ok !== 1 )
|
if ( ok !== 1 )
|
begin
|
begin
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
|
|
// Set IMAGE Control Register
|
// Set IMAGE Control Register
|
config_write( ctrl_offset, {29'd0, at_en, pref_en, 1'b0}, 4'hF, ok ) ;
|
config_write( ctrl_offset, {29'd0, at_en, pref_en, 1'b0}, 4'hF, ok ) ;
|
if ( ok !== 1 )
|
if ( ok !== 1 )
|
begin
|
begin
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
disable main ;
|
disable main ;
|
end
|
end
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if (image_num === 1)
|
if (image_num === 1)
|
begin
|
begin
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl1_bit2_0 = {at_en, pref_en, mrl_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl1_bit2_0 = {at_en, pref_en, mrl_en} ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba1_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba1_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba1_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba1_bit0 = io_nmem ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am1 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am1 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta1 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta1 = ta[31:12] ;
|
end
|
end
|
else if (image_num === 2)
|
else if (image_num === 2)
|
begin
|
begin
|
`ifdef WB_IMAGE2
|
`ifdef WB_IMAGE2
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl2_bit2_0 = {at_en, pref_en, mrl_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl2_bit2_0 = {at_en, pref_en, mrl_en} ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba2_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba2_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba2_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba2_bit0 = io_nmem ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am2 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am2 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta2 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta2 = ta[31:12] ;
|
`endif
|
`endif
|
end
|
end
|
else if (image_num === 3)
|
else if (image_num === 3)
|
begin
|
begin
|
`ifdef WB_IMAGE3
|
`ifdef WB_IMAGE3
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl3_bit2_0 = {at_en, pref_en, mrl_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl3_bit2_0 = {at_en, pref_en, mrl_en} ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba3_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba3_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba3_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba3_bit0 = io_nmem ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am3 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am3 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta3 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta3 = ta[31:12] ;
|
`endif
|
`endif
|
end
|
end
|
else if (image_num === 4)
|
else if (image_num === 4)
|
begin
|
begin
|
`ifdef WB_IMAGE4
|
`ifdef WB_IMAGE4
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl4_bit2_0 = {at_en, pref_en, mrl_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl4_bit2_0 = {at_en, pref_en, mrl_en} ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba4_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba4_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba4_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba4_bit0 = io_nmem ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am4 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am4 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta4 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta4 = ta[31:12] ;
|
`endif
|
`endif
|
end
|
end
|
else if (image_num === 5)
|
else if (image_num === 5)
|
begin
|
begin
|
`ifdef WB_IMAGE5
|
`ifdef WB_IMAGE5
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl5_bit2_0 = {at_en, pref_en, mrl_en} ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_img_ctrl5_bit2_0 = {at_en, pref_en, mrl_en} ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba5_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba5_bit31_12 = ba[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba5_bit0 = io_nmem ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ba5_bit0 = io_nmem ;
|
|
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am5 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_am5 = am[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta5 = ta[31:12] ;
|
`PCI_BRIDGE_INSTANCE.bridge.configuration.wb_ta5 = ta[31:12] ;
|
`endif
|
`endif
|
end
|
end
|
end
|
end
|
|
|
in_use = 1'b0 ;
|
in_use = 1'b0 ;
|
end
|
end
|
endtask // pci_configure_wb_slave_image
|
endtask // pci_configure_wb_slave_image
|
|
|