cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Newbie
Newbie
698 Views
Registered: ‎05-24-2018

NAN output from system generator 2018

I'm trying to co-simulate the verilog mppt with photovoltaic system in simulink using system generator 2018

but i'm getting NAN output anyway.

here's my code:

 

 

module m2(
input [23:0] v,   
input [23:0] i,
output reg [23:0] d,
input clk,
input ce,
input enable
    );
    
    localparam dinit   =24'b000000000000_100000000000;
    localparam dmax =24'b000000000000_100001010001;
    localparam dmin  =24'b000000000000_011010111000;
    localparam deltad=24'b000000000000_000000000001 ;
    
wire [47:0] p;
reg [47:0] pold;
reg [23:0] vold;
reg [23:0] iold;
reg [23:0] dold;
    assign p=v*i;
   // assign v=v*2**12;
   // assign d=d/(2**12);
always@(posedge clk)
begin
    if (v!=0 & i!=0 & enable!=0 & d<dmax & d>dmin)
     begin
        if(p<pold && v<vold)
            d<=d-deltad;
        if(p<pold && v>vold)
            d<=d+deltad;
        if(p>pold && v<vold)
            d<=d+deltad;
        if(p>pold && v>vold)
            d<=d-deltad;
    end
     
    if (enable==1)
     begin
        vold<=v;
        iold<=i;
        pold<=p;
        dold<=d;
      end
      else
      begin
        vold<=0;
        pold<=0;
        iold<=0;
        dold<=dinit;
     end
 end
             
endmodule

 

 

 

 

tnx

0 Kudos
1 Reply
Moderator
Moderator
671 Views
Registered: ‎11-09-2015

Hi @mkhezeli,

 

You output d is not initialized. So you are doing computation something which does not have a value.

 

It might be the issue.


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos