w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ib_rlim_gen.vhd
Go to the documentation of this file.
1-- $Id: ib_rlim_gen.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2019- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ib_rlim_gen - syn
7-- Description: ibus rate limter - master
8--
9-- Dependencies: -
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: ise 14.7; viv 2017.2; ghdl 0.35
13--
14-- Revision History:
15-- Date Rev Version Comment
16-- 2019-04-14 1131 1.1 add CPUSUSP port; RLIM_CEV now slv8
17-- 2019-03-17 1123 1.0 Initial version
18-- 2019-03-15 1122 0.1 First draft
19--
20-- Notes:
21-- cev scale rate in slv
22-- (0) none 8 clock cycles
23-- (1) 1: 1 8 usec 125.0 kHz
24-- (2) 1: 2 16 usec 62.5 kHz
25-- (3) 1: 4 32 usec 31.2 kHz
26-- (4) 1: 8 64 usec 15.6 kHz
27-- (5) 1: 32 256 usec 3.9 kHz
28-- (6) 1: 64 512 usec 2.0 kHz
29-- (7) 1:128 1024 usec 1.0 kHz
30------------------------------------------------------------------------------
31
32library ieee;
33use ieee.std_logic_1164.all;
34use ieee.numeric_std.all;
35
36use work.slvtypes.all;
37
38-- ----------------------------------------------------------------------------
39entity ib_rlim_gen is -- ibus rate limter - master
40 port (
41 CLK : in slbit; -- clock
42 CE_USEC : in slbit; -- usec pulse
43 RESET : in slbit; -- system reset
44 CPUSUSP : in slbit; -- cpu suspended
45 RLIM_CEV : out slv8 -- clock enable vector
46 );
47end ib_rlim_gen;
48
49architecture syn of ib_rlim_gen is
50
51 type regs_type is record -- state registers
52 cnt : slv7; -- usec counter
53 cev : slv8; -- ce vector
54 end record regs_type;
55
56 constant regs_init : regs_type := (
57 (others=>'0'), -- cnt
58 (others=>'0') -- cev
59 );
60
63
64begin
65
66 proc_regs: process (CLK)
67 begin
68 if rising_edge(CLK) then
69 if RESET = '1' then
71 else
72 R_REGS <= N_REGS;
73 end if;
74 end if;
75 end process proc_regs;
76
77 proc_next : process (R_REGS, CE_USEC, CPUSUSP)
78 variable r : regs_type := regs_init;
79 variable n : regs_type := regs_init;
80 begin
81
82 r := R_REGS;
83 n := R_REGS;
84
85 n.cev := (others=>'0');
86 if CPUSUSP = '0' then -- run timers if CPU not suspended
87 n.cev(0) := '1'; -- none
88 if CE_USEC = '1' then
89 n.cev(1) := '1'; -- 1: 1
90 n.cnt := slv(unsigned(r.cnt) + 1);
91 if r.cnt(0 downto 0) = "1" then n.cev(2) := '1'; end if; -- 1: 2
92 if r.cnt(1 downto 0) = "11" then n.cev(3) := '1'; end if; -- 1: 4
93 if r.cnt(2 downto 0) = "111" then n.cev(4) := '1'; end if; -- 1: 8
94 if r.cnt(4 downto 0) = "11111" then n.cev(5) := '1'; end if; -- 1: 32
95 if r.cnt(5 downto 0) = "111111" then n.cev(6) := '1'; end if; -- 1: 64
96 if r.cnt(6 downto 0) = "1111111" then n.cev(7) := '1'; end if; -- 1:128
97 end if;
98 end if;
99
100 N_REGS <= n;
101
102 RLIM_CEV <= r.cev;
103
104 end process proc_next;
105
106end syn;
regs_type := regs_init N_REGS
Definition: ib_rlim_gen.vhd:62
regs_type :=(( others => '0'),( others => '0')) regs_init
Definition: ib_rlim_gen.vhd:56
regs_type := regs_init R_REGS
Definition: ib_rlim_gen.vhd:61
in RESET slbit
Definition: ib_rlim_gen.vhd:43
in CE_USEC slbit
Definition: ib_rlim_gen.vhd:42
in CLK slbit
Definition: ib_rlim_gen.vhd:41
in CPUSUSP slbit
Definition: ib_rlim_gen.vhd:44
out RLIM_CEV slv8
Definition: ib_rlim_gen.vhd:46
std_logic_vector( 6 downto 0) slv7
Definition: slvtypes.vhd:39
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 7 downto 0) slv8
Definition: slvtypes.vhd:40
std_logic_vector slv
Definition: slvtypes.vhd:31