cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
YujiTanaka
Newbie
Newbie
589 Views
Registered: ‎09-06-2020

Vivado 2018.2 Synthesis remove logics, when I use "if (0<counter)"

  I use Vivado 2018.2.
  I synthesis the RTL like as follows, then r_valid fix to 1'b0 and all logics are removed.
  The point of this problem is "0<r_cntx" and "0<r_cnty". When I change these code to "r_cntx>0" or "1<=r_cntx",
then Vivado make correct logic.
  Vivado 2017.3 have no problem. Vivado 2018.2 and 2018.2.2 have this problem.

================

//
// Vivado 2018.2 bug check
//

module vivado_counter (
    i_xrst,
    i_clk,

    i_vs,
    i_de,

    o_valid
);

input                  i_xrst;
input                  i_clk;

input                  i_vs;
input                  i_de;

output                 o_valid;

reg      [1:0]         r_vs;
reg      [1:0]         r_de;
reg      [7:0]         r_cntx;

reg                    r_valid;

  always @( negedge i_xrst or posedge i_clk ) begin
    if (i_xrst==1'b0) begin
      r_vs   <= 2'b11;
      r_de   <= 2'b00;
    end
    else begin
      r_vs   <= {r_vs[0], i_vs};
      r_de   <= {r_de[0], i_de};
    end
  end

  always @(negedge i_xrst or posedge i_clk) begin
    if (i_xrst==1'b0) begin
      r_cntx <= 8'd0;
    end
    else if (r_vs==2'b01) begin
      r_cntx <= 8'd0;
    end
    else if (r_de[0]==1'b1) begin
      r_cntx <= (r_cntx>=63) ? r_cntx : r_cntx + 1;
    end
    else if (r_de==2'b10) begin
      r_cntx <= 8'd0;
    end
  end

  always @(negedge i_xrst or posedge i_clk) begin
    if (i_xrst==1'b0)
      r_valid <= 1'b0;
    else if (0<r_cntx && r_cntx<63) // NG
//    else if (r_cntx<63 && 0<r_cntx) // NG
//    else if (r_cntx>0 && r_cntx<63) // OK
//    else if ((0<r_cntx) && (r_cntx<63)) // NG
//    else if (1<=r_cntx && r_cntx<=62) // OK
//    else if (1<=r_cntx && r_cntx<63) // OK
//    else if (0<r_cntx && r_cntx<=62) // NG
      r_valid <= 1'b1;
    else
      r_valid <= 1'b0;
  end

  assign o_valid = r_valid;

endmodule

0 Kudos
1 Reply
YujiTanaka
Newbie
Newbie
522 Views
Registered: ‎09-06-2020

I check Vivado 2018.3, then this problem doesn't occur.

So we have to use 2018.3, not 2018.2.

Tags (1)
0 Kudos