Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17251 Discussions

Quartus is flipping bits when negative range is used ?!

Altera_Forum
Honored Contributor II
1,469 Views

Hi, 

 

weird thing. I'm trying to assign wires to each other, and quartus is doing it in reverse ! 

for example (Verilog) 

 

wire [9:0] a; 

wire [0:-9] b; 

 

when I do: assign a=b, I get that a is reversed b, 

i.e. if a="1110001010" then b is "0101000111" 

this is definitely not how Verilog works, is it a bug in quartus ?!
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
626 Views

Whats the problem if you declare b as wire [9:0] b??

0 Kudos
Altera_Forum
Honored Contributor II
626 Views

the entire design is written as a pixed-point DSP, 

so... [3:-9] means 4 bits for integer, 9 bits for fractional. 

 

that's the design, that's how verilog works. 

The problem, is that I'm using filters that Matlab generated, and they use the "traditional" notation (the [9:0] one...), so the filter gets the bits in reverse. 

 

but now I see the bug is only in SignalTap way of displaying the numbers, they are not reversed when I open the busses and compare bit to bit. 

only as a group
0 Kudos
Altera_Forum
Honored Contributor II
626 Views

 

--- Quote Start ---  

Hi, 

 

weird thing. I'm trying to assign wires to each other, and quartus is doing it in reverse ! 

for example (Verilog) 

 

wire [9:0] a; 

wire [0:-9] b; 

 

when I do: assign a=b, I get that a is reversed b, 

i.e. if a="1110001010" then b is "0101000111" 

this is definitely not how Verilog works, is it a bug in quartus ?! 

--- Quote End ---  

 

 

Normally when you say a="1110001010", it means (from right to left) a[0]=0, a[1]=1, a[2]=0,... a[9]=1. This means the bit at the most left is the MSB. Most computer software will read the "a" vector as a number and always place the MSB at the left regardless of your Verilog declaration. Are you sure that's not the case? 

 

Your post is unclear as it does not specify the bitfields of "b". 

Check individual bits separately (b[-9], b[-8] and so on) and see if they are correct. 

 

Because of the way the vectors are declared in this case, the correct way Verilog should "work" when you do 'assign a=b', is like this: 

a[0] = b[-9] 

a[1] = b[-8] 

a[2] = b[-7] 

... 

a[9] = b[0] 

 

If you're getting something different, the it's a bug in Quartus.
0 Kudos
Reply