URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
Compare Revisions
- This comparison shows the changes necessary to convert path
/qaz_libs/trunk/BFM/src/SPI
- from Rev 48 to Rev 50
- ↔ Reverse comparison
Rev 48 → Rev 50
/spi_agent.svh
25,32 → 25,24
//// //// |
////////////////////////////////////////////////////////////////////// |
|
class spi_agent |
class spi_agent #(N=1) |
extends uvm_agent; |
`uvm_component_utils(spi_agent) |
`uvm_component_param_utils(spi_agent #(N)) |
|
// -------------------------------------------------------------------- |
virtual spi_if vif; |
spi_driver driver_h; |
virtual spi_if #(N) vif; |
spi_driver #(N) driver_h; |
spi_sequencer sequencer_h; |
// spi_monitor monitor_h; |
|
// -------------------------------------------------------------------- |
virtual function void build_phase(uvm_phase phase); |
// super.build_phase(phase); |
driver_h = spi_driver::type_id::create("driver_h", this); |
// monitor_h = spi_monitor ::type_id::create("monitor_h", this); |
driver_h = spi_driver #(N)::type_id::create("driver_h", this); |
sequencer_h = spi_sequencer::type_id::create("sequencer_h", this); |
|
endfunction |
|
// -------------------------------------------------------------------- |
virtual function void connect_phase(uvm_phase phase); |
// super.connect_phase(phase); |
|
driver_h.vif = vif; |
// monitor_h.vif = vif; |
|
driver_h.seq_item_port.connect(sequencer_h.seq_item_export); |
endfunction |
|
60,4 → 52,4
endfunction |
|
// -------------------------------------------------------------------- |
endclass : spi_agent |
endclass |
/spi_driver.svh
25,17 → 25,17
//// //// |
////////////////////////////////////////////////////////////////////// |
|
class spi_driver |
class spi_driver #(N) |
extends uvm_driver #(spi_sequence_item); |
`uvm_component_utils(spi_driver) |
`uvm_component_param_utils(spi_driver #(N)) |
|
// -------------------------------------------------------------------- |
virtual spi_if vif; |
virtual spi_if #(N) vif; |
|
//-------------------------------------------------------------------- |
function void set_default; |
vif.sclk <= 0; |
vif.ss_n <= 1; |
vif.ss_n <= '1; |
vif.mosi <= 'x; |
endfunction: set_default |
|
51,7 → 51,8
index = 0; |
seq_item_port.get_next_item(item); |
|
vif.ss_n <= 0; |
vif.ss_n <= ~(1 << item.ss_index); |
|
vif.mosi <= item.mosi_data[index]; |
#(vif.period / 2); |
|
75,7 → 76,7
end |
|
#(vif.period / 2); |
vif.ss_n <= 1; |
vif.ss_n <= '1; |
|
set_default(); |
seq_item_port.item_done(); |
89,4 → 90,4
endfunction |
|
// -------------------------------------------------------------------- |
endclass : spi_driver |
endclass |
/spi_if.sv
25,8 → 25,7
//// //// |
////////////////////////////////////////////////////////////////////// |
|
interface |
spi_if(); |
interface spi_if #(N=1); |
import uvm_pkg::*; |
`include "uvm_macros.svh" |
import tb_spi_pkg::*; |
33,7 → 32,7
|
// -------------------------------------------------------------------- |
logic sclk; |
logic ss_n; |
logic [N-1:0] ss_n; |
logic mosi; |
logic miso; |
|
/spi_sequence_item.svh
35,6 → 35,7
// -------------------------------------------------------------------- |
logic miso_data[]; // data from slave to master |
logic mosi_data[]; // data from master to slave |
int ss_index = 0; |
bit read; |
bit write; |
|
56,38 → 57,34
mosi_data[i] = 0; |
endfunction : init |
|
// // -------------------------------------------------------------------- |
// function bit do_compare(uvm_object rhs, uvm_comparer comparer); |
// spi_sequence_item tested; |
// bit same; |
// -------------------------------------------------------------------- |
function void load_mosi_from_file(string file_name); |
byte buffer; |
integer fd; |
integer code; |
integer size; |
|
// if (rhs==null) |
// `uvm_fatal(get_type_name(), "| %m | comparison to a null pointer"); |
fd = $fopen(file_name, "rb"); |
code = $fseek(fd, 0, 2); // SEEK_END |
size = $ftell(fd); |
code = $rewind(fd); |
data_width = size*8; |
mosi_data = new[data_width]; |
write = 1; |
|
// if (!$cast(tested,rhs)) |
// same = 0; |
// else |
// same = super.do_compare(rhs, comparer); |
for(int i = 0; i < size; i++) begin |
code = $fread(buffer, fd); |
mosi_data[i*8 +: 8] = {>>{buffer}}; |
end |
|
// return same; |
// endfunction : do_compare |
$fclose(fd); |
endfunction |
|
// // -------------------------------------------------------------------- |
// function void do_copy(uvm_object rhs); |
// spi_sequence_item item; |
// assert(rhs != null) else |
// `uvm_fatal(get_type_name(), "| %m | copy null transaction"); |
// super.do_copy(rhs); |
// assert($cast(item,rhs)) else |
// `uvm_fatal(get_type_name(), "| %m | failed cast"); |
// delay = item.delay; |
// command = item.command; |
// wr_full = item.wr_full; |
// rd_empty = item.rd_empty; |
// wr_data = item.wr_data; |
// rd_data = item.rd_data; |
// count = item.count; |
// endfunction : do_copy |
// -------------------------------------------------------------------- |
function void load_mosi_from_byte_array(byte byte_array[]); |
foreach(byte_array[i]) |
mosi_data[i*8 +: 8] = {>>{byte_array[i]}}; |
endfunction |
|
// -------------------------------------------------------------------- |
function string convert2string(); |
102,8 → 99,7
); |
s0 = {s0, s1}; |
|
if(read) |
begin |
if(read) begin |
data = {>>{miso_data}}; |
|
foreach(data[i]) |
113,8 → 109,7
s0 = {s0, s2}; |
end |
|
if(write) |
begin |
if(write) begin |
data = {>>{mosi_data}}; |
|
foreach(data[i]) |
128,4 → 123,4
endfunction : convert2string |
|
// -------------------------------------------------------------------- |
endclass : spi_sequence_item |
endclass |
/tb_spi_pkg.sv
28,28 → 28,12
package tb_spi_pkg; |
import uvm_pkg::*; |
`include "uvm_macros.svh" |
import bfm_pkg::*; |
|
// // -------------------------------------------------------------------- |
// localparam W = 16; |
// localparam D = 8; |
// localparam UB = $clog2(D); |
|
// -------------------------------------------------------------------- |
// typedef enum {FIFO_RD, FIFO_WR, FIFO_BOTH, FIFO_NULL} fifo_command_t; |
|
// -------------------------------------------------------------------- |
`include "spi_sequence_item.svh" |
typedef uvm_sequencer #(spi_sequence_item) spi_sequencer; |
`include "spi_driver.svh" |
// `include "spi_monitor.svh" |
// `include "spi_scoreboard.svh" |
`include "spi_agent.svh" |
// `include "tb_env.svh" |
|
// `include "s_debug.svh" |
// `include "t_top_base.svh" |
// `include "t_debug.svh" |
|
// -------------------------------------------------------------------- |
endpackage : tb_spi_pkg |
endpackage |