Forum Discussion
Altera_Forum
Honored Contributor
14 years agoHi feng,
Your code enqueues a transaction, but it does not wait for it to complete, so Modelsim exits too soon. Here's a couple of tasks I use:
// ============================================================
// Tasks
// ============================================================
//
// Avalon-MM single-transaction read and write procedures.
//
// ------------------------------------------------------------
task avalon_write (
// ------------------------------------------------------------
input addr,
input data
);
begin
// Construct the BFM request
`BFM.set_command_request(REQ_WRITE);
`BFM.set_command_idle(0, 0);
`BFM.set_command_init_latency(0);
`BFM.set_command_address(addr);
`BFM.set_command_byte_enable('1,0);
`BFM.set_command_data(data, 0);
// Queue the command
`BFM.push_command();
// Wait until the transaction has completed
while (`BFM.get_response_queue_size() != 1)
@(posedge clk);
// Dequeue the response and discard
`BFM.pop_response();
end
endtask
// ------------------------------------------------------------
task avalon_read (
// ------------------------------------------------------------
input addr,
output data
);
begin
// Construct the BFM request
`BFM.set_command_request(REQ_READ);
`BFM.set_command_idle(0, 0);
`BFM.set_command_init_latency(0);
`BFM.set_command_address(addr);
`BFM.set_command_byte_enable('1,0);
`BFM.set_command_data(0, 0);
// Queue the command
`BFM.push_command();
// Wait until the transaction has completed
while (`BFM.get_response_queue_size() != 1)
@(posedge clk);
// Dequeue the response and return the data
`BFM.pop_response();
data = `BFM.get_response_data(0);
end
endtask
Cheers, Dave