summaryrefslogtreecommitdiff
path: root/homework_2/SRC/gen_item_seq.sv
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-24 20:46:14 -0800
committerFuwn <[email protected]>2026-02-24 20:46:14 -0800
commit57bb24b96645ad0f60c6e6968a6b2ac48754e2dc (patch)
tree9f7da4da999b87ea9541e5ad83b9cbe87f674ce7 /homework_2/SRC/gen_item_seq.sv
parentfeat(homework_2): Add initial files (diff)
downloadcst456-57bb24b96645ad0f60c6e6968a6b2ac48754e2dc.tar.xz
cst456-57bb24b96645ad0f60c6e6968a6b2ac48754e2dc.zip
feat(homework_2): Add implementation
Diffstat (limited to 'homework_2/SRC/gen_item_seq.sv')
-rw-r--r--homework_2/SRC/gen_item_seq.sv58
1 files changed, 36 insertions, 22 deletions
diff --git a/homework_2/SRC/gen_item_seq.sv b/homework_2/SRC/gen_item_seq.sv
index c42cf3a..ce3c3f5 100644
--- a/homework_2/SRC/gen_item_seq.sv
+++ b/homework_2/SRC/gen_item_seq.sv
@@ -1,22 +1,36 @@
-// The generator class is replaced by a sequence
-class gen_item_seq extends uvm_sequence;
- `uvm_object_utils(gen_item_seq)
- function new(string name="gen_item_seq");
- super.new(name);
- endfunction
-
- rand int num; // Config total number of items to be sent
-
- constraint c1 { soft num inside {[10:50]}; }
-
- virtual task body();
- for (int i = 0; i < num; i ++) begin
- Item m_item = Item::type_id::create("m_item");
- start_item(m_item);
- m_item.randomize();
- `uvm_info("SEQ", $sformatf("Generate new item: %s", m_item.convert2str()), UVM_HIGH)
- finish_item(m_item);
- end
- `uvm_info("SEQ", $sformatf("Done generation of %0d items", num), UVM_LOW)
- endtask
-endclass \ No newline at end of file
+// The generator class is replaced by a sequence
+class gen_item_seq extends uvm_sequence;
+ `uvm_object_utils(gen_item_seq)
+ function new(string name = "gen_item_seq");
+ super.new(name);
+ endfunction
+
+ rand int num; // Config total number of items to be sent
+
+ constraint c1 {soft num inside {[300 : 500]};}
+
+ virtual task body();
+ bit seed_bits [$] = '{1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0};
+ int total_num;
+
+ total_num = (num < seed_bits.size()) ? seed_bits.size() : num;
+
+ for (int i = 0; i < total_num; i++) begin
+ Item m_item = Item::type_id::create($sformatf("m_item_%0d", i));
+
+ start_item(m_item);
+
+ if (i < seed_bits.size()) begin
+ m_item.inp = seed_bits[i];
+ end else begin
+ if (!m_item.randomize()) `uvm_fatal("SEQ", "Randomization failure for sequence item")
+ end
+
+ `uvm_info("SEQ", $sformatf("Generate new item: %s", m_item.convert2str()), UVM_HIGH)
+
+ finish_item(m_item);
+ end
+
+ `uvm_info("SEQ", $sformatf("Done generation of %0d items", total_num), UVM_LOW)
+ endtask
+endclass