| 1 | --
|
|---|
| 2 | -- VHDL Architecture FACT_FTM_lib.dd_write_general_modul.beha
|
|---|
| 3 | --
|
|---|
| 4 | -- Created:
|
|---|
| 5 | -- by - kai.UNKNOWN (E5PCXX)
|
|---|
| 6 | -- at - 11:27:33 02.03.2011
|
|---|
| 7 | --
|
|---|
| 8 | -- using Mentor Graphics HDL Designer(TM) 2009.1 (Build 12)
|
|---|
| 9 | --
|
|---|
| 10 |
|
|---|
| 11 | LIBRARY ieee;
|
|---|
| 12 | USE ieee.std_logic_1164.all;
|
|---|
| 13 | USE ieee.std_logic_arith.all;
|
|---|
| 14 | USE IEEE.STD_LOGIC_UNSIGNED.all;
|
|---|
| 15 | -- LIBRARY FACT_FTM_lib;
|
|---|
| 16 | -- USE FACT_FTM_lib.ftm_array_types.all;
|
|---|
| 17 | -- USE FACT_FTM_lib.ftm_constants.all;
|
|---|
| 18 | library ftm_definitions;
|
|---|
| 19 | USE ftm_definitions.ftm_array_types.all;
|
|---|
| 20 | USE ftm_definitions.ftm_constants.all;
|
|---|
| 21 |
|
|---|
| 22 | ENTITY dd_write_general_modul IS
|
|---|
| 23 | PORT(
|
|---|
| 24 | clk : IN std_logic;
|
|---|
| 25 | dd_write_general : IN std_logic;
|
|---|
| 26 | dd_write_general_started : OUT std_logic := '0';
|
|---|
| 27 | dd_write_general_ready : OUT std_logic := '0';
|
|---|
| 28 | dd_busy : IN std_logic;
|
|---|
| 29 | dd_write : OUT std_logic := '0';
|
|---|
| 30 | dd_started : IN std_logic;
|
|---|
| 31 | dd_ready : IN std_logic;
|
|---|
| 32 | dd_addr : OUT std_logic_vector (11 DOWNTO 0) := (others => '0');
|
|---|
| 33 | dd_data : OUT std_logic_vector (15 DOWNTO 0) := (others => '0')
|
|---|
| 34 | );
|
|---|
| 35 | END ENTITY dd_write_general_modul;
|
|---|
| 36 |
|
|---|
| 37 | --
|
|---|
| 38 | ARCHITECTURE beha OF dd_write_general_modul IS
|
|---|
| 39 |
|
|---|
| 40 | type state_write_general_proc_type is (WGP_INIT, WGP_CONFIG, WGP_IDLE, WGP_WRITE_COUNTER_01, WGP_WRITE_COUNTER_02, WGP_WRITE_COUNTER_03,
|
|---|
| 41 | WGP_WRITE_TEMP_01, WGP_WRITE_TEMP_02, WGP_WRITE_TEMP_03, WGP_WRITE_TEMP_04, WGP_WRITE_READY, WRITE_TO_DD_ADDR);
|
|---|
| 42 | type state_write_dd_type is (WRITE_DD_START, WRITE_DD_WAIT, WRITE_DD_END);
|
|---|
| 43 |
|
|---|
| 44 | signal state_write_general_proc : state_write_general_proc_type := WGP_INIT;
|
|---|
| 45 | signal next_state_dd : state_write_general_proc_type := WGP_INIT;
|
|---|
| 46 | signal state_write_dd : state_write_dd_type := WRITE_DD_START;
|
|---|
| 47 |
|
|---|
| 48 | signal local_dd_addr : std_logic_vector (11 DOWNTO 0) := (others => '0');
|
|---|
| 49 | signal local_dd_data : std_logic_vector (15 DOWNTO 0) := (others => '0');
|
|---|
| 50 |
|
|---|
| 51 | signal on_time_counter : std_logic_vector (47 DOWNTO 0) := X"333322221111";
|
|---|
| 52 | signal temp_sensor_0 : std_logic_vector (15 DOWNTO 0) := X"00FF";
|
|---|
| 53 | signal temp_sensor_1 : std_logic_vector (15 DOWNTO 0) := X"11FF";
|
|---|
| 54 | signal temp_sensor_2 : std_logic_vector (15 DOWNTO 0) := X"22FF";
|
|---|
| 55 | signal temp_sensor_3 : std_logic_vector (15 DOWNTO 0) := X"33FF";
|
|---|
| 56 |
|
|---|
| 57 | BEGIN
|
|---|
| 58 | write_general_proc : process (clk)
|
|---|
| 59 | begin
|
|---|
| 60 | if rising_edge (clk) then
|
|---|
| 61 | case state_write_general_proc is
|
|---|
| 62 |
|
|---|
| 63 | when WGP_INIT =>
|
|---|
| 64 | state_write_general_proc <= WGP_CONFIG;
|
|---|
| 65 |
|
|---|
| 66 | when WGP_CONFIG =>
|
|---|
| 67 | state_write_general_proc <= WGP_IDLE;
|
|---|
| 68 |
|
|---|
| 69 | when WGP_IDLE =>
|
|---|
| 70 | if (dd_write_general = '1') then
|
|---|
| 71 | dd_write_general_started <= '1';
|
|---|
| 72 | dd_write_general_ready <= '0';
|
|---|
| 73 | state_write_general_proc <= WGP_WRITE_COUNTER_01;
|
|---|
| 74 | end if;
|
|---|
| 75 |
|
|---|
| 76 | when WGP_WRITE_COUNTER_01 =>
|
|---|
| 77 | local_dd_addr <= X"000";
|
|---|
| 78 | local_dd_data <= on_time_counter (47 DOWNTO 32);
|
|---|
| 79 | next_state_dd <= WGP_WRITE_COUNTER_02;
|
|---|
| 80 | state_write_general_proc <= WRITE_TO_DD_ADDR;
|
|---|
| 81 |
|
|---|
| 82 | when WGP_WRITE_COUNTER_02 =>
|
|---|
| 83 | local_dd_addr <= X"001";
|
|---|
| 84 | local_dd_data <= on_time_counter (31 DOWNTO 16);
|
|---|
| 85 | next_state_dd <= WGP_WRITE_COUNTER_03;
|
|---|
| 86 | state_write_general_proc <= WRITE_TO_DD_ADDR;
|
|---|
| 87 |
|
|---|
| 88 | when WGP_WRITE_COUNTER_03 =>
|
|---|
| 89 | local_dd_addr <= X"002";
|
|---|
| 90 | local_dd_data <= on_time_counter (15 DOWNTO 0);
|
|---|
| 91 | next_state_dd <= WGP_WRITE_TEMP_01;
|
|---|
| 92 | state_write_general_proc <= WRITE_TO_DD_ADDR;
|
|---|
| 93 |
|
|---|
| 94 | when WGP_WRITE_TEMP_01 =>
|
|---|
| 95 | local_dd_addr <= X"003";
|
|---|
| 96 | local_dd_data <= temp_sensor_0;
|
|---|
| 97 | next_state_dd <= WGP_WRITE_TEMP_02;
|
|---|
| 98 | state_write_general_proc <= WRITE_TO_DD_ADDR;
|
|---|
| 99 |
|
|---|
| 100 | when WGP_WRITE_TEMP_02 =>
|
|---|
| 101 | local_dd_addr <= X"004";
|
|---|
| 102 | local_dd_data <= temp_sensor_1;
|
|---|
| 103 | next_state_dd <= WGP_WRITE_TEMP_03;
|
|---|
| 104 | state_write_general_proc <= WRITE_TO_DD_ADDR;
|
|---|
| 105 |
|
|---|
| 106 | when WGP_WRITE_TEMP_03 =>
|
|---|
| 107 | local_dd_addr <= X"005";
|
|---|
| 108 | local_dd_data <= temp_sensor_2;
|
|---|
| 109 | next_state_dd <= WGP_WRITE_TEMP_04;
|
|---|
| 110 | state_write_general_proc <= WRITE_TO_DD_ADDR;
|
|---|
| 111 |
|
|---|
| 112 | when WGP_WRITE_TEMP_04 =>
|
|---|
| 113 | local_dd_addr <= X"006";
|
|---|
| 114 | local_dd_data <= temp_sensor_3;
|
|---|
| 115 | next_state_dd <= WGP_WRITE_READY;
|
|---|
| 116 | state_write_general_proc <= WRITE_TO_DD_ADDR;
|
|---|
| 117 |
|
|---|
| 118 | when WGP_WRITE_READY =>
|
|---|
| 119 | if (dd_write_general = '0') then
|
|---|
| 120 | dd_write_general_ready <= '1';
|
|---|
| 121 | state_write_general_proc <= WGP_IDLE;
|
|---|
| 122 | end if;
|
|---|
| 123 |
|
|---|
| 124 | -- write to dynamic data block
|
|---|
| 125 | when WRITE_TO_DD_ADDR =>
|
|---|
| 126 | case state_write_dd is
|
|---|
| 127 | when WRITE_DD_START =>
|
|---|
| 128 | if (dd_busy = '0') then
|
|---|
| 129 | dd_addr <= local_dd_addr;
|
|---|
| 130 | dd_data <= local_dd_data;
|
|---|
| 131 | dd_write <= '1';
|
|---|
| 132 | state_write_dd <= WRITE_DD_WAIT;
|
|---|
| 133 | end if;
|
|---|
| 134 | when WRITE_DD_WAIT =>
|
|---|
| 135 | if (dd_started = '1') then
|
|---|
| 136 | dd_write <= '0';
|
|---|
| 137 | state_write_dd <= WRITE_DD_END;
|
|---|
| 138 | end if;
|
|---|
| 139 | when WRITE_DD_END =>
|
|---|
| 140 | if (dd_ready = '1') then
|
|---|
| 141 | state_write_dd <= WRITE_DD_START;
|
|---|
| 142 | state_write_general_proc <= next_state_dd;
|
|---|
| 143 | end if;
|
|---|
| 144 | end case;
|
|---|
| 145 |
|
|---|
| 146 | end case;
|
|---|
| 147 | end if;
|
|---|
| 148 | end process write_general_proc;
|
|---|
| 149 |
|
|---|
| 150 | END ARCHITECTURE beha;
|
|---|