-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsram_uvm_components.sv
More file actions
140 lines (113 loc) · 2.97 KB
/
Copy pathsram_uvm_components.sv
File metadata and controls
140 lines (113 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
`timescale 1ns/1ps
import uvm_pkg::*;
`include "uvm_macros.svh"
// SRAM Driver
class sram_driver extends uvm_driver;
`uvm_component_utils(sram_driver)
virtual interface sram_if vif;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
task run_phase(uvm_phase phase);
forever begin
// Wait for a transaction
sram_transaction tr;
seq_item_port.get_next_item(tr);
// Drive the signals based on the transaction
vif.address <= tr.address;
vif.data <= tr.data;
vif.we <= tr.we;
vif.oe <= tr.oe;
vif.cs <= tr.cs;
// Wait for a clock cycle
@(posedge vif.clk);
// Indicate the transaction is done
seq_item_port.item_done();
end
endtask
endclass
// SRAM Monitor
class sram_monitor extends uvm_monitor;
`uvm_component_utils(sram_monitor)
virtual interface sram_if vif;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
task run_phase(uvm_phase phase);
forever begin
// Capture the signals
sram_transaction tr;
tr.address = vif.address;
tr.data = vif.data;
tr.we = vif.we;
tr.oe = vif.oe;
tr.cs = vif.cs;
// Send the transaction to the analysis port
analysis_port.write(tr);
// Wait for a clock cycle
@(posedge vif.clk);
end
endtask
endclass
// SRAM Scoreboard
class sram_scoreboard extends uvm_scoreboard;
`uvm_component_utils(sram_scoreboard)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
task run_phase(uvm_phase phase);
forever begin
// Wait for a transaction from the monitor
sram_transaction tr;
analysis_port.get(tr);
// Compare expected and actual results
if (tr.expected_data !== tr.actual_data) begin
`uvm_error("Scoreboard", $sformatf("Data mismatch: expected %0h, got %0h", tr.expected_data, tr.actual_data));
end
end
endtask
endclass
// SRAM Coverage Collector
class sram_coverage extends uvm_subscriber;
`uvm_component_utils(sram_coverage)
covergroup cg;
coverpoint vif.address;
coverpoint vif.data;
coverpoint vif.we;
coverpoint vif.oe;
coverpoint vif.cs;
endgroup
function new(string name, uvm_component parent);
super.new(name, parent);
cg = new();
endfunction
task run_phase(uvm_phase phase);
forever begin
// Sample coverage points
cg.sample();
@(posedge vif.clk);
end
endtask
endclass
// SRAM Sequence
class sram_sequence extends uvm_sequence;
`uvm_object_utils(sram_sequence)
function new(string name = "sram_sequence");
super.new(name);
endfunction
task body();
sram_transaction tr;
// Example test scenario: Write and then read
tr.address = 16'h0000;
tr.data = 8'hAA;
tr.we = 1;
tr.oe = 0;
tr.cs = 1;
start_item(tr);
finish_item(tr);
tr.we = 0;
tr.oe = 1;
start_item(tr);
finish_item(tr);
endtask
endclass