w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ib_rlim_slv.vhd
Go to the documentation of this file.
1-- $Id: ib_rlim_slv.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_slv - syn
7-- Description: ibus rate limter - slave
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 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-- sel ce-scale rate in slv
22-- 0 - 8 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: 16 256 usec 3.9 kHz
28-- 6 1: 32 512 usec 2.0 kHz
29-- 7 1: 64 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_slv is -- ibus rate limter - slave
40 port (
41 CLK : in slbit; -- clock
42 RESET : in slbit; -- system reset
43 RLIM_CEV : in slv8; -- clock enable vector
44 SEL : in slv3; -- rlim select
45 START : in slbit; -- start timer
46 STOP : in slbit; -- stop timer
47 DONE : out slbit; -- 1 cycle pulse when expired
48 BUSY : out slbit -- timer running
49 );
50end ib_rlim_slv;
51
52architecture syn of ib_rlim_slv is
53
54 type regs_type is record -- state registers
55 cnt : slv3; -- counter
56 busy : slbit; -- busy
57 end record regs_type;
58
59 constant regs_init : regs_type := (
60 (others=>'0'), -- cnt
61 '0' -- busy
62 );
63
66
67begin
68
69 proc_regs: process (CLK)
70 begin
71 if rising_edge(CLK) then
72 if RESET = '1' then
74 else
75 R_REGS <= N_REGS;
76 end if;
77 end if;
78 end process proc_regs;
79
80 proc_next : process (R_REGS, RLIM_CEV, SEL, START, STOP)
81 variable r : regs_type := regs_init;
82 variable n : regs_type := regs_init;
83 variable idone : slbit := '0';
84 variable ice : slbit := '0';
85 begin
86
87 r := R_REGS;
88 n := R_REGS;
89
90 ice := '0';
91 case SEL is
92 when "000" => ice := RLIM_CEV(0); -- every cycle
93 when "001" => ice := RLIM_CEV(1); -- every CE_USEC
94 when "010" => ice := RLIM_CEV(2); -- every 2nd CE_USEC
95 when "011" => ice := RLIM_CEV(3); -- every 4th CE_USEC
96 when "100" => ice := RLIM_CEV(4); -- every 8th CE_USEC
97 when "101" => ice := RLIM_CEV(5); -- every 32nd CE_USEC
98 when "110" => ice := RLIM_CEV(6); -- every 64th CE_USEC
99 when "111" => ice := RLIM_CEV(7); -- every 128th CE_USEC
100 when others => null;
101 end case;
102
103 idone := '0';
104 if STOP = '1' then
105 n.busy := '0';
106 idone := r.busy;
107 elsif START = '1' then
108 n.busy := '1';
109 n.cnt := "000";
110 elsif r.busy = '1' then
111 if ice = '1' then
112 n.cnt := slv(unsigned(r.cnt) + 1);
113 if r.cnt = "111" then
114 n.busy := '0';
115 idone := '1';
116 end if;
117 end if;
118 end if;
119
120 N_REGS <= n;
121
122 DONE <= idone;
123 BUSY <= r.busy;
124
125 end process proc_next;
126
127end syn;
regs_type := regs_init N_REGS
Definition: ib_rlim_slv.vhd:65
regs_type := regs_init R_REGS
Definition: ib_rlim_slv.vhd:64
regs_type :=(( others => '0'), '0') regs_init
Definition: ib_rlim_slv.vhd:59
in STOP slbit
Definition: ib_rlim_slv.vhd:46
in RESET slbit
Definition: ib_rlim_slv.vhd:42
out BUSY slbit
Definition: ib_rlim_slv.vhd:49
out DONE slbit
Definition: ib_rlim_slv.vhd:47
in CLK slbit
Definition: ib_rlim_slv.vhd:41
in SEL slv3
Definition: ib_rlim_slv.vhd:44
in RLIM_CEV slv8
Definition: ib_rlim_slv.vhd:43
in START slbit
Definition: ib_rlim_slv.vhd:45
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
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