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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_vdsm12.vhd] - Diff between revs 194 and 213

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 194 Rev 213
Line 25... Line 25...
-- Description:  12-bit variable delta-sigma modulator. Requires Open8_pkg.vhd
-- Description:  12-bit variable delta-sigma modulator. Requires Open8_pkg.vhd
--
--
-- Register Map:
-- Register Map:
-- Offset  Bitfield Description                        Read/Write
-- Offset  Bitfield Description                        Read/Write
--   0x0   AAAAAAAA Pending DAC Level (7:0)            (R/W)
--   0x0   AAAAAAAA Pending DAC Level (7:0)            (R/W)
--   0x1   AAAAAAAA Pending DAC Level (11:8)           (R/W)
--   0x1   ----AAAA Pending DAC Level (11:8)           (R/W)
--   0x2   -------- Clear DAC Output (on write)        (WO)
--   0x2   -------- Clear DAC Output (on write)        (WO)
--   0x3   AAAAAAAA Update DAC Output (on write)       (RO)
--   0x3   AAAAAAAA Update DAC Output (on write)       (RO)
--
--
-- Revision History
-- Revision History
-- Author          Date     Change
-- Author          Date     Change
------------------ -------- ---------------------------------------------------
------------------ -------- ---------------------------------------------------
-- Seth Henry      12/18/19 Design start
-- Seth Henry      12/18/19 Design start
 
-- Seth Henry      04/10/20 Code Cleanup
 
 
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_arith.all;
Line 67... Line 68...
 
 
  constant User_Addr    : std_logic_vector(15 downto 2)
  constant User_Addr    : std_logic_vector(15 downto 2)
                          := Address(15 downto 2);
                          := Address(15 downto 2);
  alias  Comp_Addr      is Bus_Address(15 downto 2);
  alias  Comp_Addr      is Bus_Address(15 downto 2);
  alias  Reg_Addr       is Bus_Address(1 downto 0);
  alias  Reg_Addr       is Bus_Address(1 downto 0);
  signal Reg_Sel        : std_logic_vector(1 downto 0);
  signal Reg_Sel        : std_logic_vector(1 downto 0) := "00";
  signal Addr_Match     : std_logic;
  signal Addr_Match     : std_logic := '0';
  signal Wr_En          : std_logic;
  signal Wr_En          : std_logic := '0';
  signal Wr_Data_q      : DATA_TYPE;
  signal Wr_Data_q      : DATA_TYPE := x"00";
  signal Rd_En          : std_logic;
  signal Rd_En          : std_logic := '0';
 
 
  constant DAC_Width    : integer := 12;
  constant DAC_Width    : integer := 12;
 
 
  signal DAC_Val_LB     : DATA_TYPE;
  signal DAC_Val_LB     : std_logic_vector(7 downto 0) := x"00";
  signal DAC_Val_UB     : DATA_TYPE;
  signal DAC_Val_UB     : std_logic_vector(3 downto 0) := x"0";
  signal DAC_Val        : std_logic_vector(DAC_Width-1 downto 0);
  signal DAC_Val        : std_logic_vector(DAC_Width-1 downto 0)  :=
 
                           (others => '0');
 
 
  constant DELTA_1_I    : integer := 1;
  constant DELTA_1_I    : integer := 1;
  constant DELTA_2_I    : integer := 5;
  constant DELTA_2_I    : integer := 5;
  constant DELTA_3_I    : integer := 25;
  constant DELTA_3_I    : integer := 25;
  constant DELTA_4_I    : integer := 75;
  constant DELTA_4_I    : integer := 75;
