Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
15388 Discussions

pi controller i verilog

Altera_Forum
Honored Contributor II
842 Views

i used matlab hdl coder to design the pi controller. but when I use it an error occurs  

it shows $bitstoreal is not supported 

2 real value is not supported. 

any help  

thanku 

 

 

// ------------------------------------------------------------- 

//  

// File Name: hdlsrc\untitled\PI_Controller.v 

// Created: 2018-02-27 12:02:47 

//  

// Generated by MATLAB 9.0 and HDL Coder 3.8 

//  

// ------------------------------------------------------------- 

 

 

 

 

// ------------------------------------------------------------- 

//  

// Module: PI_Controller 

// Source Path: untitled/PI Controller 

// Hierarchy Level: 1 

//  

// ------------------------------------------------------------- 

 

 

`timescale 1 ns / 1 ns 

 

 

module PI_Controller 

clk, 

reset, 

enb, 

u, 

); 

 

 

 

 

input clk; 

input reset; 

input enb; 

input [63:0] u; // double 

output [63:0] y; // double 

 

 

 

 

real u_double; // double 

real Proportional_Gain_out1; // double 

real Integral_Gain_out1; // double 

real Integrator_x_reg; // double 

real Integrator_u_add; // double 

real Sum_out1; // double 

 

 

 

 

always @* u_double = $bitstoreal(u); 

 

 

always @* Proportional_Gain_out1 = 0.0349 * u_double; 

 

 

 

 

 

 

always @* Integral_Gain_out1 = 2.0 * u_double; 

 

 

 

 

 

 

always @* Integrator_u_add = Integrator_x_reg + Integral_Gain_out1; 

 

 

 

 

 

 

always @(posedge clk or posedge reset) 

begin : Integrator_reg_process 

if (reset == 1'b1) begin 

Integrator_x_reg <= 0.0; 

end 

else begin 

if (enb) begin 

Integrator_x_reg <= Integrator_u_add; 

end 

end 

end 

 

 

 

 

 

 

always @* Sum_out1 = Proportional_Gain_out1 + Integrator_x_reg; 

 

 

 

 

 

 

assign y = $realtobits(Sum_out1); 

 

 

endmodule // PI_Controller
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
115 Views

The model below is not synthesizable.  

 

$real is not supported in synthesis.  

 

Additionally, most of the logic is not synchronous. Perhaps the HDL compiler from MathWorks is only generating a simulation model, not a synthesizable one.  

 

-James 

 

 

 

--- Quote Start ---  

i used matlab hdl coder to design the pi controller. but when I use it an error occurs  

it shows $bitstoreal is not supported 

2 real value is not supported. 

any help  

thanku 

 

 

// ------------------------------------------------------------- 

//  

// File Name: hdlsrc\untitled\PI_Controller.v 

// Created: 2018-02-27 12:02:47 

//  

// Generated by MATLAB 9.0 and HDL Coder 3.8 

//  

// ------------------------------------------------------------- 

 

 

 

 

// ------------------------------------------------------------- 

//  

// Module: PI_Controller 

// Source Path: untitled/PI Controller 

// Hierarchy Level: 1 

//  

// ------------------------------------------------------------- 

 

 

`timescale 1 ns / 1 ns 

 

 

module PI_Controller 

clk, 

reset, 

enb, 

u, 

); 

 

 

 

 

input clk; 

input reset; 

input enb; 

input [63:0] u; // double 

output [63:0] y; // double 

 

 

 

 

real u_double; // double 

real Proportional_Gain_out1; // double 

real Integral_Gain_out1; // double 

real Integrator_x_reg; // double 

real Integrator_u_add; // double 

real Sum_out1; // double 

 

 

 

 

always @* u_double = $bitstoreal(u); 

 

 

always @* Proportional_Gain_out1 = 0.0349 * u_double; 

 

 

 

 

 

 

always @* Integral_Gain_out1 = 2.0 * u_double; 

 

 

 

 

 

 

always @* Integrator_u_add = Integrator_x_reg + Integral_Gain_out1; 

 

 

 

 

 

 

always @(posedge clk or posedge reset) 

begin : Integrator_reg_process 

if (reset == 1'b1) begin 

Integrator_x_reg <= 0.0; 

end 

else begin 

if (enb) begin 

Integrator_x_reg <= Integrator_u_add; 

end 

end 

end 

 

 

 

 

 

 

always @* Sum_out1 = Proportional_Gain_out1 + Integrator_x_reg; 

 

 

 

 

 

 

assign y = $realtobits(Sum_out1); 

 

 

endmodule // PI_Controller 

--- Quote End ---  

Reply