Steve Nelson | ef7bcab | 2021-01-06 08:40:01 -0800 | [diff] [blame] | 1 | // Copyright lowRISC contributors. |
| 2 | // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | class csrng_item extends uvm_sequence_item; |
| 6 | |
Steve Nelson | ef7bcab | 2021-01-06 08:40:01 -0800 | [diff] [blame] | 7 | `uvm_object_utils_begin(csrng_item) |
| 8 | `uvm_object_utils_end |
| 9 | |
| 10 | `uvm_object_new |
| 11 | |
Steve Nelson | 1ae3152 | 2021-06-28 07:29:22 -0700 | [diff] [blame] | 12 | rand acmd_e acmd; |
| 13 | rand bit [3:0] clen, flags; |
| 14 | rand bit [18:0] glen; |
| 15 | rand bit [31:0] cmd_data_q[$]; |
| 16 | |
| 17 | // TODO: Try clen > 12 |
| 18 | constraint c_clen { |
| 19 | clen inside {[0:12]}; |
| 20 | }; |
| 21 | |
| 22 | constraint c_cmd_data { |
| 23 | solve clen before cmd_data_q; |
| 24 | |
| 25 | cmd_data_q.size() == clen; |
| 26 | }; |
| 27 | |
| 28 | constraint c_flags { |
| 29 | flags inside {[0:1]}; |
| 30 | }; |
| 31 | |
| 32 | // TODO: add/fix glen constraint |
| 33 | // constraint c_glen { |
| 34 | // solve acmd before glen; |
| 35 | // |
| 36 | // if (acmd != csrng_pkg::GEN) |
| 37 | // glen == 'h0; |
| 38 | // }; |
Steve Nelson | 67a5d9f | 2021-02-25 07:19:46 -0800 | [diff] [blame] | 39 | |
| 40 | virtual function string convert2string(); |
| 41 | string str = ""; |
| 42 | str = {str, "\n"}; |
Steve Nelson | 9c384a3 | 2021-05-24 06:25:49 -0700 | [diff] [blame] | 43 | str = {str, $sformatf("\n\t |*********** csrng_item ************| \t") }; |
Steve Nelson | 1ae3152 | 2021-06-28 07:29:22 -0700 | [diff] [blame] | 44 | str = {str, $sformatf("\n\t |* acmd : %4s *| \t", acmd.name()) }; |
Steve Nelson | 9c384a3 | 2021-05-24 06:25:49 -0700 | [diff] [blame] | 45 | str = {str, $sformatf("\n\t |* clen : 0x%0h *| \t", clen) }; |
| 46 | str = {str, $sformatf("\n\t |* flags : 0x%0h *| \t", flags) }; |
| 47 | str = {str, $sformatf("\n\t |* glen : 0x%5h *| \t", glen) }; |
| 48 | if (cmd_data_q.size()) begin |
| 49 | for (int i = 0; i < cmd_data_q.size(); i++) begin |
| 50 | str = {str, $sformatf("\n\t |* cmd_data_q[%2d] : 0x%0h *| \t", i, cmd_data_q[i]) }; |
Steve Nelson | b9dc728 | 2021-04-19 13:19:10 -0700 | [diff] [blame] | 51 | end |
Steve Nelson | b9dc728 | 2021-04-19 13:19:10 -0700 | [diff] [blame] | 52 | end |
Steve Nelson | 9c384a3 | 2021-05-24 06:25:49 -0700 | [diff] [blame] | 53 | str = {str, $sformatf("\n\t |***********************************| \t") }; |
Steve Nelson | 67a5d9f | 2021-02-25 07:19:46 -0800 | [diff] [blame] | 54 | str = {str, "\n"}; |
| 55 | return str; |
| 56 | endfunction |
| 57 | |
Steve Nelson | ef7bcab | 2021-01-06 08:40:01 -0800 | [diff] [blame] | 58 | endclass |