OpenCores
URL https://opencores.org/ocsvn/gecko3/gecko3/trunk

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-ip/] [core/] [GECKO3COM_functions.vhd] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 nussgipfel
--      Package File Template
2
--
3
--      Purpose: This package defines supplemental types, subtypes, 
4
--               constants, and functions 
5
 
6
 
7
library IEEE;
8
use IEEE.STD_LOGIC_1164.all;
9
 
10
 
11
library work;
12
use work.USB_TMC_IP_Defs.all;
13
use work.USB_TMC_cmp.all;
14
 
15
 
16
package USB_TMC_func is
17
 
18
 
19
--  type <new_type> is
20
--    record
21
--        <type_name>        : std_logic_vector( 7 downto 0);
22
--        <type_name>        : std_logic;
23
--    end record;
24
--
25
---- Declare constants
26
--
27
--  constant <constant_name>            : time := <time_unit> ns;
28
--  constant <constant_name>            : integer := <value>;
29
-- 
30
---- Declare functions and procedure
31
--
32
--  function <function_name>  (signal <signal_name> : in <type_declaration>) return <type_declaration>;
33
--  procedure <procedure_name>  (<type_declaration> <constant_name>     : in <type_declaration>);
34
 
35
procedure rst_header_Reg  (signal reg : out tHeaderReg);
36
 
37
procedure wr_header_Reg_element (variable bl : in integer;
38
                                 signal data : in std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
39
                                 signal reg : out tHeaderReg);
40
 
41
procedure rd_header_Reg_element (variable bl : in integer;
42
                                 signal reg : in tHeaderReg;
43
                                 signal data : out std_logic_vector(SIZE_DBUS_GPIF-1 downto 0));
44
 
45
 
46
end USB_TMC_func;
47
 
48
 
49
package body USB_TMC_func is
50
--
51
---- Example 1
52
--  function <function_name>  (signal <signal_name> : in <type_declaration>  ) return <type_declaration> is
53
--    variable <variable_name>     : <type_declaration>;
54
--  begin
55
--    <variable_name> := <signal_name> xor <signal_name>;
56
--    return <variable_name>; 
57
--  end <function_name>;
58
--
59
--
60
---- Example 2
61
--  function <function_name>  (signal <signal_name> : in <type_declaration>;
62
--                         signal <signal_name>   : in <type_declaration>  ) return <type_declaration> is
63
--  begin
64
--    if (<signal_name> = '1') then
65
--      return <signal_name>;
66
--    else
67
--      return 'Z';
68
--    end if;
69
--  end <function_name>;
70
--
71
---- Procedure Example
72
--  procedure <procedure_name>  (<type_declaration> <constant_name>  : in <type_declaration>) is
73
--    
74
--  begin
75
--    
76
--  end <procedure_name>;
77
 
78
procedure rst_header_Reg  (signal reg : out tHeaderReg) is
79
 
80
  begin
81
         reg.MsgID   <= (others => '0');
82
         reg.bTag    <= (others => '0');
83
         reg.bTagInv <= (others => '0');
84
         reg.res1    <= (others => '0');
85
         reg.TfSize  <= (others => '0');
86
         reg.bmTfAtt <= (others => '0');
87
    reg.GPByte1 <= (others => '0');
88
         reg.GPByte2 <= (others => '0');
89
         reg.GPByte3 <= (others => '0');
90
 
91
end rst_header_Reg;
92
 
93
procedure wr_header_Reg_element (variable bl : in integer;
94
                                 signal data : in std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
95
                                 signal reg : out tHeaderReg) is
96
 
97
begin
98
        case bl is
99
 
100
          when 0 =>
101
                 reg.MsgID   <= data(BYTE-1 downto 0);
102
                 reg.bTag    <= data((2*BYTE)-1 downto BYTE);
103
          when 1 =>
104
                 reg.bTagInv <= data(BYTE-1 downto 0);
105
                 reg.res1    <= data((2*BYTE)-1 downto BYTE);
106
          when 2 =>
107
                 reg.TfSize((2*BYTE)-1 downto 0)      <= data;
108
          when 3 =>
109
                 reg.TfSize((4*BYTE)-1 downto 2*BYTE) <= data;
110
          when 4 =>
111
                 reg.bmTfAtt <= data(BYTE-1 downto 0);
112
                 reg.GPByte1 <= data((2*BYTE)-1 downto BYTE);
113
          when 5 =>
114
                 reg.GPByte2 <= data(BYTE-1 downto 0);
115
                 reg.GPByte3 <= data((2*BYTE)-1 downto BYTE);
116
          when others =>
117
   end case;
118
end wr_header_Reg_element;
119
 
120
 
121
 
122
procedure rd_header_Reg_element (variable bl : in integer;
123
                                 signal reg : in tHeaderReg;
124
                                 signal data : out std_logic_vector(SIZE_DBUS_GPIF-1 downto 0)) is
125
 
126
   begin
127
 
128
        case bl is
129
          when 0 =>
130
                 data <= reg.MsgID & reg.bTag;
131
          when 1 =>
132
                 data <= reg.bTagInv & reg.res1;
133
          when 2 =>
134
                 data <= reg.TfSize((2*BYTE)-1 downto 0);
135
          when 3 =>
136
                 data <= reg.TfSize((4*BYTE)-1 downto 2*BYTE);
137
          when 4 =>
138
                 data <= reg.bmTfAtt & reg.GPByte1;
139
          when 5 =>
140
                 data <= reg.GPByte2 & reg.GPByte3;
141
          when others =>
142
            data <= (others => 'X');
143
        end case;
144
 
145
end rd_header_Reg_element;
146
 
147
 
148
end USB_TMC_func;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.