URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [avalon_lib/] [sim/] [src/] [amm_monitor/] [altera_avalon_mm_monitor.sv] - Rev 31
Compare with Previous | Blame | View Log
// (C) 2001-2016 Intel Corporation. All rights reserved.// Your use of Intel Corporation's design tools, logic functions and other// software and tools, and its AMPP partner logic functions, and any output// files any of the foregoing (including device programming or simulation// files), and any associated documentation or information are expressly subject// to the terms and conditions of the Intel Program License Subscription// Agreement, Intel MegaCore Function License Agreement, or other applicable// license agreement, including, without limitation, that your use is for the// sole purpose of programming logic devices manufactured by Intel and sold by// Intel or its authorized distributors. Please refer to the applicable// agreement for further details.// $Id: //acds/rel/16.1/ip/sopc/components/verification/altera_avalon_mm_monitor_bfm/altera_avalon_mm_monitor.sv#1 $// $Revision: #1 $// $Date: 2016/08/07 $//-----------------------------------------------------------------------------// =head1 NAME// altera_avalon_mm_monitor// =head1 SYNOPSIS// Bridge with Avalon Bus Protocol Assertion Checker// The macro DISABLE_ALTERA_AVALON_SIM_SVA is defined to disable SVA processing// The macro ALTERA_AVALON_SIM_MTI must be defined to enable transaction tracing// The macro ENABLE_ALTERA_AVALON_TRANSACTION_RECORDING must be defined to// enable transaction monitoring//-----------------------------------------------------------------------------`timescale 1ps / 1psmodule altera_avalon_mm_monitor(clk,reset,avm_clken,avs_clken,avs_waitrequest,avs_write,avs_read,avs_address,avs_byteenable,avs_burstcount,avs_beginbursttransfer,avs_begintransfer,avs_writedata,avs_readdata,avs_readdatavalid,avs_arbiterlock,avs_lock,avs_debugaccess,avs_transactionid,avs_readid,avs_writeid,avs_response,avs_writeresponserequest,avs_writeresponsevalid,// deprecated signalsavs_readresponse,avs_writeresponse,avm_readresponse,avm_writeresponse,avm_waitrequest,avm_write,avm_read,avm_address,avm_byteenable,avm_burstcount,avm_beginbursttransfer,avm_begintransfer,avm_writedata,avm_readdata,avm_readdatavalid,avm_arbiterlock,avm_lock,avm_debugaccess,avm_transactionid,avm_readid,avm_writeid,avm_response,avm_writeresponserequest,avm_writeresponsevalid);// =head1 PARAMETERSparameter AV_ADDRESS_W = 32; // address widthparameter AV_SYMBOL_W = 8; // default symbol is byteparameter AV_NUMSYMBOLS = 4; // number of symbols per wordparameter AV_BURSTCOUNT_W = 3; // burst port width// deprecated parameterparameter AV_WRITERESPONSE_W = 8;parameter AV_READRESPONSE_W = 8;parameter AV_CONSTANT_BURST_BEHAVIOR = 1; // Address, burstcount, transactionid and// avm_writeresponserequest need to be held constant// in burst transactionparameter AV_BURST_LINEWRAP = 0; // line wrapping addr is set to 1parameter AV_BURST_BNDR_ONLY = 0; // addr is multiple of burst sizeparameter REGISTER_WAITREQUEST = 0; // Waitrequest is registered at the slaveparameter AV_MAX_PENDING_READS = 1; // maximum pending read transfer countparameter AV_MAX_PENDING_WRITES = 0; // maximum pending write transfer countparameter AV_FIX_READ_LATENCY = 0; // fixed read latency in cyclesparameter USE_READ = 1; // use read portparameter USE_WRITE = 1; // use write portparameter USE_ADDRESS = 1; // use address portparameter USE_BYTE_ENABLE = 1; // use byteenable portparameter USE_BURSTCOUNT = 0; // use burstcount portparameter USE_READ_DATA = 1; // use readdata portparameter USE_READ_DATA_VALID = 1; // use readdatavalid portparameter USE_WRITE_DATA = 1; // use writedata portparameter USE_BEGIN_TRANSFER = 0; // use begintransfer portparameter USE_BEGIN_BURST_TRANSFER = 0; // use begintbursttransfer portparameter USE_WAIT_REQUEST = 1; // use waitrequest portparameter USE_ARBITERLOCK = 0; // Use arbiterlock pin on interfaceparameter USE_LOCK = 0; // Use lock pin on interfaceparameter USE_DEBUGACCESS = 0; // Use debugaccess pin on interfaceparameter USE_TRANSACTIONID = 0; // Use transactionid interface pinparameter USE_WRITERESPONSE = 0; // Use write response interface pinsparameter USE_READRESPONSE = 0; // Use read response interface pinsparameter USE_CLKEN = 0; // Use NTCM interface pinsparameter AV_READ_TIMEOUT = 100; // timeout period for read transferparameter AV_WRITE_TIMEOUT = 100; // timeout period for write burst transferparameter AV_WAITREQUEST_TIMEOUT = 1024; // timeout period for continuous waitrequestparameter AV_MAX_READ_LATENCY = 100; // maximum read latency cycle for coverageparameter AV_MAX_WAITREQUESTED_READ = 100; // maximum waitrequested read cycle for coverageparameter AV_MAX_WAITREQUESTED_WRITE = 100; // maximum waitrequested write cycle for coverageparameter AV_MAX_CONTINUOUS_READ = 5; // maximum continuous read cycle for coverageparameter AV_MAX_CONTINUOUS_WRITE = 5; // maximum continuous write cycle for coverageparameter AV_MAX_CONTINUOUS_WAITREQUEST = 5; // maximum continuous waitrequest cycle for coverageparameter AV_MAX_CONTINUOUS_READDATAVALID = 5; // maximum continuous readdatavalid cycle for coverageparameter string SLAVE_ADDRESS_TYPE = "SYMBOLS"; // Set slave interface address type, {SYMBOLS, WORDS}parameter string MASTER_ADDRESS_TYPE = "SYMBOLS"; // Set master interface address type, {SYMBOLS, WORDS}parameter AV_READ_WAIT_TIME = 0; // Fixed wait time cycles whenparameter AV_WRITE_WAIT_TIME = 0; // USE_WAIT_REQUEST is 0parameter AV_REGISTERINCOMINGSIGNALS = 0; // Indicate that waitrequest is come from registerparameter VHDL_ID = 0; // VHDL BFM ID numberparameter PRINT_HELLO = 1; // To enable the printing of __hello messageparameter STORE_COMMAND = 1; // Store commands inside command queueparameter STORE_RESPONSE = 1; // Store responses inside response queuelocalparam AV_DATA_W = AV_SYMBOL_W * AV_NUMSYMBOLS;localparam AV_MAX_BURST = USE_BURSTCOUNT ? 2**(lindex(AV_BURSTCOUNT_W)) : 1;localparam INT_WIDTH = 32;localparam AV_TRANSACTIONID_W = 8;localparam AV_SLAVE_ADDRESS_W = (SLAVE_ADDRESS_TYPE != MASTER_ADDRESS_TYPE)? (AV_ADDRESS_W - log2(AV_NUMSYMBOLS)):AV_ADDRESS_W;localparam TAP_W = 1 + // clken1 + // arbiterlock1 + // lock1 + // debugaccess((AV_TRANSACTIONID_W == 0)? 1:AV_TRANSACTIONID_W) + // transactionid((AV_TRANSACTIONID_W == 0)? 1:AV_TRANSACTIONID_W) + // readid((AV_TRANSACTIONID_W == 0)? 1:AV_TRANSACTIONID_W) + // writeid2 + // response1 + // writeresponserequest1 + // writeresponsevalid1 + // waitrequest1 + // readdatavalid((AV_DATA_W == 0)? 1:AV_DATA_W) + // readdata1 + // write1 + // read((AV_ADDRESS_W == 0)? 1:AV_ADDRESS_W) + // address((AV_NUMSYMBOLS == 0)? 1:AV_NUMSYMBOLS) + // byteenable((AV_BURSTCOUNT_W == 0)? 1:AV_BURSTCOUNT_W) + // burstcount1 + // beginbursttransfer1 + // begintransfer((AV_DATA_W == 0)? 1:AV_DATA_W); // writedatafunction int lindex;// returns the left index for a vector having a declared width// when width is 0, then the left index is set to 0 rather than -1input [31:0] width;lindex = (width > 0) ? (width-1) : 0;endfunction// =head1 PINS// =head2 Clock Interfaceinput clk;input reset;// =head2 Tightly Coupled Memory Interfaceoutput avm_clken;input avs_clken;// =head2 Avalon Master Interfaceinput avm_waitrequest;input avm_readdatavalid;input [lindex(AV_SYMBOL_W * AV_NUMSYMBOLS):0] avm_readdata;output avm_write;output avm_read;output [lindex(AV_ADDRESS_W):0] avm_address;output [lindex(AV_NUMSYMBOLS):0] avm_byteenable;output [lindex(AV_BURSTCOUNT_W):0] avm_burstcount;output avm_beginbursttransfer;output avm_begintransfer;output [lindex(AV_SYMBOL_W * AV_NUMSYMBOLS):0] avm_writedata;output avm_arbiterlock;output avm_lock;output avm_debugaccess;output [lindex(AV_TRANSACTIONID_W):0] avm_transactionid;input [lindex(AV_TRANSACTIONID_W):0] avm_readid;input [lindex(AV_TRANSACTIONID_W):0] avm_writeid;input [1:0] avm_response;output avm_writeresponserequest;input avm_writeresponsevalid;// deprecatedinput [lindex(AV_READRESPONSE_W):0] avm_readresponse;input [lindex(AV_WRITERESPONSE_W):0] avm_writeresponse;// =head2 Avalon Slave Interfaceoutput avs_waitrequest;output avs_readdatavalid;output [lindex(AV_SYMBOL_W * AV_NUMSYMBOLS):0] avs_readdata;input avs_write;input avs_read;input [lindex(AV_SLAVE_ADDRESS_W):0] avs_address;input [lindex(AV_NUMSYMBOLS):0] avs_byteenable;input [lindex(AV_BURSTCOUNT_W):0] avs_burstcount;input avs_beginbursttransfer;input avs_begintransfer;input [lindex(AV_SYMBOL_W * AV_NUMSYMBOLS):0] avs_writedata;input avs_arbiterlock;input avs_lock;input avs_debugaccess;input [lindex(AV_TRANSACTIONID_W):0] avs_transactionid;output [lindex(AV_TRANSACTIONID_W):0] avs_readid;output [lindex(AV_TRANSACTIONID_W):0] avs_writeid;output [1:0] avs_response;input avs_writeresponserequest;output avs_writeresponsevalid;// deprecatedoutput [lindex(AV_READRESPONSE_W):0] avs_readresponse;output [lindex(AV_WRITERESPONSE_W):0] avs_writeresponse;logic avm_clken;logic avs_clken;logic avm_waitrequest;logic avm_readdatavalid;logic [lindex(AV_SYMBOL_W * AV_NUMSYMBOLS):0] avm_readdata;logic avm_write;logic avm_read;logic [lindex(AV_ADDRESS_W):0] avm_address;logic [lindex(AV_NUMSYMBOLS):0] avm_byteenable;logic [lindex(AV_BURSTCOUNT_W):0] avm_burstcount;logic avm_beginbursttransfer;logic avm_begintransfer;logic [lindex(AV_SYMBOL_W * AV_NUMSYMBOLS):0] avm_writedata;logic avm_arbiterlock;logic avm_lock;logic avm_debugaccess;logic [lindex(AV_TRANSACTIONID_W):0] avm_transactionid;logic [lindex(AV_TRANSACTIONID_W):0] avm_readid;logic [lindex(AV_TRANSACTIONID_W):0] avm_writeid;logic [1:0] avm_response;logic avm_writeresponserequest;logic avm_writeresponsevalid;// deprecatedlogic [lindex(AV_READRESPONSE_W):0] avm_readresponse;logic [lindex(AV_WRITERESPONSE_W):0] avm_writeresponse;logic avs_waitrequest;logic avs_readdatavalid;logic [lindex(AV_SYMBOL_W * AV_NUMSYMBOLS):0] avs_readdata;logic avs_write;logic avs_read;logic [lindex(AV_SLAVE_ADDRESS_W):0] avs_address;logic [lindex(AV_NUMSYMBOLS):0] avs_byteenable;logic [lindex(AV_BURSTCOUNT_W):0] avs_burstcount;logic avs_beginbursttransfer;logic avs_begintransfer;logic [lindex(AV_SYMBOL_W * AV_NUMSYMBOLS):0] avs_writedata;logic avs_arbiterlock;logic avs_lock;logic avs_debugaccess;logic [lindex(AV_TRANSACTIONID_W):0] avs_transactionid;logic [lindex(AV_TRANSACTIONID_W):0] avs_readid;logic [lindex(AV_TRANSACTIONID_W):0] avs_writeid;logic [1:0] avs_response;logic avs_writeresponserequest;logic avs_writeresponsevalid;// deprecatedlogic [lindex(AV_READRESPONSE_W):0] avs_readresponse;logic [lindex(AV_WRITERESPONSE_W):0] avs_writeresponse;logic [lindex(TAP_W):0] tap;logic [31:0] read_wait_time = 0;logic [31:0] write_wait_time = 0;logic local_avs_waitrequest;bit master_slave_address_type_mismatch;// Use SLAVE_ADDRESS_TYPE/MASTER_ADDRESS_TYPE inside always_comb block will causing an warninginitial beginmaster_slave_address_type_mismatch = (SLAVE_ADDRESS_TYPE != MASTER_ADDRESS_TYPE);end//--------------------------------------------------------------------------// =head1 DESCRIPTION// The component acts as a simple repeater or bridge with Avalon bus// signals passed through from the slave to master interface.// The instantiated altera_avalon_mm_monitor snoops all passing Avalon// bus signals and performs assertion checking and measures coverage on// Avalon Memory Mapped protocol properties.// =cut//--------------------------------------------------------------------------always_comb begin// repeateravm_clken <= avs_clken;if (USE_WAIT_REQUEST == 0) beginavs_waitrequest <= local_avs_waitrequest;end else beginavs_waitrequest <= avm_waitrequest;endavs_readdatavalid <= avm_readdatavalid;avs_readdata <= avm_readdata;avm_write <= avs_write;avm_read <= avs_read;if (master_slave_address_type_mismatch)avm_address <= address_shift(avs_address);elseavm_address <= avs_address;avm_byteenable <= avs_byteenable;avm_burstcount <= avs_burstcount;avm_beginbursttransfer <= avs_beginbursttransfer;avm_begintransfer <= avs_begintransfer;avm_writedata <= avs_writedata;avm_arbiterlock <= avs_arbiterlock;avm_lock <= avs_lock;avm_debugaccess <= avs_debugaccess;avm_transactionid <= avs_transactionid;avs_readid <= avm_readid;avs_writeid <= avm_writeid;avm_writeresponserequest <= avs_writeresponserequest;avs_writeresponsevalid <= avm_writeresponsevalid;avs_response <= avm_response;// snoop bus for assertion and coverage checkingif (master_slave_address_type_mismatch) begintap <= {avs_clken,avs_arbiterlock,avs_lock,avs_debugaccess,avs_transactionid,avm_readid,avm_writeid,avm_response,avs_writeresponserequest,avm_writeresponsevalid,(USE_WAIT_REQUEST == 0)? local_avs_waitrequest:avm_waitrequest,avm_readdatavalid,avm_readdata,avs_write,avs_read,address_shift(avs_address),avs_byteenable,avs_burstcount,avs_beginbursttransfer,avs_begintransfer,avs_writedata};end else begintap <= {avs_clken,avs_arbiterlock,avs_lock,avs_debugaccess,avs_transactionid,avm_readid,avm_writeid,avm_response,avs_writeresponserequest,avm_writeresponsevalid,(USE_WAIT_REQUEST == 0)? local_avs_waitrequest:avm_waitrequest,avm_readdatavalid,avm_readdata,avs_write,avs_read,avs_address,avs_byteenable,avs_burstcount,avs_beginbursttransfer,avs_begintransfer,avs_writedata};endend//--------------------------------------------------------------------------// =head1 ALTERA_AVALON_MM_MONITOR_ASSERTION// This module implements Avalon MM protocol assertion checking for// simulation.// Component name = monitor_assertion.// =cut//--------------------------------------------------------------------------altera_avalon_mm_monitor_assertion#(.AV_ADDRESS_W (AV_ADDRESS_W),.AV_SYMBOL_W (AV_SYMBOL_W),.AV_NUMSYMBOLS (AV_NUMSYMBOLS),.AV_BURSTCOUNT_W (AV_BURSTCOUNT_W),.AV_CONSTANT_BURST_BEHAVIOR (AV_CONSTANT_BURST_BEHAVIOR),.AV_BURST_LINEWRAP (AV_BURST_LINEWRAP),.AV_BURST_BNDR_ONLY (AV_BURST_BNDR_ONLY),.AV_MAX_PENDING_READS (AV_MAX_PENDING_READS),.AV_MAX_PENDING_WRITES (AV_MAX_PENDING_WRITES),.AV_FIX_READ_LATENCY (AV_FIX_READ_LATENCY),.REGISTER_WAITREQUEST (REGISTER_WAITREQUEST),.USE_READ (USE_READ),.USE_WRITE (USE_WRITE),.USE_ADDRESS (USE_ADDRESS),.USE_BYTE_ENABLE (USE_BYTE_ENABLE),.USE_BURSTCOUNT (USE_BURSTCOUNT),.USE_READ_DATA (USE_READ_DATA),.USE_READ_DATA_VALID (USE_READ_DATA_VALID),.USE_WRITE_DATA (USE_WRITE_DATA),.USE_BEGIN_TRANSFER (USE_BEGIN_TRANSFER),.USE_BEGIN_BURST_TRANSFER (USE_BEGIN_BURST_TRANSFER),.USE_WAIT_REQUEST (USE_WAIT_REQUEST),.USE_ARBITERLOCK (USE_ARBITERLOCK),.USE_LOCK (USE_LOCK),.USE_DEBUGACCESS (USE_DEBUGACCESS),.USE_TRANSACTIONID (USE_TRANSACTIONID),.USE_WRITERESPONSE (USE_WRITERESPONSE),.USE_READRESPONSE (USE_READRESPONSE),.USE_CLKEN (USE_CLKEN),.AV_READ_TIMEOUT (AV_READ_TIMEOUT),.AV_WRITE_TIMEOUT (AV_WRITE_TIMEOUT),.AV_WAITREQUEST_TIMEOUT (AV_WAITREQUEST_TIMEOUT),.AV_READ_WAIT_TIME (AV_READ_WAIT_TIME),.AV_WRITE_WAIT_TIME (AV_WRITE_WAIT_TIME),.AV_REGISTERINCOMINGSIGNALS (AV_REGISTERINCOMINGSIGNALS),.SLAVE_ADDRESS_TYPE (SLAVE_ADDRESS_TYPE),.MASTER_ADDRESS_TYPE (MASTER_ADDRESS_TYPE))master_assertion (.clk (clk),.reset (reset),.tap (tap));//--------------------------------------------------------------------------// =head1 ALTERA_AVALON_MM_MONITOR_COVERAGE// This module implements Avalon MM protocol coverage for simulation.// Component name = monitor_coverage.// =cut//--------------------------------------------------------------------------altera_avalon_mm_monitor_coverage#(.AV_ADDRESS_W (AV_ADDRESS_W),.AV_SYMBOL_W (AV_SYMBOL_W),.AV_NUMSYMBOLS (AV_NUMSYMBOLS),.AV_BURSTCOUNT_W (AV_BURSTCOUNT_W),.AV_BURST_LINEWRAP (AV_BURST_LINEWRAP),.AV_BURST_BNDR_ONLY (AV_BURST_BNDR_ONLY),.AV_MAX_PENDING_READS (AV_MAX_PENDING_READS),.AV_MAX_PENDING_WRITES (AV_MAX_PENDING_WRITES),.AV_FIX_READ_LATENCY (AV_FIX_READ_LATENCY),.REGISTER_WAITREQUEST (REGISTER_WAITREQUEST),.USE_READ (USE_READ),.USE_WRITE (USE_WRITE),.USE_ADDRESS (USE_ADDRESS),.USE_BYTE_ENABLE (USE_BYTE_ENABLE),.USE_BURSTCOUNT (USE_BURSTCOUNT),.USE_READ_DATA (USE_READ_DATA),.USE_READ_DATA_VALID (USE_READ_DATA_VALID),.USE_WRITE_DATA (USE_WRITE_DATA),.USE_BEGIN_TRANSFER (USE_BEGIN_TRANSFER),.USE_BEGIN_BURST_TRANSFER (USE_BEGIN_BURST_TRANSFER),.USE_WAIT_REQUEST (USE_WAIT_REQUEST),.USE_CLKEN (USE_CLKEN),.USE_ARBITERLOCK (USE_ARBITERLOCK),.USE_LOCK (USE_LOCK),.USE_DEBUGACCESS (USE_DEBUGACCESS),.USE_TRANSACTIONID (USE_TRANSACTIONID),.USE_WRITERESPONSE (USE_WRITERESPONSE),.USE_READRESPONSE (USE_READRESPONSE),.AV_MAX_READ_LATENCY (AV_MAX_READ_LATENCY),.AV_MAX_WAITREQUESTED_READ (AV_MAX_WAITREQUESTED_READ),.AV_MAX_WAITREQUESTED_WRITE (AV_MAX_WAITREQUESTED_WRITE),.AV_MAX_CONTINUOUS_READ (AV_MAX_CONTINUOUS_READ),.AV_MAX_CONTINUOUS_WRITE (AV_MAX_CONTINUOUS_WRITE),.AV_MAX_CONTINUOUS_WAITREQUEST (AV_MAX_CONTINUOUS_WAITREQUEST),.AV_MAX_CONTINUOUS_READDATAVALID (AV_MAX_CONTINUOUS_READDATAVALID),.AV_READ_WAIT_TIME (AV_READ_WAIT_TIME),.AV_WRITE_WAIT_TIME (AV_WRITE_WAIT_TIME))master_coverage(.clk (clk),.reset (reset),.tap (tap));//--------------------------------------------------------------------------// =head1 ALTERA_AVALON_MM_MONITOR_TRANSACTIONS// This module implements Avalon-MM the transaction recorder.// =cut//--------------------------------------------------------------------------`ifdef ENABLE_ALTERA_AVALON_TRANSACTION_RECORDINGaltera_avalon_mm_monitor_transactions#(.AV_ADDRESS_W (AV_ADDRESS_W),.AV_SYMBOL_W (AV_SYMBOL_W),.AV_NUMSYMBOLS (AV_NUMSYMBOLS),.AV_BURSTCOUNT_W (AV_BURSTCOUNT_W),.AV_BURST_LINEWRAP (AV_BURST_LINEWRAP),.AV_BURST_BNDR_ONLY (AV_BURST_BNDR_ONLY),.AV_MAX_PENDING_READS (AV_MAX_PENDING_READS),.AV_MAX_PENDING_WRITES (AV_MAX_PENDING_WRITES),.AV_FIX_READ_LATENCY (AV_FIX_READ_LATENCY),// deprecated// deprecated parameter.AV_WRITERESPONSE_W (AV_WRITERESPONSE_W),.AV_READRESPONSE_W (AV_READRESPONSE_W),.REGISTER_WAITREQUEST (REGISTER_WAITREQUEST),.USE_READ (USE_READ),.USE_WRITE (USE_WRITE),.USE_ADDRESS (USE_ADDRESS),.USE_BYTE_ENABLE (USE_BYTE_ENABLE),.USE_BURSTCOUNT (USE_BURSTCOUNT),.USE_READ_DATA (USE_READ_DATA),.USE_READ_DATA_VALID (USE_READ_DATA_VALID),.USE_WRITE_DATA (USE_WRITE_DATA),.USE_BEGIN_TRANSFER (USE_BEGIN_TRANSFER),.USE_BEGIN_BURST_TRANSFER (USE_BEGIN_BURST_TRANSFER),.USE_WAIT_REQUEST (USE_WAIT_REQUEST),.USE_CLKEN (USE_CLKEN),.USE_ARBITERLOCK (USE_ARBITERLOCK),.USE_LOCK (USE_LOCK),.USE_DEBUGACCESS (USE_DEBUGACCESS),.USE_TRANSACTIONID (USE_TRANSACTIONID),.USE_WRITERESPONSE (USE_WRITERESPONSE),.USE_READRESPONSE (USE_READRESPONSE),.AV_READ_WAIT_TIME (AV_READ_WAIT_TIME),.AV_WRITE_WAIT_TIME (AV_WRITE_WAIT_TIME),.STORE_RESPONSE (STORE_RESPONSE),.STORE_COMMAND (STORE_COMMAND))monitor_trans(.clk (clk),.reset (reset),.tap (tap));`endif// synthesis translate_offimport verbosity_pkg::*;import avalon_mm_pkg::*;typedef bit [lindex(AV_ADDRESS_W):0] AvalonAddress_t;typedef bit [lindex(AV_BURSTCOUNT_W):0] AvalonBurstCount_t;typedef bit [AV_MAX_BURST-1:0][AV_DATA_W-1:0] AvalonData_t;typedef bit [AV_MAX_BURST-1:0][AV_NUMSYMBOLS-1:0] AvalonByteEnable_t;typedef bit [AV_MAX_BURST-1:0][INT_WIDTH-1:0] AvalonLatency_t;typedef struct packed {Request_t request;AvalonAddress_t address; // start addressAvalonBurstCount_t burst_count; // burst lengthAvalonData_t data; // write dataAvalonByteEnable_t byte_enable; // hot encodedint burst_cycle;} SlaveCommand_t;typedef struct packed {Request_t request;AvalonAddress_t address; // start addrAvalonBurstCount_t burst_count; // burst lengthAvalonData_t data; // read dataAvalonLatency_t read_latency;AvalonLatency_t wait_latency;} MasterResponse_t;//--------------------------------------------------------------------------// =head1 Public Methods API// This section describes the public methods in the application programming// interface (API). In this case the application program is the test bench// which instantiates and controls and queries state of this component.// Test programs must only use these public access methods and events to// communicate with this BFM component. The API and the module pins// are the only interfaces in this component that are guaranteed to be// stable. The API will be maintained for the life of the product.// While we cannot prevent a test program from directly accessing internal// tasks, functions, or data private to the BFM, there is no guarantee that// these will be present in the future. In fact, it is best for the user// to assume that the underlying implementation of this component can// and will change.//--------------------------------------------------------------------------function automatic string get_version(); // public// Return component version as a string of three integers separated by periods.// For example, version 9.1 sp1 is encoded as "9.1.1".string ret_version = "16.1";return ret_version;endfunction// =cut//--------------------------------------------------------------------------// Public API Method(s) - end//--------------------------------------------------------------------------function automatic void hello();// introduction message to the consolestring message;$sformat(message, "%m: - Hello from altera_avalon_mm_monitor");print(VERBOSITY_INFO, message);`ifdef DISABLE_ALTERA_AVALON_SIM_SVA$sformat(message, "%m: - Assertions disabled (DISABLE_ALTERA_AVALON_SIM_SVA defined)");`else$sformat(message, "%m: - Assertions enabled (DISABLE_ALTERA_AVALON_SIM_SVA undefined)");`endifprint(VERBOSITY_INFO, message);`ifdef ALTERA_AVALON_SIM_MTI$sformat(message, "%m: - Transaction tracing enabled (ALTERA_AVALON_SIM_MTI defined)");`else$sformat(message, "%m: - Transaction tracing disabled (ALTERA_AVALON_SIM_MTI undefined)");`endifprint(VERBOSITY_INFO, message);$sformat(message, "%m: - $Revision: #1 $");print(VERBOSITY_INFO, message);$sformat(message, "%m: - $Date: 2016/08/07 $");print(VERBOSITY_INFO, message);print_divider(VERBOSITY_INFO);endfunction//--------------------------------------------------------------------------// The Mentor QuestaSim simulation transaction tracing feature is supported// by enabling the macro: +define+ALTERA_AVALON_SIM_MTI in CLISlaveCommand_t current_command;MasterResponse_t completed_response;int command_trans;int command_trans_stream;int addr_offset = 0;bit burst_mode = 0;int command_counter = 0;int response_counter = 0;int clock_counter = 0;string message = "*unitialized*";event signal_fatal_error;event command;event response;function automatic void init_transaction_recording();`ifdef ALTERA_AVALON_SIM_MTIcommand_trans_stream =$create_transaction_stream("avalon_mm_monitor_bfm_cmd");`endifendfunctionfunction automatic void begin_record_command_trans();`ifdef ALTERA_AVALON_SIM_MTIcommand_trans = $begin_transaction(command_trans_stream, "Command");`endifendfunctionfunction automatic void end_record_command_trans();`ifdef ALTERA_AVALON_SIM_MTIstring field;if (!reset) begin$add_attribute(command_trans, current_command.request, "request");$add_attribute(command_trans, current_command.address, "address");$add_attribute(command_trans, current_command.burst_count, "burst_count");if (current_command.request == REQ_WRITE) beginfor (int i=0; i<current_command.burst_count; i++) begin$sformat(field, "data_cycle_%0d", i);$add_attribute(command_trans, current_command.data[i], field);$sformat(field, "byte_enable_cycle_%0d", i);$add_attribute(command_trans, current_command.byte_enable[i], field);endend$end_transaction(command_trans);$free_transaction(command_trans);end`endifendfunction//--------------------------------------------------------------------------initial begin// $vcdpluson; // for debugging with DVEif (PRINT_HELLO)hello();init_transaction_recording();end//--------------------------------------------------------------------------always @(posedge clk) clock_counter++;always @(command) command_counter++;always @(response) response_counter++;always @(signal_fatal_error) begin$sformat(message, "%m: Terminate simulation.");print(VERBOSITY_FAILURE, message);abort_simulation();endalways @(posedge clk) beginfork: monitorbegin#1 monitor_command();begin_record_command_trans();endbegin@(posedge clk);end_record_command_trans();endjoin_any;endtask monitor_command();current_command.address = avm_address;current_command.burst_count = avm_burstcount;if (avm_read && avm_write) begincurrent_command.address = avm_address;$sformat(message, "%m: Error - both write and read active, address: %0d",current_command.address);print(VERBOSITY_FAILURE, message);end else if (avm_write) beginif (avm_beginbursttransfer) begincurrent_command = '0;addr_offset = 0;burst_mode = 1;end else if (burst_mode) beginif (addr_offset == avm_burstcount-1) beginburst_mode = 0;addr_offset = 0;end else beginaddr_offset++;endend else begincurrent_command = '0;burst_mode = 0;addr_offset = 0;endcurrent_command.request = REQ_WRITE;current_command.data[addr_offset] = avm_writedata;current_command.byte_enable[addr_offset] = avm_byteenable;current_command.burst_cycle = addr_offset;->command;end else if (avm_read) begincurrent_command = '0;burst_mode = 0;addr_offset = 0;current_command.request = REQ_READ;// according to the Avalon spec, we expect that the master does// not drive writedata and byteenable during read request, but// this behavior may be violated in custom componentscurrent_command.data = avm_writedata;current_command.byte_enable = avm_byteenable;endendtaskalways @(posedge clk) beginif (USE_WAIT_REQUEST == 0) beginif (reset) beginlocal_avs_waitrequest = 0;read_wait_time = 0;write_wait_time = 0;end else beginlocal_avs_waitrequest = 0;if (AV_READ_WAIT_TIME > 0) begin#1;if (avs_read) beginif (read_wait_time < AV_READ_WAIT_TIME) beginlocal_avs_waitrequest = 1;read_wait_time++;end else beginlocal_avs_waitrequest = 0;read_wait_time = 0;endendendif (AV_WRITE_WAIT_TIME > 0) begin#1;if (avs_write) beginif (write_wait_time < AV_WRITE_WAIT_TIME) beginlocal_avs_waitrequest = 1;write_wait_time++;end else beginlocal_avs_waitrequest = 0;write_wait_time = 0;endendendendend else beginlocal_avs_waitrequest = avm_waitrequest;endend// synthesis translate_onfunction integer log2(input int value);//-----------------------------------------------------------------------------// Mathematic logarithm function with base as 2.//-----------------------------------------------------------------------------value = value-1;for (log2=0; value>0; log2=log2+1)beginvalue = value>>1;endendfunction: log2function logic [lindex(AV_ADDRESS_W):0] address_shift(input logic [lindex(AV_ADDRESS_W):0] value);//-----------------------------------------------------------------------------// Shift the slave interface address back as master interface address.//-----------------------------------------------------------------------------if (value >= 0)address_shift = value << log2(AV_NUMSYMBOLS);elseaddress_shift = 'x;endfunction: address_shiftendmodule
