w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
rgbdrv_master.vhd
Go to the documentation of this file.
1-- $Id: rgbdrv_master.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2016- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: rgbdrv_master - syn
7-- Description: rgbled driver: master
8--
9-- Dependencies: -
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: viv 2015.4; ghdl 0.31
13--
14-- Revision History:
15-- Date Rev Version Comment
16-- 2016-02-20 734 1.0 Initial version
17------------------------------------------------------------------------------
18
19library ieee;
20use ieee.std_logic_1164.all;
21use ieee.numeric_std.all;
22
23use work.slvtypes.all;
24
25entity rgbdrv_master is -- rgbled driver: master
26 generic (
27 DWIDTH : positive := 8); -- dimmer width (must be >= 1)
28 port (
29 CLK : in slbit; -- clock
30 RESET : in slbit := '0'; -- reset
31 CE_USEC : in slbit; -- 1 us clock enable
32 RGBCNTL : out slv3; -- rgb control
33 DIMCNTL : out slv(DWIDTH-1 downto 0) -- dim control
34 );
36
37architecture syn of rgbdrv_master is
38
39 type regs_type is record
40 rgbena : slv3; -- rgb enables
41 dimcnt : slv(DWIDTH-1 downto 0); -- dim counter
42 end record regs_type;
43
44 constant dimones : slv(DWIDTH-1 downto 0) := (others=>'1');
45
46 constant regs_init : regs_type := (
47 "001", -- rgbena
48 dimones -- dimcnt
49 );
50
51 signal R_REGS : regs_type := regs_init; -- state registers
52 signal N_REGS : regs_type := regs_init; -- next value state regs
53
54begin
55
56 proc_regs: process (CLK)
57 begin
58
59 if rising_edge(CLK) then
60 if RESET = '1' then
62 else
63 R_REGS <= N_REGS;
64 end if;
65 end if;
66
67 end process proc_regs;
68
69
70 proc_next: process (R_REGS, CE_USEC)
71 variable r : regs_type := regs_init;
72 variable n : regs_type := regs_init;
73 begin
74
75 r := R_REGS;
76 n := R_REGS;
77
78 if CE_USEC = '1' then
79 n.dimcnt := slv(unsigned(r.dimcnt) + 1);
80 if r.dimcnt = dimones then
81 n.rgbena(2) := r.rgbena(1);
82 n.rgbena(1) := r.rgbena(0);
83 n.rgbena(0) := r.rgbena(2);
84 end if;
85 end if;
86
87 N_REGS <= n;
88
89 end process proc_next;
90
91 RGBCNTL <= R_REGS.rgbena;
92 DIMCNTL <= R_REGS.dimcnt;
93
94end syn;
regs_type :=( "001", dimones) regs_init
regs_type := regs_init N_REGS
slv( DWIDTH- 1 downto 0) :=( others => '1') dimones
regs_type := regs_init R_REGS
DWIDTH positive := 8
in CE_USEC slbit
in CLK slbit
in RESET slbit := '0'
out RGBCNTL slv3
out DIMCNTL slv( DWIDTH- 1 downto 0)
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector slv
Definition: slvtypes.vhd:31