Здравствуйте.
Начал недавно изучать ПЛИСы и сейчас возник вопрос про шину Avalon. В Qsys'e соединил стандартные модули Master и Slave и составил программку посмотреть режимы чтения и записи. В итоге при моделировании в ModelSim'е в режиме записи все сигналы в порядке, а в режиме чтения сигнал readdata всё время неизвестен (Х). Помогите разобраться. Вот сама программа:
//Console messaging level
`define VERBOSITY VERBOSITY_DEBUG
//BFM hierachy
`define CLK top.tb.avalon_mm_inst_clk_bfm
`define RST top.tb.avalon_mm_inst_reset_bfm
`define MS top.tb.avalon_mm_inst.mm_master_bfm_0
`define SL top.tb.avalon_mm_inst.mm_slave_bfm_0
//BFM related parameters
`define AV_ADDRESS_W 32
`define AV_DATA 32
//local parameters
`define NUMBER_OF_TRANSACTIONS 3
module test_program();
import verbosity_pkg::*;
import avalon_mm_pkg::*;
typedef logic [`AV_DATA-1 :0] Avalon_MM_Data, rddata;
typedef logic [`AV_ADDRESS_W-1 :0] Avalon_MM_Adress;
int i,j,k;
initial begin
set_verbosity(`VERBOSITY);
// initialize BFMS
`MS.init();
`SL.init();
j = 65535; // data
i = 0; // address
k = 1;
wait(`RST.reset == 1);
wait(`MS.reset == 0);
end
always @(posedge `CLK.clk) begin
if (`MS.avm_waitrequest == 0) begin
if (k <= `NUMBER_OF_TRANSACTIONS) begin
avalon_write(i,j);
end
if ((k <= 2*`NUMBER_OF_TRANSACTIONS) & (k > `NUMBER_OF_TRANSACTIONS))
avalon_read(i,rddata);
k++;
i++;
j++;
end
end
task avalon_write (
// ------------------------------------------------------------
input [`AV_ADDRESS_W-1:0] addr,
input [`AV_DATA-1:0] data
);
begin
// Construct the BFM request
`MS.set_command_request(REQ_WRITE);
`MS.set_command_idle(0, 0);
`MS.set_command_init_latency(0);
`MS.set_command_address(addr);
`MS.set_command_byte_enable('1,0);
`MS.set_command_data(data, 0);
// Queue the command
`MS.push_command();
// Wait until the transaction has completed
while (`MS.get_response_queue_size() != 1)
@(posedge `CLK.clk);
// Dequeue the response and discard
`MS.pop_response();
end
endtask
// ------------------------------------------------------------
task avalon_read (
// ------------------------------------------------------------
input [`AV_ADDRESS_W-1:0] addr,
output [`AV_DATA-1:0] data
);
begin
// Construct the BFM request
`MS.set_command_request(REQ_READ);
`MS.set_command_idle(0, 0);
`MS.set_command_init_latency(0);
`MS.set_command_address(addr);
`MS.set_command_byte_enable('b1111,0);
`MS.set_command_data(0, 0);
// Queue the command
`MS.push_command();
`SL.set_response_data('h1234567,0);
`SL.set_interface_wait_time(0,0);
`SL.push_response();
// Wait until the transaction has completed
while (`MS.get_response_queue_size() != 1)
@(posedge `CLK.clk);
// Dequeue the response and return the data
`MS.pop_response();
`SL.pop_command();
data = `MS.get_response_data(0);
end
endtask
endmodule