EmbDev.net

Forum: FPGA, VHDL & Verilog Beginner's problem with very simple Verilog buffer


von jhin (Guest)


Rate this post
useful
not useful
Hey everyone,

I've got a hopefully easy to solve question.
The following Code is given:

1
module filter
2
  (
3
    input                 clk,
4
    input                 en,
5
    input [31:0]          rawdata,
6
    output [31:0]         filtered_data
7
  );
8
  
9
  reg [31:0]              filtered_data_q;
10
11
  assign filtered_data    = filtered_data_q;
12
13
  // filter + register
14
  always @(posedge clk)
15
    if (en)
16
      // Simple recursive filtering
17
      filtered_data_q <= filtered_data_q * 3 / 4 + rawdata / 4;
18
    else
19
      filtered_data_q <= filtered_data_q;
20
    
21
endmodule

This code synthesizes and simulates perfectly, just as expected.
But once I add a simple(st) buffer, nothing works:

1
  wire    temp;
2
  assign  temp = rawdata;
Additionally, I used 'temp' instead of 'rawdata' for the filter.

The result is that my complete filtered_q register is removed during 
optimization step for the following reason: "Stuck at GND due to stuck 
port data_in"

I also tried
1
  reg temp;
2
  always @ (rawdata)
3
    temp = rawdata;
but that did not change anything.

Any Explanations? Why does this happen?

von Uwe Bonnes (Guest)


Rate this post
useful
not useful
Did youb really write
wire
and not
wire[31:0]
?
Do temp at max resolves to `'b1 and
1'b1 >>4
is alway 0!

von jhin (Guest)


Rate this post
useful
not useful
Haha, you're right!
I expected it to be a stupid mistake, not knowing it could be THAT 
stupid ... :-)
Anyway, thanks a lot for pointing it out!

Greets,
jhin

von beginner (Guest)


Rate this post
useful
not useful
Hallo Uwe,

can you explain that is the different between

wire  and wire[31:0]   ?


thank you

von not Uwe (Guest)


Rate this post
useful
not useful
wire means only 1 bit
wire[31:0] means 32 bits

because verilog doesn't talk and disallow as much as vhdl, it is 
accepted to fed a 32bit vector into a 1 bit(keeping only 1 bit!).

So all other 31 bits are lost and you will never know it.
(maybe there is a warning from synthesis tool, don't know)

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.