Line 146... Line 148...
  constant PADJ_9       : std_logic_vector(DIV_WIDTH-1 downto 0) :=
  constant PADJ_9       : std_logic_vector(DIV_WIDTH-1 downto 0) :=
                           conv_std_logic_vector(PADJ_9_I,DIV_WIDTH);
                           conv_std_logic_vector(PADJ_9_I,DIV_WIDTH);
  constant PADJ_10      : std_logic_vector(DIV_WIDTH-1 downto 0) :=
  constant PADJ_10      : std_logic_vector(DIV_WIDTH-1 downto 0) :=
                           conv_std_logic_vector(PADJ_10_I,DIV_WIDTH);
                           conv_std_logic_vector(PADJ_10_I,DIV_WIDTH);
 
 
  signal DACin_q        : std_logic_vector(DAC_Width-1 downto 0);
  signal DACin_q        : std_logic_vector(DAC_Width-1 downto 0) :=
 
                           (others => '0');
 
 
  signal Divisor        : std_logic_vector(DIV_WIDTH-1 downto 0);
  signal Divisor        : std_logic_vector(DIV_WIDTH-1 downto 0) :=
  signal Dividend       : std_logic_vector(DIV_WIDTH-1 downto 0);
                           (others => '0');
 
 
  signal q              : std_logic_vector(DIV_WIDTH*2-1 downto 0);
  signal Dividend       : std_logic_vector(DIV_WIDTH-1 downto 0) :=
  signal diff           : std_logic_vector(DIV_WIDTH downto 0);
                           (others => '0');
 
 
 
  signal q              : std_logic_vector(DIV_WIDTH*2-1 downto 0) :=
 
                           (others => '0');
 
 
 
  signal diff           : std_logic_vector(DIV_WIDTH downto 0) :=
 
                           (others => '0');
 
 
  constant CB           : integer := ceil_log2(DIV_WIDTH);
  constant CB           : integer := ceil_log2(DIV_WIDTH);
  signal count          : std_logic_vector(CB-1 downto 0);
  signal count          : std_logic_vector(CB-1 downto 0) :=
 
                           (others => '0');
 
 
 
  signal Next_Width     : std_logic_vector(DAC_Width-1 downto 0) :=
 
                           (others => '0');
 
 
 
  signal Next_Period    : std_logic_vector(DAC_Width-1 downto 0) :=
 
                           (others => '0');
 
 
  signal Next_Width     : std_logic_vector(DAC_Width-1 downto 0);
  signal PWM_Width      : std_logic_vector(DAC_Width-1 downto 0) :=
  signal Next_Period    : std_logic_vector(DAC_Width-1 downto 0);
                           (others => '0');
 
 
  signal PWM_Width      : std_logic_vector(DAC_Width-1 downto 0);
  signal PWM_Period     : std_logic_vector(DAC_Width-1 downto 0) :=
  signal PWM_Period     : std_logic_vector(DAC_Width-1 downto 0);
                           (others => '0');
 
 
  signal Width_Ctr      : std_logic_vector(DAC_Width-1 downto 0);
  signal Width_Ctr      : std_logic_vector(DAC_Width-1 downto 0) :=
  signal Period_Ctr     : std_logic_vector(DAC_Width-1 downto 0);
                           (others => '0');
 
 
 
  signal Period_Ctr     : std_logic_vector(DAC_Width-1 downto 0) :=
 
                           (others => '0');
 
 
begin
begin
 
 
  Addr_Match            <= '1' when Comp_Addr = User_Addr else '0';
  Addr_Match            <= '1' when Comp_Addr = User_Addr else '0';
 
 
Line 180... Line 198...
      Rd_En             <= '0';
      Rd_En             <= '0';
      Rd_Data           <= OPEN8_NULLBUS;
      Rd_Data           <= OPEN8_NULLBUS;
      Wr_En             <= '0';
      Wr_En             <= '0';
      Wr_Data_q         <= x"00";
      Wr_Data_q         <= x"00";
      DAC_Val_LB        <= x"00";
      DAC_Val_LB        <= x"00";
      DAC_Val_UB        <= x"00";
      DAC_Val_UB        <= x"0";
      DAC_Val           <= (others => '0');
      DAC_Val           <= (others => '0');
    elsif( rising_edge( Clock ) )then
    elsif( rising_edge( Clock ) )then
      Reg_Sel           <= Reg_Addr;
      Reg_Sel           <= Reg_Addr;
 
 
      Wr_En             <= Addr_Match and Wr_Enable;
      Wr_En             <= Addr_Match and Wr_Enable;
Line 192... Line 210...
      if( Wr_En = '1' )then
      if( Wr_En = '1' )then
        case( Reg_Sel )is
        case( Reg_Sel )is
          when "00" =>
          when "00" =>
            DAC_Val_LB  <= Wr_Data_q;
            DAC_Val_LB  <= Wr_Data_q;
          when "01" =>
          when "01" =>
            DAC_Val_UB  <= "0000" & Wr_Data_q(3 downto 0);
            DAC_Val_UB  <= Wr_Data_q(3 downto 0);
          when "10" =>
          when "10" =>
            DAC_Val     <= (others => '0');
            DAC_Val     <= (others => '0');
          when "11" =>
          when "11" =>
            DAC_Val     <= DAC_Val_UB(3 downto 0) & DAC_Val_LB;
            DAC_Val     <= DAC_Val_UB & DAC_Val_LB;
          when others => null;
          when others => null;
        end case;
        end case;
      end if;
      end if;
 
 
      Rd_Data           <= OPEN8_NULLBUS;
      Rd_Data           <= OPEN8_NULLBUS;
Line 208... Line 226...
      if( Rd_En = '1' )then
      if( Rd_En = '1' )then
        case( Reg_Sel )is
        case( Reg_Sel )is
          when "00" =>
          when "00" =>
            Rd_Data     <= DAC_Val_LB;
            Rd_Data     <= DAC_Val_LB;
          when "01" =>
          when "01" =>
            Rd_Data     <= DAC_Val_UB;
            Rd_Data     <= x"0" & DAC_Val_UB;
          when others => null;
          when others => null;
        end case;
        end case;
      end if;
      end if;
    end if;
    end if;
  end process;
  end process;

powered by: WebSVN 2.1.0

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