I have made a small example of the package and procedure but the error shows an error. Unit is not declared. I tried but can't fix it.
See below (also attached), maybe just the last line misses some keywords. Pleas contribute full error message/log.
1 | library ieee; |
2 | use ieee.std_logic_1164.all; |
3 | use ieee.numeric_std.all; |
4 | |
5 | package package_Thong_so is |
6 | --- Thong so mach luc
|
7 | constant one_div_Lf : signed(12-1 downto 0) := to_signed(200, 12); --Lf = 5e-3 |
8 | constant one_div_Cf : signed(18-1 downto 0) := to_signed(66667, 18); --Cf = 15e-6 |
9 | constant Vdc : signed(11-1 downto 0) := to_signed(180, 11); --Vdc_1cell = 180 |
10 | constant N : signed(5-1 downto 0) := to_signed(1, 5); |
11 | --constant Ts: signed(22-1 downto 0) := to_signed(21,22);
|
12 | subtype unit is signed(22-1 downto 0); |
13 | procedure Tinh_toan(Ts : in unit; |
14 | Ts_div_Cf, Ts_div_Lf, W_Ts, Vdc_Ts_3Lf : out unit); |
15 | end package; |
16 | -- tinh toan phan tu ma tran
|
17 | |
18 | package body packgage_Thong_so is |
19 | procedure Tinh_toan(Ts : in unit; |
20 | Ts_div_Cf, Ts_div_Lf, W_Ts, Vdc_Ts_3Lf : out unit) is |
21 | variable temp_Ts_div_Cf : signed(40-1 downto 0); |
22 | variable temp_Ts_div_Lf : signed(34-1 downto 0); |
23 | variable temp_Vdc_Ts_3Lf : signed(61-1 downto 0); |
24 | begin
|
25 | temp_Ts_div_Cf := Ts * one_div_Cf; |
26 | Ts_div_Cf := temp_Ts_div_Cf(temp_Ts_div_Cf'high) & temp_Ts_div_Cf(39-1 downto 18); |
27 | temp_Ts_div_Lf := Ts * one_div_Lf; |
28 | Ts_div_Lf := temp_Ts_div_Lf(temp_Ts_div_Lf'high) & temp_Ts_div_Lf(33-1 downto 12); |
29 | w_Ts := to_signed(6588, 22); |
30 | temp_Vdc_Ts_3Lf := Ts * Vdc * one_div_Cf * to_signed(171, 10); |
31 | Vdc_Ts_3Lf := temp_Vdc_Ts_3Lf(temp_Vdc_Ts_3Lf'high) & temp_Vdc_Ts_3Lf(60-1 downto 39); |
32 | end procedure; |
33 | end; -- try end package body here!! |
See for syntax on package, package body, and procedure : https://www.ics.uci.edu/~jmoorkan/vhdlref/procedur.html
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
Log in with Google account
No account? Register here.