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

Subversion Repositories wb_tk

[/] [wb_tk/] [trunk/] [technology_xilinx.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 tantos
--
2
--  Technology mapping library. XILINX edition.
3
--
4
--  (c) Copyright Andras Tantos <andras_tantos@yahoo.com> 2001/03/31
5
--  This code is distributed under the terms and conditions of the GNU General Public Lince.
6
--
7
 
8
library IEEE;
9
use IEEE.std_logic_1164.all;
10
use IEEE.STD_LOGIC_UNSIGNED.all;
11
--library xul;
12
 
13
package body technology is
14
        function to_std_logic_vector(ARG: INTEGER; SIZE: INTEGER) return STD_LOGIC_VECTOR is
15
                variable RetVal: std_logic_vector(size-1 downto 0) := (others => '0');
16
                variable L_Arg: integer;
17
        begin
18
--              return ul_utils.int_2_std_logic_vector(ARG,SIZE);
19
                L_Arg := ARG;
20
                if (L_Arg < 0) then L_Arg := -L_Arg; end if;
21
                for i in 0 to SIZE-1 loop
22
                        if (L_Arg mod 2) = 1 then
23
                                RetVal(i) := '1';
24
                        end if;
25
                        L_Arg := L_Arg/2;
26
                end loop;
27
                -- Compute two's complement if arg was negative
28
                if (ARG < 0) then
29
                        RetVal := not RetVal;
30
                        RetVal := RetVal+"1";
31
                end if;
32
                return RetVal;
33
        end;
34
 
35
        function to_integer(arg:std_logic_vector) return integer is
36
        begin
37
                return CONV_INTEGER(arg);
38
        end;
39
 
40
--      function add_one(inp : std_logic_vector) return std_logic_vector is
41
--      begin
42
--              return inp+"1";
43
--      end;
44
--
45
--      function sub_one(inp : std_logic_vector) return std_logic_vector is
46
--              variable minus_one: std_logic_vector(inp'RANGE) := (others => '1');
47
--      begin
48
--              return inp+minus_one;
49
--      end;
50
 
51
        function is_zero(inp : std_logic_vector) return boolean is
52
                variable zero: std_logic_vector(inp'RANGE) := (others => '0');
53
        begin
54
                return (inp = zero);
55
        end;
56
 
57
        function sl(l: std_logic_vector; r: integer) return std_logic_vector is
58
                variable RetVal : std_logic_vector (l'length-1 downto 0) ;
59
                variable LL: std_logic_vector(l'length-1 downto 0) := l;
60
        begin
61
                RetVal := (others => '0');
62
                if (ABS(r) < l'length) then
63
                        if (r >= 0) then
64
                                RetVal(l'length-1 downto r) :=  ll(l'length-1-r downto 0);
65
                        else -- (r < 0)
66
                                RetVal(l'length-1+r downto 0) := ll(l'length-1 downto -r);
67
                        end if ;
68
                end if;
69
                return RetVal ;
70
        end sl ;
71
 
72
        function sr(l: std_logic_vector; r: integer) return std_logic_vector is
73
        begin
74
                return sl(l,-r);
75
        end sr;
76
 
77
        function max2(a : integer; b: integer) return integer is
78
        begin
79
                if (a > b) then return a; end if;
80
                return b;
81
        end max2;
82
 
83
        function min2(a : integer; b: integer) return integer is
84
        begin
85
                if (a < b) then return a; end if;
86
                return b;
87
        end min2;
88
 
89
        function log2(inp : integer) return integer is
90
        begin
91
                if (inp < 1) then return 0; end if;
92
                if (inp < 2) then return 0; end if;
93
                if (inp < 4) then return 1; end if;
94
                if (inp < 8) then return 2; end if;
95
                if (inp < 16) then return 3; end if;
96
                if (inp < 32) then return 4; end if;
97
                if (inp < 64) then return 5; end if;
98
                if (inp < 128) then return 6; end if;
99
                if (inp < 256) then return 7; end if;
100
                if (inp < 512) then return 8; end if;
101
                if (inp < 1024) then return 9; end if;
102
                if (inp < 2048) then return 10; end if;
103
                if (inp < 4096) then return 11; end if;
104
                if (inp < 8192) then return 12; end if;
105
                if (inp < 16384) then return 13; end if;
106
                if (inp < 32768) then return 14; end if;
107
                if (inp < 65536) then return 15; end if;
108
                return 16;
109
        end log2;
110
 
111
        function bus_resize2adr_bits(in_bus : integer; out_bus: integer) return integer is
112
        begin
113
                if (in_bus = out_bus) then return 0; end if;
114
                if (in_bus < out_bus) then return -log2(out_bus/in_bus); end if;
115
                if (in_bus > out_bus) then return log2(in_bus/out_bus); end if;
116
        end bus_resize2adr_bits;
117
 
118
        function size2bits(inp : integer) return integer is
119
        begin
120
                if (inp <= 1) then return 1; end if;
121
                if (inp <= 2) then return 1; end if;
122
                if (inp <= 4) then return 2; end if;
123
                if (inp <= 8) then return 3; end if;
124
                if (inp <= 16) then return 4; end if;
125
                if (inp <= 32) then return 5; end if;
126
                if (inp <= 64) then return 6; end if;
127
                if (inp <= 128) then return 7; end if;
128
                if (inp <= 256) then return 8; end if;
129
                if (inp <= 512) then return 9; end if;
130
                if (inp <= 1024) then return 10; end if;
131
                if (inp <= 2048) then return 11; end if;
132
                if (inp <= 4096) then return 12; end if;
133
                if (inp <= 8192) then return 13; end if;
134
                if (inp <= 16384) then return 14; end if;
135
                if (inp <= 32768) then return 15; end if;
136
                if (inp <= 65536) then return 16; end if;
137
                return 17;
138
        end size2bits;
139
 
140
        function equ(a : std_logic_vector; b : integer) return boolean is
141
                variable b_s : std_logic_vector(a'RANGE);
142
        begin
143
                b_s := to_std_logic_vector(b,a'HIGH+1);
144
                return (a = b_s);
145
        end equ;
146
 
147
end technology;
148
 
149
library IEEE;
150
use IEEE.std_logic_1164.all;
151
 
152
library unisim;
153
use unisim.vcomponents.all;
154
 
155
architecture xilinx of d_ff is
156
--      signal clrn,pren: std_logic;
157
begin
158
--      clrn <= not clr;
159
--      pren <= not pre;
160
        ff: FDCPE port map (
161
                D => d,
162
                C => clk,
163
                CE => ena,
164
                CLR => clr,
165
                PRE => pre,
166
                Q => q
167
        );
168
end xilinx;
169
 
170
LIBRARY ieee;
171
USE ieee.std_logic_1164.ALL;
172
use IEEE.STD_LOGIC_UNSIGNED.all;
173
library wb_tk;
174
use wb_tk.technology.all;
175
 
176
architecture xilinx of fifo is
177
        -- One additional bit is added to detect over and under-flow
178
        signal w_adr : std_logic_vector(adr_width downto 0);  -- internal write address
179
        signal r_adr : std_logic_vector(adr_width downto 0);  -- internal read address
180
        signal dont_care : std_logic_vector(dat_width downto 0) := (others => '-');
181
        signal w_ack, r_ack: std_logic;
182
begin
183
        dont_care <= (others => '-');
184
 
185
        read_proc : process (r_clk_i, reset)
186
        begin
187
                if reset = '1' then
188
                        r_adr     <= (others => '0');
189
                elsif r_clk_i'event and r_clk_i = '1' then
190
                        if (r_stb_i = '1' and r_we_i = '0' and r_ack = '1') then
191
                                r_adr <= r_adr+"1";
192
                        end if;
193
                end if;
194
        end process read_proc;
195
 
196
        write_proc : process (w_clk_i, reset)
197
        begin
198
                if reset = '1' then
199
                        w_adr     <= (others => '0');
200
                elsif w_clk_i'event and w_clk_i = '1' then
201
                        if (w_stb_i = '1' and w_we_i = '1' and w_ack = '1') then
202
                                w_adr <= w_adr+"1";
203
                        end if;
204
                end if;
205
        end process write_proc;
206
 
207
        empty_o <= '1' when r_adr = w_adr else '0';
208
        full_o  <= '1' when (w_adr(adr_width-1 downto 0) = r_adr(adr_width-1 downto 0)) and (w_adr(adr_width) /= r_adr(adr_width)) else '0';
209
        used_o <= w_adr - r_adr;
210
 
211
        mem_core: dpmem
212
        generic map (default_out,default_content,adr_width,dat_width,async_read)
213
        port map (
214
                a_clk_i   => r_clk_i,
215
                a_stb_i   => r_stb_i,
216
                a_we_i    => r_we_i,
217
                a_adr_i   => r_adr(adr_width-1 downto 0),
218
                a_dat_i   => dont_care,
219
                a_dat_o   => r_dat_o,
220
                a_ack_o   => r_ack,
221
 
222
                b_clk_i   => w_clk_i,
223
                b_stb_i   => w_stb_i,
224
                b_we_i    => w_we_i,
225
                b_adr_i   => w_adr(adr_width-1 downto 0),
226
                b_dat_i   => w_dat_i,
227
--              b_dat_o
228
                b_ack_o   => w_ack
229
        );
230
end xilinx;
231
 
232
library ieee;
233
use ieee.std_logic_1164.all;
234
library wb_tk;
235
use wb_tk.technology.all;
236
 
237
architecture xilinx of spmem is
238
        signal w_ack, r_ack: std_logic;
239
        signal dont_care : std_logic_vector(dat_width downto 0) := (others => '-');
240
begin
241
        dont_care <= (others => '-');
242
 
243
        mem_core: dpmem generic map (default_out,default_content,adr_width,dat_width,async_read)
244
        port map (
245
                a_clk_i   => clk_i,
246
                a_stb_i   => stb_i,
247
                a_we_i    => we_i,
248
                a_adr_i   => adr_i,
249
                a_dat_i   => dont_care,
250
                a_dat_o   => dat_o,
251
                a_ack_o   => r_ack,
252
 
253
                b_clk_i   => clk_i,
254
                b_stb_i   => stb_i,
255
                b_we_i    => we_i,
256
                b_adr_i   => adr_i,
257
                b_dat_i   => dat_i,
258
--              b_dat_o
259
                b_ack_o   => w_ack
260
        );
261
        ack_o <= ('0' and not stb_i) or (r_ack and (stb_i and not we_i)) or (w_ack and (stb_i and we_i));
262
end xilinx;

powered by: WebSVN 2.1.0

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