UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor crotossauro
Visitor
156 Views
Registered: ‎04-18-2019

SystemVerilog syntax question

Jump to solution

Hi all,

I'd like to get some help with a few lines of the code I'm working on. I can't fully understand what it is doing:

 

input [2:0] In_Packet_mod, //(...)

wire [3:0] len = (In_Packet_mod ? In_Packet_mod : 8);

How does the compiler treats the In_Packet_mod to be true or false? All bits being 1s? If true, does len gets a 3 bit value and then gets its MSB set to zero?

also this one, where In_Packet_bus_val is 1 bit wide and Byte_count is 16 bits wide. Does it concatenates or does an AND operation between them? If it's an AND operation, does the compiler adds zeroes to the left or right of In_Packet_bus_val?

if (In_Packet_bus_val && Byte_count < In_Packet_bus_len)

Sorry for the stupid questions, it's been a while since I've done any Verilog at all.

Thanks for the help.

Best regards,

CB

 

0 Kudos
1 Solution

Accepted Solutions
Advisor xilinxacct
Advisor
116 Views
Registered: ‎10-23-2018

Re: SystemVerilog syntax question

Jump to solution

@crotossauro 

I think system verilog follows the same rules a C/C++ operators... so, the answer to the first questions is any non-zero value would be true. And the && is a 'logical' and (not bitwise and), so if both of the 'true' (non-zero) then it should work. I would not expect it to do any concatenation.

Hope that Helps

If so, Please mark as solution accepted. Kudos also welcomed. :-) 

2 Replies
Advisor xilinxacct
Advisor
117 Views
Registered: ‎10-23-2018

Re: SystemVerilog syntax question

Jump to solution

@crotossauro 

I think system verilog follows the same rules a C/C++ operators... so, the answer to the first questions is any non-zero value would be true. And the && is a 'logical' and (not bitwise and), so if both of the 'true' (non-zero) then it should work. I would not expect it to do any concatenation.

Hope that Helps

If so, Please mark as solution accepted. Kudos also welcomed. :-) 

Visitor crotossauro
Visitor
75 Views
Registered: ‎04-18-2019

Re: SystemVerilog syntax question

Jump to solution
Perfect, I've simulated it and it does exactly what you've said. Thanks so much!
0 Kudos