| 1 |
-- Copyright (c) 2017 Nuand LLC |
| 2 |
-- |
| 3 |
-- Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 |
-- of this software and associated documentation files (the "Software"), to deal |
| 5 |
-- in the Software without restriction, including without limitation the rights |
| 6 |
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 |
-- copies of the Software, and to permit persons to whom the Software is |
| 8 |
-- furnished to do so, subject to the following conditions: |
| 9 |
-- |
| 10 |
-- The above copyright notice and this permission notice shall be included in |
| 11 |
-- all copies or substantial portions of the Software. |
| 12 |
-- |
| 13 |
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 |
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 |
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 |
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 |
-- THE SOFTWARE. |
| 20 |
|
| 21 |
-- set_clear_ff: provides a simple clocked set/clear flipflop |
| 22 |
|
| 23 |
library ieee; |
| 24 |
use ieee.std_logic_1164.all; |
| 25 |
use ieee.numeric_std.all; |
| 26 |
|
| 27 |
entity set_clear_ff is |
| 28 |
port ( |
| 29 |
clock : in std_logic; |
| 30 |
reset : in std_logic; |
| 31 |
set : in std_logic; |
| 32 |
clear : in std_logic; |
| 33 |
q : out std_logic |
| 34 |
); |
| 35 |
end entity; -- set_clear_ff |
| 36 |
|
| 37 |
architecture arch of set_clear_ff is |
| 38 |
signal q_r : std_logic; |
| 39 |
signal set_r : std_logic; |
| 40 |
signal clr_r : std_logic; |
| 41 |
begin |
| 42 |
process (reset, clock) |
| 43 |
begin |
| 44 |
if (reset = '1') then |
| 45 |
q_r <= '0'; |
| 46 |
set_r <= '0'; |
| 47 |
clr_r <= '0'; |
| 48 |
elsif (rising_edge(clock)) then |
| 49 |
set_r <= set; |
| 50 |
clr_r <= clear; |
| 51 |
|
| 52 |
if (set_r = '0' and set = '1') then |
| 53 |
q_r <= '1'; |
| 54 |
elsif(clr_r = '0' and clear = '1') then |
| 55 |
q_r <= '0'; |
| 56 |
end if; |
| 57 |
end if; |
| 58 |
end process; |
| 59 |
|
| 60 |
q <= q_r; |
| 61 |
|
| 62 |
end architecture; -- arch |