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

Subversion Repositories p9813_rgb_led_string_driver

[/] [p9813_rgb_led_string_driver/] [trunk/] [rtl/] [VHDL/] [flancter_pack.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jclaytons
--------------------------------------------------------------------------
2
-- Package of flancter components
3
--
4
--
5
 
6
library ieee;
7
use ieee.std_logic_1164.all;
8
use ieee.numeric_std.all;
9
 
10
package flancter_pack is
11
 
12
-- Component declarations not provided any more.
13
-- With VHDL '93 and newer, component declarations are allowed,
14
-- but not required.
15
--
16
-- If you please, try direct instantiation instead, for example:
17
--
18
--   instance_name : entity work.entity_name(beh)
19
--
20
 
21
end flancter_pack;
22
 
23
package body flancter_pack is
24
end flancter_pack;
25
 
26
-------------------------------------------------------------------------------
27
-- Basic Flancter Component
28
-------------------------------------------------------------------------------
29
--
30
-- Author: John Clayton
31
-- Update: May   1, 2013 Copied code from Rob Weinstein's MEMEC flancter
32
--                       app note.  Formatted it, and wrote a short
33
--                       description.
34
--
35
-- Description
36
-------------------------------------------------------------------------------
37
-- This is a simple set/reset flag that crosses clock domains in a safe
38
-- manner.
39
-- For further details, see Rob Weinstein's MEMEC app. note
40
-- (Which probably was a Xilinx app. note at one time...)
41
--
42
--
43
 
44
 
45
library IEEE;
46
use IEEE.STD_LOGIC_1164.ALL;
47
 
48
  entity flancter is
49
  port (
50
    async_rst_n : in  std_logic;
51
    set_clk     : in  std_logic;
52
    set_ce      : in  std_logic;
53
    reset_clk   : in  std_logic;
54
    reset_ce    : in  std_logic;
55
    flag_s_o    : out std_logic;
56
    flag_r_o    : out std_logic;
57
    flag_o      : out std_logic
58
    );
59
  end flancter;
60
 
61
architecture beh of flancter is
62
 
63
-- Signals
64
signal setflop : std_logic;
65
signal rstflop : std_logic;
66
signal flag    : std_logic;
67
 
68
begin
69
 
70
  --The Set flip-flop
71
  set_proc: process(async_rst_n, set_clk)
72
  begin
73
    if async_rst_n='0' then
74
      setflop <= '0';
75
      flag_s_o <= '0';
76
    elsif rising_edge(set_clk) then
77
      if set_ce = '1' then
78
        -- Flops get opposite logic levels.
79
        setflop <= not rstflop;
80
      end if;
81
      flag_s_o <= flag;
82
    end if;
83
  end process;
84
 
85
  --The Reset flip-flop
86
  reset_proc: process(async_rst_n, reset_clk)
87
  begin
88
    if async_rst_n='0' then
89
      rstflop <= '0';
90
      flag_r_o <= '0';
91
    elsif rising_edge(reset_clk) then
92
      if reset_ce = '1' then
93
        -- Flops get the same logic levels.
94
        rstflop <= setflop;
95
      end if;
96
      flag_r_o <= flag;
97
    end if;
98
  end process;
99
 
100
flag <= setflop xor rstflop;
101
flag_o <= flag;
102
 
103
end beh;
104
 
105
 
106
-------------------------------------------------------------------------------
107
-- Flancter Component - "Fast Flag" version
108
-------------------------------------------------------------------------------
109
--
110
-- Author: John Clayton
111
-- Update: May   1, 2013 Copied code from flancter, updated it to set and
112
--                       clear flags as early as possible!  The original
113
--                       has a one clock cycle delay before the synchronized
114
--                       flags reflect the state of the raw flag.
115
--
116
-- Description
117
-------------------------------------------------------------------------------
118
-- This is a simple set/reset flag that crosses clock domains in a safe
119
-- manner.
120
-- For further details, see Rob Weinstein's MEMEC app. note
121
-- (Which probably was a Xilinx app. note at one time...)
122
--
123
--
124
 
125
library IEEE;
126
use IEEE.STD_LOGIC_1164.ALL;
127
 
128
  entity flancter_fastflag is
129
  port (
130
    async_rst_n : in  std_logic;
131
    set_clk     : in  std_logic;
132
    set_ce      : in  std_logic;
133
    reset_clk   : in  std_logic;
134
    reset_ce    : in  std_logic;
135
    flag_s_o    : out std_logic;
136
    flag_r_o    : out std_logic;
137
    flag_o      : out std_logic
138
    );
139
  end flancter_fastflag;
140
 
141
architecture beh of flancter_fastflag is
142
 
143
-- Signals
144
signal setflop : std_logic;
145
signal rstflop : std_logic;
146
signal flag    : std_logic;
147
 
148
begin
149
 
150
  --The Set flip-flop
151
  set_proc: process(async_rst_n, set_clk)
152
  begin
153
    if async_rst_n='0' then
154
      setflop <= '0';
155
      flag_s_o <= '0';
156
    elsif rising_edge(set_clk) then
157
      flag_s_o <= flag;
158
      if set_ce = '1' then
159
        -- Flops get opposite logic levels.
160
        setflop <= not rstflop;
161
        flag_s_o <= '1'; -- Fast action!
162
      end if;
163
    end if;
164
  end process;
165
 
166
  --The Reset flip-flop
167
  reset_proc: process(async_rst_n, reset_clk)
168
  begin
169
    if async_rst_n='0' then
170
      rstflop <= '0';
171
      flag_r_o <= '0';
172
    elsif rising_edge(reset_clk) then
173
      flag_r_o <= flag;
174
      if reset_ce = '1' then
175
        -- Flops get the same logic levels.
176
        rstflop <= setflop;
177
        flag_r_o <= '0'; -- Fast action!
178
      end if;
179
    end if;
180
  end process;
181
 
182
flag <= setflop xor rstflop;
183
flag_o <= flag;
184
 
185
end beh;
186
 
187
 
188
-------------------------------------------------------------------------------
189
-- Flancter Component with rising edge detection on set/reset inputs
190
-------------------------------------------------------------------------------
191
--
192
-- Author: John Clayton
193
-- Update: May   2, 2013 Copied code from basic flancter, and added rising
194
--                       edge detectors.
195
--
196
-- Description
197
-------------------------------------------------------------------------------
198
-- This is a simple set/reset flag that crosses clock domains in a safe
199
-- manner.
200
-- For further details, see Rob Weinstein's MEMEC app. note
201
-- (Which probably was a Xilinx app. note at one time...)
202
--
203
--
204
 
205
library IEEE;
206
use IEEE.STD_LOGIC_1164.ALL;
207
 
208
  entity flancter_rising is
209
  port (
210
    async_rst_n : in  std_logic;
211
    set_clk     : in  std_logic;
212
    set         : in  std_logic;
213
    reset_clk   : in  std_logic;
214
    reset       : in  std_logic;
215
    flag_s_o    : out std_logic;
216
    flag_r_o    : out std_logic;
217
    flag_o      : out std_logic
218
    );
219
  end flancter_rising;
220
 
221
architecture beh of flancter_rising is
222
 
223
-- Signals
224
signal setflop   : std_logic;
225
signal rstflop   : std_logic;
226
signal flag      : std_logic;
227
signal set_ce    : std_logic;
228
signal reset_ce  : std_logic;
229
signal set_r1    : std_logic;
230
signal reset_r1  : std_logic;
231
 
232
begin
233
 
234
  --The Set flip-flop
235
  set_proc: process(async_rst_n, set_clk)
236
  begin
237
    if async_rst_n='0' then
238
      setflop <= '0';
239
      flag_s_o <= '0';
240
      set_r1 <= '1';
241
    elsif rising_edge(set_clk) then
242
      set_r1 <= set;
243
      if set_ce = '1' then
244
        -- Flops get opposite logic levels.
245
        setflop <= not rstflop;
246
      end if;
247
      flag_s_o <= flag;
248
    end if;
249
  end process;
250
  set_ce <= '1' when set='1' and set_r1='0' else '0';
251
 
252
  --The Reset flip-flop
253
  reset_proc: process(async_rst_n, reset_clk)
254
  begin
255
    if async_rst_n='0' then
256
      rstflop <= '0';
257
      flag_r_o <= '0';
258
      reset_r1 <= '0';
259
    elsif rising_edge(reset_clk) then
260
      reset_r1 <= reset;
261
      if reset_ce = '1' then
262
        -- Flops get the same logic levels.
263
        rstflop <= setflop;
264
      end if;
265
      flag_r_o <= flag;
266
    end if;
267
  end process;
268
  reset_ce <= '1' when reset='1' and reset_r1='0' else '0';
269
 
270
flag <= setflop xor rstflop;
271
flag_o <= flag;
272
 
273
end beh;
274
 
275
 
276
-------------------------------------------------------------------------------
277
-- Flancter Component with rising edge detection on set/reset inputs,
278
-- and outputs which go high for a single clock pulse.
279
-------------------------------------------------------------------------------
280
--
281
-- Author: John Clayton
282
-- Update: May   2, 2013 Copied code from flancter_rising, and added rising
283
--                       edge detectors to the outputs, changing them from
284
--                       "flags" to "pulses".
285
--
286
-- Description
287
-------------------------------------------------------------------------------
288
-- This is a simple set/reset flag that crosses clock domains in a safe
289
-- manner.
290
-- For further details, see Rob Weinstein's MEMEC app. note
291
-- (Which probably was a Xilinx app. note at one time...)
292
--
293
--
294
 
295
library IEEE;
296
use IEEE.STD_LOGIC_1164.ALL;
297
 
298
  entity flancter_rising_pulseout is
299
  port (
300
    async_rst_n : in  std_logic;
301
    set_clk     : in  std_logic;
302
    set         : in  std_logic;
303
    reset_clk   : in  std_logic;
304
    reset       : in  std_logic;
305
    pulse_s_o   : out std_logic;
306
    pulse_r_o   : out std_logic;
307
    flag_o      : out std_logic
308
    );
309
  end flancter_rising_pulseout;
310
 
311
architecture beh of flancter_rising_pulseout is
312
 
313
-- Signals
314
signal setflop    : std_logic;
315
signal rstflop    : std_logic;
316
signal flag       : std_logic;
317
signal set_ce     : std_logic;
318
signal reset_ce   : std_logic;
319
signal set_r1     : std_logic;
320
signal reset_r1   : std_logic;
321
signal pulse_s_r1 : std_logic;
322
signal pulse_s_r2 : std_logic;
323
signal pulse_r_r1 : std_logic;
324
signal pulse_r_r2 : std_logic;
325
 
326
begin
327
 
328
  --The Set flip-flop
329
  set_proc: process(async_rst_n, set_clk)
330
  begin
331
    if async_rst_n='0' then
332
      setflop <= '0';
333
      pulse_s_r1 <= '0';
334
      pulse_s_r2 <= '0';
335
      set_r1 <= '1';
336
    elsif rising_edge(set_clk) then
337
      set_r1 <= set;
338
      if set_ce = '1' then
339
        -- Flops get opposite logic levels.
340
        setflop <= not rstflop;
341
      end if;
342
      pulse_s_r1 <= flag;
343
      pulse_s_r2 <= pulse_s_r1;
344
    end if;
345
  end process;
346
  set_ce <= '1' when set='1' and set_r1='0' else '0';
347
  pulse_s_o <= '1' when pulse_s_r1='1' and pulse_s_r2='0' else '0';
348
 
349
  --The Reset flip-flop
350
  reset_proc: process(async_rst_n, reset_clk)
351
  begin
352
    if async_rst_n='0' then
353
      rstflop <= '0';
354
      pulse_r_r1 <= '0';
355
      pulse_r_r2 <= '0';
356
      reset_r1 <= '0';
357
    elsif rising_edge(reset_clk) then
358
      reset_r1 <= reset;
359
      if reset_ce = '1' then
360
        -- Flops get the same logic levels.
361
        rstflop <= setflop;
362
      end if;
363
      pulse_r_r1 <= flag;
364
      pulse_r_r2 <= pulse_r_r1;
365
    end if;
366
  end process;
367
  reset_ce <= '1' when reset='1' and reset_r1='0' else '0';
368
  pulse_r_o <= '1' when pulse_r_r1='1' and pulse_r_r2='0' else '0';
369
 
370
flag <= setflop xor rstflop;
371
flag_o <= flag;
372
 
373
end beh;
374
 
375
 

powered by: WebSVN 2.1.0

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