Problem in converting for loop in matlab into vhdl code

1 回表示 (過去 30 日間)
Amanpreet Singh
Amanpreet Singh 2014 年 10 月 28 日
コメント済み: Amanpreet Singh 2014 年 10 月 29 日
I am trying to implement sigmoid function by converting it from matlab into vhdl. Since , sigmoid function is not supported by hdl coder, I am using following code:
function [ g ] = sigmoid_exp( z )
y = 1;
for I = 1:z
y = y * 2.718;
end
y = 1 / y;
g = 1.0 / (1.0 + y);
end
But I am getting this error: Found an unsupported unbounded loop structure. This loop may be user written or automatically generated due to the use of specific vector expressions or functions. For more information on unsupported loop structures, please refer to the documentation.
I know it can be directly implemented in vhdl but I want to know about this error.
Thankyou

採用された回答

Abhiram Bhanuprakash
Abhiram Bhanuprakash 2014 年 10 月 28 日
編集済み: Abhiram Bhanuprakash 2014 年 10 月 28 日
Hi Amanpreet,
This error is because of the following:
1. In code generation, unbounded 'for' loops are not supported.
2. During compile time, HDL Coder does not know the value of z as it depends on the value of the input argument. Since
I = 1:z
is used in the 'for' loop, HDL Coder does not know what the upper bound is.
The workaround is to provide a hard coded value like, say,
I = 1:3
In fact, if you create a variable, say k, and assign it a value of 3 in the function 'sigmoid_exp' and then enter
I = 1:k
this will not result in the error and will generate code successfully.
Hope this helps,
Cheers!
Abhiram.
  1 件のコメント
Amanpreet Singh
Amanpreet Singh 2014 年 10 月 29 日
Hi Abhiram Thanx for you reply. I got the point. But I am sending the value of z in the testbench file, so as to convert it into vhdl code. Do I need to convert the code by sending some value in this code. Then later make modifications in the converted vhdl code? Regards Amanpreet Singh

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHDL Coder についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by