OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_vdsm8.vhd] - Blame information for rev 301

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 213 jshamlet
-- Copyright (c)2016, 2020 Jeremy Seth Henry
2 167 jshamlet
-- All rights reserved.
3
--
4
-- Redistribution and use in source and binary forms, with or without
5
-- modification, are permitted provided that the following conditions are met:
6
--     * Redistributions of source code must retain the above copyright
7
--       notice, this list of conditions and the following disclaimer.
8
--     * Redistributions in binary form must reproduce the above copyright
9
--       notice, this list of conditions and the following disclaimer in the
10
--       documentation and/or other materials provided with the distribution,
11
--       where applicable (as part of a user interface, debugging port, etc.)
12
--
13
-- THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
14
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
-- DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
17
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 194 jshamlet
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 167 jshamlet
--
24
-- VHDL Units :  o8_vdsm8
25 217 jshamlet
-- Description:  8-bit variable delta-sigma modulator.
26 213 jshamlet
--
27 221 jshamlet
-- Register Map:
28
-- Offset  Bitfield Description                        Read/Write
29
--   0x00  AAAAAAAA DAC Value                             (RW)
30
--
31 213 jshamlet
-- Revision History
32
-- Author          Date     Change
33
------------------ -------- ---------------------------------------------------
34
-- Seth Henry      06/23/16 Design start
35
-- Seth Henry      04/10/20 Code Cleanup
36 224 jshamlet
-- Seth Henry      04/16/20 Modified to use Open8 bus record
37 244 jshamlet
-- Seth Henry      05/18/20 Added write qualification input
38
-- Seth Henry      05/18/20 Added write qualification input
39 167 jshamlet
 
40
library ieee;
41
use ieee.std_logic_1164.all;
42
use ieee.std_logic_unsigned.all;
43
use ieee.std_logic_arith.all;
44
 
45
library work;
46
  use work.open8_pkg.all;
47
 
48
entity o8_vdsm8 is
49
generic(
50 268 jshamlet
  Invert_Output              : boolean := FALSE;
51 221 jshamlet
  Default_Value              : DATA_TYPE := x"00";
52 217 jshamlet
  Address                    : ADDRESS_TYPE
53 167 jshamlet
);
54
port(
55 223 jshamlet
  Open8_Bus                  : in  OPEN8_BUS_TYPE;
56 244 jshamlet
  Write_Qual                 : in  std_logic := '1';
57 217 jshamlet
  Rd_Data                    : out DATA_TYPE;
58 167 jshamlet
  --
59 217 jshamlet
  DACout                     : out std_logic
60 167 jshamlet
);
61
end entity;
62
 
63
architecture behave of o8_vdsm8 is
64
 
65 224 jshamlet
  alias Clock                is Open8_Bus.Clock;
66
  alias Reset                is Open8_Bus.Reset;
67
 
68 221 jshamlet
  constant User_Addr         : std_logic_vector(15 downto 0)
69
                               := Address(15 downto 0);
70 223 jshamlet
  alias  Comp_Addr           is Open8_Bus.Address(15 downto 0);
71 221 jshamlet
  signal Addr_Match          : std_logic;
72 244 jshamlet
  signal Wr_En_d             : std_logic := '0';
73
  signal Wr_En_q             : std_logic := '0';
74
  alias  Wr_Data_d           is Open8_Bus.Wr_Data;
75
  signal Wr_Data_q           : DATA_TYPE := x"00";
76
  signal Rd_En_d             : std_logic := '0';
77
  signal Rd_En_q             : std_logic := '0';
78
 
79 221 jshamlet
  signal Reg_Out             : DATA_TYPE;
80 172 jshamlet
 
81 268 jshamlet
  signal DACout_pre          : std_logic;
82
 
83 167 jshamlet
begin
84
 
85 217 jshamlet
  Addr_Match                 <= '1' when Comp_Addr = User_Addr else '0';
86 244 jshamlet
  Wr_En_d                    <= Addr_Match and Open8_Bus.Wr_En and Write_Qual;
87
  Rd_En_d                    <= Addr_Match and Open8_Bus.Rd_En;
88 167 jshamlet
 
89
  io_reg: process( Clock, Reset )
90
  begin
91
    if( Reset = Reset_Level )then
92 244 jshamlet
      Wr_En_q                <= '0';
93 217 jshamlet
      Wr_Data_q              <= x"00";
94 221 jshamlet
      Reg_Out                <= Default_Value;
95 244 jshamlet
      Rd_En_q                <= '0';
96 217 jshamlet
      Rd_Data                <= OPEN8_NULLBUS;
97 167 jshamlet
    elsif( rising_edge( Clock ) )then
98 244 jshamlet
      Wr_En_q                <= Wr_En_d;
99
      Wr_Data_q              <= Wr_Data_d;
100
      if( Wr_En_q = '1' )then
101 221 jshamlet
        Reg_Out              <= Wr_Data_q;
102 172 jshamlet
      end if;
103 167 jshamlet
 
104 244 jshamlet
      Rd_En_q                <= Rd_En_d;
105 217 jshamlet
      Rd_Data                <= OPEN8_NULLBUS;
106 244 jshamlet
      if( Rd_En_q = '1' )then
107 221 jshamlet
        Rd_Data              <= Reg_Out;
108 167 jshamlet
      end if;
109
    end if;
110
  end process;
111
 
112 217 jshamlet
  U_DAC : entity work.vdsm8
113
  generic map(
114
    Reset_Level              => Reset_Level
115
  )
116
  port map(
117
    Clock                    => Clock,
118
    Reset                    => Reset,
119 221 jshamlet
    DACin                    => Reg_Out,
120 268 jshamlet
    DACout                   => DACout_pre
121 217 jshamlet
  );
122 167 jshamlet
 
123 268 jshamlet
  DACout                     <= (not DACout_pre) when Invert_Output else
124
                                DACout_pre;
125
 
126 167 jshamlet
end architecture;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.