Line 1... |
Line 1... |
-- Copyright (c)2013, 2020 Jeremy Seth Henry
|
-- Copyright (c)2016, 2020 Jeremy Seth Henry
|
-- All rights reserved.
|
-- All rights reserved.
|
--
|
--
|
-- Redistribution and use in source and binary forms, with or without
|
-- Redistribution and use in source and binary forms, with or without
|
-- modification, are permitted provided that the following conditions are met:
|
-- modification, are permitted provided that the following conditions are met:
|
-- * Redistributions of source code must retain the above copyright
|
-- * Redistributions of source code must retain the above copyright
|
Line 21... |
Line 21... |
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
--
|
--
|
-- VHDL Units : o8_vdsm8
|
-- VHDL Units : o8_vdsm8
|
-- Description: 8-bit variable delta-sigma modulator. Requires Open8_pkg.vhd
|
-- Description: 8-bit variable delta-sigma modulator. Requires Open8_pkg.vhd
|
|
--
|
|
-- Revision History
|
|
-- Author Date Change
|
|
------------------ -------- ---------------------------------------------------
|
|
-- Seth Henry 06/23/16 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 53... |
Line 59... |
|
|
architecture behave of o8_vdsm8 is
|
architecture behave of o8_vdsm8 is
|
|
|
constant User_Addr : std_logic_vector(15 downto 0) := Address;
|
constant User_Addr : std_logic_vector(15 downto 0) := Address;
|
alias Comp_Addr is Bus_Address(15 downto 0);
|
alias Comp_Addr is Bus_Address(15 downto 0);
|
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';
|
signal DACin : DATA_TYPE;
|
signal DACin : DATA_TYPE := x"00";
|
|
|
-- DAC WIDTH = 8 is fixed, with all constants normalized
|
-- DAC WIDTH = 8 is fixed, with all constants normalized
|
-- against 256 (the MAX PERIOD)
|
-- against 256 (the MAX PERIOD)
|
|
|
constant DAC_WIDTH : integer := 8;
|
constant DAC_WIDTH : integer := 8;
|
Line 107... |
Line 113... |
constant PADJ_5 : std_logic_vector(DIV_WIDTH-1 downto 0) :=
|
constant PADJ_5 : std_logic_vector(DIV_WIDTH-1 downto 0) :=
|
conv_std_logic_vector(PADJ_5_I,DIV_WIDTH);
|
conv_std_logic_vector(PADJ_5_I,DIV_WIDTH);
|
constant PADJ_6 : std_logic_vector(DIV_WIDTH-1 downto 0) :=
|
constant PADJ_6 : std_logic_vector(DIV_WIDTH-1 downto 0) :=
|
conv_std_logic_vector(PADJ_6_I,DIV_WIDTH);
|
conv_std_logic_vector(PADJ_6_I,DIV_WIDTH);
|
|
|
signal DACin_q : DATA_TYPE;
|
signal DACin_q : DATA_TYPE := x"00";
|
|
|
|
signal Divisor : std_logic_vector(DIV_WIDTH-1 downto 0) :=
|
|
(others => '0');
|
|
signal Dividend : std_logic_vector(DIV_WIDTH-1 downto 0) :=
|
|
(others => '0');
|
|
|
signal Divisor : std_logic_vector(DIV_WIDTH-1 downto 0);
|
signal q : std_logic_vector(DIV_WIDTH*2-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 diff : std_logic_vector(DIV_WIDTH downto 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 : DATA_TYPE;
|
signal Next_Width : DATA_TYPE := x"00";
|
signal Next_Period : DATA_TYPE;
|
signal Next_Period : DATA_TYPE := x"00";
|
|
|
signal PWM_Width : DATA_TYPE;
|
signal PWM_Width : DATA_TYPE := x"00";
|
signal PWM_Period : DATA_TYPE;
|
signal PWM_Period : DATA_TYPE := x"00";
|
|
|
signal Width_Ctr : DATA_TYPE;
|
signal Width_Ctr : DATA_TYPE := x"00";
|
signal Period_Ctr : DATA_TYPE;
|
signal Period_Ctr : DATA_TYPE := x"00";
|
|
|
begin
|
begin
|
|
|
Addr_Match <= '1' when Comp_Addr = User_Addr else '0';
|
Addr_Match <= '1' when Comp_Addr = User_Addr else '0';
|
|
|