package and procedure

Guest #6732844
Rate this post
• ▲ useful
▼ not useful
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!!
Attached files:

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.