| 1 | --
|
|---|
| 2 | -- VHDL Architecture FACT_FAD_TB_lib.spi_devices_emulator.beha
|
|---|
| 3 | --
|
|---|
| 4 | -- Created:
|
|---|
| 5 | -- by - Benjamin Krumm.UNKNOWN (EEPC8)
|
|---|
| 6 | -- at - 09:26:11 28.04.2010
|
|---|
| 7 | --
|
|---|
| 8 | -- using Mentor Graphics HDL Designer(TM) 2009.1 (Build 12)
|
|---|
| 9 | --
|
|---|
| 10 | LIBRARY ieee;
|
|---|
| 11 | USE ieee.std_logic_1164.all;
|
|---|
| 12 | USE ieee.std_logic_arith.all;
|
|---|
| 13 | USE ieee.std_logic_unsigned.all;
|
|---|
| 14 | LIBRARY FACT_FAD_lib;
|
|---|
| 15 | USE FACT_FAD_lib.fad_definitions.all;
|
|---|
| 16 |
|
|---|
| 17 | ENTITY max6662_emulator IS
|
|---|
| 18 | GENERIC(
|
|---|
| 19 | DRS_TEMPERATURE : integer := 51
|
|---|
| 20 | );
|
|---|
| 21 | PORT(
|
|---|
| 22 | sclk : IN std_logic;
|
|---|
| 23 | sio : INOUT std_logic;
|
|---|
| 24 | sensor_cs : IN std_logic_vector(3 downto 0)
|
|---|
| 25 | );
|
|---|
| 26 | END max6662_emulator ;
|
|---|
| 27 |
|
|---|
| 28 | ARCHITECTURE beha OF max6662_emulator IS
|
|---|
| 29 |
|
|---|
| 30 | signal data : std_logic_vector(15 downto 0) := (others => '0');
|
|---|
| 31 | signal spi_cycle_cnt : integer := 0;
|
|---|
| 32 | signal temperature : integer range -55 to 150 := DRS_TEMPERATURE;
|
|---|
| 33 |
|
|---|
| 34 | BEGIN
|
|---|
| 35 |
|
|---|
| 36 | spi_cnt_proc: process (sclk)
|
|---|
| 37 | begin
|
|---|
| 38 | if rising_edge(sclk) then
|
|---|
| 39 | if (sensor_cs /= "1111") then
|
|---|
| 40 | spi_cycle_cnt <= spi_cycle_cnt + 1;
|
|---|
| 41 | else
|
|---|
| 42 | spi_cycle_cnt <= 0;
|
|---|
| 43 | end if;
|
|---|
| 44 | end if;
|
|---|
| 45 | end process spi_cnt_proc;
|
|---|
| 46 |
|
|---|
| 47 | sensor_data_proc: process (spi_cycle_cnt, sclk)
|
|---|
| 48 | begin
|
|---|
| 49 | if falling_edge(sclk) then
|
|---|
| 50 | sio <= 'Z';
|
|---|
| 51 | if (spi_cycle_cnt = 1) then
|
|---|
| 52 | data <= '0' & conv_std_logic_vector(temperature + conv_integer(sensor_cs), 12) & "000";
|
|---|
| 53 | end if;
|
|---|
| 54 | if (spi_cycle_cnt > 7) then
|
|---|
| 55 | sio <= data(15);
|
|---|
| 56 | data(15 downto 1) <= data(14 downto 0);
|
|---|
| 57 | end if;
|
|---|
| 58 | end if;
|
|---|
| 59 | end process sensor_data_proc;
|
|---|
| 60 |
|
|---|
| 61 | END ARCHITECTURE beha;
|
|---|
| 62 |
|
|---|