w11 - vhd
0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
clkdivce.vhd
Go to the documentation of this file.
1
-- $Id: clkdivce.vhd 1181 2019-07-08 17:00:50Z mueller $
2
-- SPDX-License-Identifier: GPL-3.0-or-later
3
-- Copyright 2007-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
------------------------------------------------------------------------------
6
-- Module Name: clkgen - syn
7
-- Description: Generate usec and msec enable signals
8
--
9
-- Dependencies: -
10
-- Test bench: -
11
-- Target Devices: generic
12
-- Tool versions: ise 8.2-14.7; viv 2014.4-2015.4; ghdl 0.18-0.33
13
-- Revision History:
14
-- Date Rev Version Comment
15
-- 2011-10-22 418 1.0.3 now numeric_std clean
16
-- 2008-01-20 112 1.0.2 rename clkgen->clkdivce; remove SYS_CLK port
17
-- 2007-10-12 88 1.0.1 avoid ieee.std_logic_unsigned, use cast to unsigned
18
-- 2007-06-30 62 1.0 Initial version
19
------------------------------------------------------------------------------
20
-- Note: for test bench usage a copy of the clkdivce entity, with _tb
21
-- appended to the name, has been created in the /tb sub folder.
22
-- Ensure to update the copy when this file is changed !!
23
24
library
ieee
;
25
use
ieee.std_logic_1164.
all
;
26
use
ieee.numeric_std.
all
;
27
28
use
work.
slvtypes
.
all
;
29
30
entity
clkdivce
is
-- generate usec/msec ce pulses
31
generic
(
32
CDUWIDTH
:
positive
:=
6
;
-- usec clock divider width
33
USECDIV
:
positive
:=
50
;
-- divider ratio for usec pulse
34
MSECDIV
:
positive
:=
1000
)
;
-- divider ratio for msec pulse
35
port
(
36
CLK
:
in
slbit
;
-- input clock
37
CE_USEC
:
out
slbit
;
-- usec pulse
38
CE_MSEC
:
out
slbit
-- msec pulse
39
)
;
40
end
clkdivce
;
41
42
43
architecture
syn
of
clkdivce
is
44
45
type
regs_type
is
record
46
ucnt
:
slv
(
CDUWIDTH
-
1
downto
0
)
;
-- usec clock divider counter
47
mcnt
:
slv10
;
-- msec clock divider counter
48
usec
:
slbit
;
-- usec pulse
49
msec
:
slbit
;
-- msec pulse
50
end
record
regs_type
;
51
52
constant
regs_init
:
regs_type
:=
(
53
slv
(
to_unsigned
(
USECDIV
-
1
,
CDUWIDTH
)
)
,
54
slv
(
to_unsigned
(
MSECDIV
-
1
,
10
)
)
,
55
'
0
'
,
'
0
'
56
)
;
57
58
signal
R_REGS
:
regs_type
:=
regs_init
;
-- state registers
59
signal
N_REGS
:
regs_type
:=
regs_init
;
-- next value state regs
60
61
begin
62
63
assert
USECDIV
<=
2
*
*
CDUWIDTH
and
MSECDIV
<=
1024
64
report
"assert(USECDIV <= 2**CDUWIDTH and MSECDIV <= 1024): "
&
65
"USECDIV too large for given CDUWIDTH or MSECDIV>1024"
66
severity
failure
;
67
68
proc_regs:
process
(
CLK
)
69
begin
70
71
if
rising_edge
(
CLK
)
then
72
R_REGS
<=
N_REGS
;
73
end
if
;
74
75
end
process
proc_regs
;
76
77
proc_next:
process
(
R_REGS
)
78
79
variable
r
:
regs_type
:=
regs_init
;
80
variable
n
:
regs_type
:=
regs_init
;
81
82
begin
83
84
r
:=
R_REGS
;
85
n
:=
R_REGS
;
86
87
n
.
usec
:=
'
0
'
;
88
n
.
msec
:=
'
0
'
;
89
90
n
.
ucnt
:=
slv
(
unsigned
(
r
.
ucnt
)
-
1
)
;
91
if
unsigned
(
r
.
ucnt
)
=
0
then
92
n
.
usec
:=
'
1
'
;
93
n
.
ucnt
:=
slv
(
to_unsigned
(
USECDIV
-
1
,
CDUWIDTH
)
)
;
94
n
.
mcnt
:=
slv
(
unsigned
(
r
.
mcnt
)
-
1
)
;
95
if
unsigned
(
r
.
mcnt
)
=
0
then
96
n
.
msec
:=
'
1
'
;
97
n
.
mcnt
:=
slv
(
to_unsigned
(
MSECDIV
-
1
,
10
)
)
;
98
end
if
;
99
end
if
;
100
101
N_REGS
<=
n
;
102
103
CE_USEC
<=
r
.
usec
;
104
CE_MSEC
<=
r
.
msec
;
105
106
end
process
proc_next
;
107
108
109
end
syn;
clkdivce.syn
Definition:
clkdivce.vhd:43
clkdivce.syn.N_REGS
regs_type := regs_init N_REGS
Definition:
clkdivce.vhd:59
clkdivce.syn.regs_type
regs_type
Definition:
clkdivce.vhd:45
clkdivce.syn.R_REGS
regs_type := regs_init R_REGS
Definition:
clkdivce.vhd:58
clkdivce.syn.regs_init
regs_type :=( slv( to_unsigned( USECDIV- 1, CDUWIDTH) ), slv( to_unsigned( MSECDIV- 1, 10) ), '0', '0') regs_init
Definition:
clkdivce.vhd:52
clkdivce
Definition:
clkdivce.vhd:30
clkdivce.CE_MSEC
out CE_MSEC slbit
Definition:
clkdivce.vhd:39
clkdivce.USECDIV
USECDIV positive := 50
Definition:
clkdivce.vhd:33
clkdivce.CDUWIDTH
CDUWIDTH positive := 6
Definition:
clkdivce.vhd:32
clkdivce.CE_USEC
out CE_USEC slbit
Definition:
clkdivce.vhd:37
clkdivce.MSECDIV
MSECDIV positive := 1000
Definition:
clkdivce.vhd:34
clkdivce.CLK
in CLK slbit
Definition:
clkdivce.vhd:36
slvtypes
Definition:
slvtypes.vhd:28
slvtypes.slv10
std_logic_vector( 9 downto 0) slv10
Definition:
slvtypes.vhd:42
slvtypes.slbit
std_logic slbit
Definition:
slvtypes.vhd:30
slvtypes.slv
std_logic_vector slv
Definition:
slvtypes.vhd:31
vlib
genlib
clkdivce.vhd
Generated on Thu Feb 9 2023 12:41:05 for w11 - vhd by
1.9.6