From e5a4793ebe09c90a5b888ee91f376d97f0454ce5 Mon Sep 17 00:00:00 2001 From: Cahit Date: Mon, 20 Jan 2014 16:02:31 +0100 Subject: [PATCH] Changes to the DAC-SPI interface for the get4 ADCs --- special/spi_ltc2600.vhd | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/special/spi_ltc2600.vhd b/special/spi_ltc2600.vhd index 00f307d..ede76b6 100644 --- a/special/spi_ltc2600.vhd +++ b/special/spi_ltc2600.vhd @@ -40,6 +40,7 @@ architecture spi_ltc2600_arch of spi_ltc2600 is signal start : std_logic; signal chipselect_reg : std_logic_vector(15 downto 0) := x"0001"; signal clear_reg : std_logic_vector(15 downto 0) := x"0000"; + signal invert_reg : std_logic; signal spi_cs : std_logic_vector(15 downto 0); signal spi_sck : std_logic; @@ -70,12 +71,14 @@ begin BUS_ACK_OUT <= '1'; if BUS_ADDR_IN(4) = '0' then ram(addr) <= BUS_DATA_IN; - elsif BUS_ADDR_IN(1) = '1' then + elsif BUS_ADDR_IN(2) = '1' then clear_reg <= BUS_DATA_IN(15 downto 0); + elsif BUS_ADDR_IN(3) = '1' then + invert_reg <= BUS_DATA_IN(0); elsif BUS_ADDR_IN(0) = '1' then ctrl_reg <= BUS_DATA_IN; start <= '1'; - else --if BUS_ADDR_IN(0) = '0' then + else --if BUS_ADDR_IN(0) = '0' then chipselect_reg <= BUS_DATA_IN(15 downto 0); end if; else @@ -88,12 +91,15 @@ begin BUS_DATA_OUT <= ram(addr); elsif BUS_ADDR_IN(0) = '1' then BUS_DATA_OUT <= ctrl_reg; - elsif BUS_ADDR_IN(1) = '1' then + elsif BUS_ADDR_IN(2) = '1' then BUS_DATA_OUT(15 downto 0) <= clear_reg; BUS_DATA_OUT(31 downto 16) <= x"0000"; + elsif BUS_ADDR_IN(3) = '1' then + BUS_DATA_OUT(0) <= invert_reg; + BUS_DATA_OUT(31 downto 1) <= (others => '0'); elsif BUS_ADDR_IN(1) = '1' then BUS_DATA_OUT <= readback; - else --if BUS_ADDR_IN(1) = '0' then + else --if BUS_ADDR_IN(1) = '0' then BUS_DATA_OUT(15 downto 0) <= chipselect_reg; BUS_DATA_OUT(31 downto 16) <= x"0000"; end if; @@ -208,10 +214,19 @@ begin --- Outputs - SPI_CS_OUT <= spi_cs; - SPI_SCK_OUT <= spi_sck; - SPI_SDO_OUT <= spi_sd; +-- Outputs + Invert : process(invert_reg) + begin + if invert_reg = '1' then + SPI_CS_OUT <= not spi_cs; + SPI_SCK_OUT <= not spi_sck; + SPI_SDO_OUT <= not spi_sd; + else + SPI_CS_OUT <= spi_cs; + SPI_SCK_OUT <= spi_sck; + SPI_SDO_OUT <= spi_sd; + end if; + end process Invert; SPI_CLR_OUT <= clear_reg; -- 2.43.0