Questions tagged [system-verilog]
SystemVerilog is a unified hardware design, specification, and verification language based on extensions to Verilog.
2,829
questions
0
votes
0
answers
15
views
trying to make an even-odd sorter on quartus (systermverilog) but simulation problems
this a cell as i'm using multiple cells in parallel to sort an array each cell is supposed to take 2 elements of this array either even or odd indexed (as you will see in the top level ) and output ...
1
vote
0
answers
14
views
Error when I run a testbench using VCS with $urandom
I have some problems when I run this testbench using vcs:
module test;
reg [31:0] a;
reg [31:0] b;
reg c;
integer seed,i,seed_num,j;
initial begin
seed=4;
for (i=0; i<20;i=i+1)begin
a=$urandom(...
0
votes
1
answer
29
views
Multiport driven issue with CAM
I'm trying to code a CAM where when a new entry comes, it checks with the existing entries in the table and if it is not there, it is added in the table considering there are some empty spaces in the ...
0
votes
1
answer
32
views
Instantiate VHDL entity with 2D array from SystemVerilog
There seems to be very little documentation on how to pass 2D arrays between VHDL and SystemVerilog. I have a port of the following type in VHDL:
package my_package is
type my_array_t is array (...
0
votes
1
answer
21
views
Get port name in SystemVerilog
I wonder if the modules have any visibility into the hierarchy of the ports? Can the port hierarchy be printed out?
For a minimum working example, assume I have this:
module top ();
logic my_sig;
...
0
votes
0
answers
43
views
System Verilog Interface Array as Port Parameter
The code:
interface a_if;
logic foo;
endinterface
interface b_if;
a_if a();
endinterface
module y(a_if a);
logic bar;
endmodule
module z();
b_if b();
y y(b.a);
logic lex;
...
-1
votes
1
answer
36
views
Detect posedge for sync signal [Without using @posedge signal]
I'm trying to detect the posedge of a synchronous signal, but I don't know how to implement it relative to the clock [Without using @posedge signal].
Can I implement it like @(posedge clk iff -----)?
0
votes
1
answer
34
views
Non-constant expression specified where only constant expressions are allowed
I have my dummy code in here.
I remember coding like this before.
But I'm getting an error saying non-constant expression is used where only constant expressions are allowed.
If I have to do the same, ...
0
votes
1
answer
38
views
Complex DataType in system verilog(hash of queues)
Suppose I declared a queue: axi4_req_txn_t wr_req_queue[$];
Now I want to have a hash of queue, key is the address and data is the pointer to the queue; Is it possible in systemverilog ?
when I write ...
0
votes
1
answer
19
views
Whether the random numbers generated by $urandom_range() are 'cyclical random'?
It's a Sample from SystemVerilog for Verification-A Guide to Learning the Testbench Language Features.
In class Driver, if drop==0 , transaction will be lost. Why drop = ($urandom_range(0,99) == 0) ...
1
vote
1
answer
34
views
Pad or truncate vector assignments based on parameter values
I have a module that can be configured with two parameters. Depending on the values of these parameters, I either need to pad or truncate an output vector when assigning it to an input vector. For ...
-1
votes
0
answers
32
views
Cross coverage binsof construct
I want to know why bins ad12,13,14,15 are not being displayed. When I change the binsof ad32 and intersect the values which are not common, it is also not being displayed. If the values are not hit, ...
1
vote
1
answer
45
views
I wrote this code in Verilog and there are no error messages, but it doesn't work
This is the module:
module test (output reg [7:0] Q_out, input [2:0] data_in);
always
begin
case (data_in)
3'b000: Q_out = 8'b10000000;
3'b001: Q_out = 8'b01000000;
...
0
votes
1
answer
29
views
Lint is unable to catch RHS and LSH width mismatch
Below piece of logic is doing 2^(3+x), where x is 2 bit value and can have max 2'b11, according to the below logic, RHS will be 1 << 6, which is 7'b1000000. MSB will be discarded as LHS is of 6 ...
0
votes
1
answer
25
views
How to auto-extend the data with the MSB aligned?
I am now trying to create a "print" in Verilog to help me debug.
When assigning a short string to a long buffer.
For example:
reg[63:0] buf;
task print(input[63:0] in);
begin
buf<=in;
...
0
votes
1
answer
28
views
Getting the size of a SystemVerilog macro range
I have a code with a number of different signals whose width is defined by macro ranges like this:
`define MY_RANGE_1 8:2
`define MY_RANGE_2 12:0
`define MY_RANGE_3 5:0
I want to obtain the widths of ...
-1
votes
0
answers
43
views
Why cant we write data from 2D array logic to 1D array in system verilog?
module RegisterFile(ReadRegister1, ReadRegister2, WriteRegister, WriteData, RegWrite, ReadData1, ReadData2);
input [4:0] ReadRegister1, ReadRegister2, WriteRegister;
input [31:0] WriteData;
...
1
vote
1
answer
45
views
How to invert a bit of a packed array
logic [4:0] count_zeros;
logic [2:0] id;
integer i;
logic [7:0] [15:0] vld;
always@*
begin
count_zeros = 5'b0;
for (i=0; i<2; i=i+1)
count_zeros = count_zeros + ~vld[id][i];
end
For an ...
0
votes
1
answer
29
views
How to override localparam? -GPARAM=VAL not working
I know we can override a generic/parameter in Verilog/SystemVerilog using vsim's option -GMYPARAM=VALUE.
This doesn't work for a localparam and the use of localparam in the module to prevent the ...
1
vote
1
answer
21
views
Retrieving Data from Register File (Unpacked Array)
I try to write a register file for updating and retrieving data from it. Here is my code
module RegisterFile(input logic clk
,input logic M_we // M_we is write ...
0
votes
2
answers
41
views
UVM end-of-test mechanism
task mabu_scoreboard::main_phase(uvm_phase phase);
forever begin
# 1ns;
if(extip_rd_req_cnt - extip_rd_rsp_cnt >= `MABU_READ_OST_NUM) begin
hit_rd_max_outstanding = 1;
`...
1
vote
1
answer
26
views
Unexpected Xs in the result of addition of two logic signals
I have a code where two signals are added. Only top bits of the signals are X. Bottom bits are 0s.
But, the result has all Xs. I would expect the bottom bits to be 0s in the result.
logic [3:0] a; // ...
-1
votes
0
answers
69
views
FPGA bitfile acting different with the simulation
I wrote some RTL like this:
wire[255:0] tx_data;
wire[4:0] tx_empty;
reg [255:0] mask1, mask2, mask3;
reg [95:0] tmp0, tmp1, tmp2, tmp3, tmp4;
wire [95:0] timestamp, ...
-1
votes
0
answers
34
views
how to pipeline in system verilog
I have these assign statemnts in system verilog that I wanted to pipeline, but i'm not quite sure how to do that.
assign torque_off = avg_torque - torque_min;
assign incline_lim = (!incline_factor[10] ...
0
votes
1
answer
36
views
Meaning of |-> 1[0:$] in assertions in system verilog
usage example
state==ACTIVE1 |-> 1[0:$] ##1 state==ACTIVE2
The problem the assertion trying to solve is
if the state machine reaches state=ACTIVE1, it will eventually reach state=ACTIVE2
Any idea ...
1
vote
1
answer
37
views
Verilog/SystemVerilog: passing a slice of an unpacked array to a module
I am using a DE10-Nano with Quartus Prime to try to implement the following.
I have two modules: Module1 and Module2. Module1 declares a RAM like this:
reg [15:0] RAM[0:24576];
// init RAM 0:8191 with ...
-1
votes
0
answers
49
views
Getting different results from Icarus verilog and Xilinx Vivado
I am doing a project on March C tests and I started doing the project on the online tool, EDA playground. I did all the testing there and got the expected results so I decided to move the project on ...
1
vote
1
answer
633
views
Getting output of convolutional PE as XXX instead of a number?
`timescale 1ns / 1ps
// Description: This device performs convolution operation with a 3x3 kernel.
//////////////////////////////////////////////////////////////////////////////////
module ...
-2
votes
0
answers
67
views
How can I split a 3 digits decimal number into digits in System Verilog?
I have to present a 3 digit decimal number into seperate digits.
I have thought about using - % operator but the counting isn't right, so I would like to know
if in the next enter code herecode I ...
-1
votes
1
answer
74
views
Why is this line getting the error : Expecting a left parenthesis ( '(' ) [12.1.2][7.1(IEEE)]?
I have a Verilog code for a simple multiplier as shown below, which takes two 32-b inputs which are split into two (16-b MSB and 16-b LSB) and multiplied:
parameter WordLen1 = 32, WordLen2 = 16;
...
1
vote
2
answers
79
views
Why am I getting the error : part select cannot be applied to scalar in my testbench?
I have designed a multiplier circuit that has two 32-b inputs, that would be split into two 16-b values and multiplied separately after which the results will be added together. Here is a part of the ...
1
vote
1
answer
28
views
predict clock in user defined primitive
So basically there is udp in verilog for which we define tables. This table is maintained in memory in code.
Eg.
primitive abc(q,d,clk,not);
input d, clk, not;
output q;
reg q;
table
|0 1 ? : ? :...
-1
votes
1
answer
44
views
Is assign statement in system verilog two way assignment ? If LHS is driven does RHS change?
Consider the assignment below
assign A = B;
if I force A from testbench does B change ? If it does what happens in the conditional assignment scenario ?
assign A = S ? B : C;
0
votes
1
answer
43
views
How does streaming operator unpacking work?
Consider the following code:
wire unpacked_wire[3:0];
wire [3:0] packed_wire;
assign unpacked_wire = packed_wire; // Error: Cannot assign packed type to unpacked type
assign {>>{...
0
votes
1
answer
73
views
Defining void function in Verilog?
I know that we can write functions in verilog just to display sth. like in the example below:
function ex_func;
input op;
input [1:0] in1;
input [1:0] in2;
input [1:0] out1;
begin
...
1
vote
1
answer
52
views
Swapping 2 parameters in always_ff @
I have an issue with my code.
I'm trying to swap between Xspeed and Yspeed at the same clock while the if statement is true.
I'm getting the errors:
cant resolve multiple constant drivers for net
...
0
votes
1
answer
52
views
Verilog: Understanding multiple driver on bidirectional signal
I am debugging some Verilog code and I'm having some difficulty understanding a bidirectional signal with multiple drivers:
The verilog code looks like this:
inout a;
assign a = b ? c : 1'bz
a=...
0
votes
1
answer
41
views
Multiple assignments to function return value
In a SystemVerilog function, is it legal to do multiple assignments to the implicitly-declared return variable? See the following function for an example:
localparam int Q=1,I=0;
function logic [1:...
0
votes
1
answer
62
views
Error message ”sorry: constant selects in always_* processes are not currently supported (all bits will be included).“ in SystemVerilog
I need to use "case" statement to implement a 4-bit priority encoder,and the code is showed below:
module case2(
input [3 : 0] in,
output logic [1 : 0] pos
);
always_comb begin
...
0
votes
1
answer
31
views
working of `line compiler directive in system verilog
Can someone please explain the working of `line compiler directive in system verilog tried to read it's working from LRM but was not able to understand it
0
votes
1
answer
35
views
How to use let with typedef signals?
I'm trying to use let-constructs instead of `define in my TB to access some signals via hierarchical paths. It's not going that great. "Normal" signals seems to work and I can access them, ...
0
votes
1
answer
40
views
How to initi SV queue with binary values
I have an queue, which I want to init with the binary value. What is the best way to do that?
logic serial_frame[$]; // Want to init with 0010_0000_1000_0
2
votes
1
answer
51
views
How does SystemVerilog compiler knows to separate two arguments in a macro?
I have this macro:
`define do_code(DO_SOETHING, ID) \
fork \
begin \
``DO_SOMETHING`` \
end \
begin \
$display("%s",ID.name()); \
end \
...
0
votes
1
answer
40
views
Gate-level timing checks in SVA
I need to check the value of a signal after a certain amount of time a clock edge occurs. For example, I want to check that if signal b asserts to high 1ps after posedge clock occurs.
Does SVA provide ...
0
votes
1
answer
41
views
Shortening a dist style constraint in SystemVerilog
I have a constraint of the form:
s dist {0:= 20, 1:= 25, 2:= 30, <many more, possibly hundreds>};
Instead of writing down the constraint this way, I found in my application the RHS (i.e. the ...
0
votes
1
answer
46
views
Missing connection for port 'v1'
I'm working on a systemVerilog code, where a lookup value is being compared to 8 registers of the same bit size, it should give valid 1 if one of the registers matches the the lookup val. everything ...
1
vote
1
answer
60
views
UVM Verbosity override
Is there a way to override any verbosity switches that have been given and force verbosity to a different value in UVM?
+uvm_set_verbosity=*abc*,_ALL_,UVM_FULL,run
+uvm_set_verbosity=*aes*,_ALL_,...
1
vote
2
answers
40
views
Masking input unpacked array
I want to "mask" an input unpacked array given a specific signal. If that signal is 1, I want the input to be all zeroes instead of the given array.
module thing (
input clk,
input rst,
...
0
votes
1
answer
50
views
Way to pick random addresses from dynamic ranges in SV constraints
I have a requirement to pick random addresses from a set of predefined ranges in Systemverilog
program test;
int unsigned q[$], rSz;
typedef struct {
int unsigned from, till;
} range_t;
initial ...
-1
votes
1
answer
42
views
Best way to optionally register inputs
I have a systemverilog module with a LOT of input signals of varying sizes. I want to optionally register them before use. Here is my desired criteria for the code that does this optional registering:
...