w11 - vhd
0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
clkdivce_tb.vhd
Go to the documentation of this file.
1
-- $Id: clkdivce_tb.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: clkdivce_tb - sim
7
-- Description: Generate usec and msec enable signals (SIM only!)
8
--
9
-- Dependencies: -
10
-- Test bench: -
11
-- Target Devices: generic
12
-- Tool versions: viv 2016.2; ghdl 0.33
13
-- Revision History:
14
-- Date Rev Version Comment
15
-- 2016-09-10 806 1.0 Initial version (copied from clkdivce)
16
------------------------------------------------------------------------------
17
18
library
ieee
;
19
use
ieee.std_logic_1164.
all
;
20
use
ieee.numeric_std.
all
;
21
22
use
work.
slvtypes
.
all
;
23
24
entity
clkdivce_tb
is
-- generate usec/msec ce pulses
25
generic
(
26
CDUWIDTH
:
positive
:=
6
;
-- usec clock divider width
27
USECDIV
:
positive
:=
50
;
-- divider ratio for usec pulse
28
MSECDIV
:
positive
:=
1000
)
;
-- divider ratio for msec pulse
29
port
(
30
CLK
:
in
slbit
;
-- input clock
31
CE_USEC
:
out
slbit
;
-- usec pulse
32
CE_MSEC
:
out
slbit
-- msec pulse
33
)
;
34
end
clkdivce_tb
;
35
36
37
architecture
sim
of
clkdivce_tb
is
38
39
type
regs_type
is
record
40
ucnt
:
slv
(
CDUWIDTH
-
1
downto
0
)
;
-- usec clock divider counter
41
mcnt
:
slv10
;
-- msec clock divider counter
42
usec
:
slbit
;
-- usec pulse
43
msec
:
slbit
;
-- msec pulse
44
end
record
regs_type
;
45
46
constant
regs_init
:
regs_type
:=
(
47
slv
(
to_unsigned
(
USECDIV
-
1
,
CDUWIDTH
)
)
,
48
slv
(
to_unsigned
(
MSECDIV
-
1
,
10
)
)
,
49
'
0
'
,
'
0
'
50
)
;
51
52
signal
R_REGS
:
regs_type
:=
regs_init
;
-- state registers
53
signal
N_REGS
:
regs_type
:=
regs_init
;
-- next value state regs
54
55
begin
56
57
assert
USECDIV
<=
2
*
*
CDUWIDTH
and
MSECDIV
<=
1024
58
report
"assert(USECDIV <= 2**CDUWIDTH and MSECDIV <= 1024): "
&
59
"USECDIV too large for given CDUWIDTH or MSECDIV>1024"
60
severity
failure
;
61
62
proc_regs:
process
(
CLK
)
63
begin
64
65
if
rising_edge
(
CLK
)
then
66
R_REGS
<=
N_REGS
;
67
end
if
;
68
69
end
process
proc_regs
;
70
71
proc_next:
process
(
R_REGS
)
72
73
variable
r
:
regs_type
:=
regs_init
;
74
variable
n
:
regs_type
:=
regs_init
;
75
76
begin
77
78
r
:=
R_REGS
;
79
n
:=
R_REGS
;
80
81
n
.
usec
:=
'
0
'
;
82
n
.
msec
:=
'
0
'
;
83
84
n
.
ucnt
:=
slv
(
unsigned
(
r
.
ucnt
)
-
1
)
;
85
if
unsigned
(
r
.
ucnt
)
=
0
then
86
n
.
usec
:=
'
1
'
;
87
n
.
ucnt
:=
slv
(
to_unsigned
(
USECDIV
-
1
,
CDUWIDTH
)
)
;
88
n
.
mcnt
:=
slv
(
unsigned
(
r
.
mcnt
)
-
1
)
;
89
if
unsigned
(
r
.
mcnt
)
=
0
then
90
n
.
msec
:=
'
1
'
;
91
n
.
mcnt
:=
slv
(
to_unsigned
(
MSECDIV
-
1
,
10
)
)
;
92
end
if
;
93
end
if
;
94
95
N_REGS
<=
n
;
96
97
CE_USEC
<=
r
.
usec
;
98
CE_MSEC
<=
r
.
msec
;
99
100
end
process
proc_next
;
101
102
103
end
sim;
clkdivce_tb.sim
Definition:
clkdivce_tb.vhd:37
clkdivce_tb.sim.N_REGS
regs_type := regs_init N_REGS
Definition:
clkdivce_tb.vhd:53
clkdivce_tb.sim.regs_type
regs_type
Definition:
clkdivce_tb.vhd:39
clkdivce_tb.sim.R_REGS
regs_type := regs_init R_REGS
Definition:
clkdivce_tb.vhd:52
clkdivce_tb.sim.regs_init
regs_type :=( slv( to_unsigned( USECDIV- 1, CDUWIDTH) ), slv( to_unsigned( MSECDIV- 1, 10) ), '0', '0') regs_init
Definition:
clkdivce_tb.vhd:46
clkdivce_tb
Definition:
clkdivce_tb.vhd:24
clkdivce_tb.CE_MSEC
out CE_MSEC slbit
Definition:
clkdivce_tb.vhd:33
clkdivce_tb.USECDIV
USECDIV positive := 50
Definition:
clkdivce_tb.vhd:27
clkdivce_tb.CDUWIDTH
CDUWIDTH positive := 6
Definition:
clkdivce_tb.vhd:26
clkdivce_tb.CE_USEC
out CE_USEC slbit
Definition:
clkdivce_tb.vhd:31
clkdivce_tb.MSECDIV
MSECDIV positive := 1000
Definition:
clkdivce_tb.vhd:28
clkdivce_tb.CLK
in CLK slbit
Definition:
clkdivce_tb.vhd:30
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
tb
clkdivce_tb.vhd
Generated on Thu Feb 9 2023 12:41:05 for w11 - vhd by
1.9.6