source: firmware/FAD/FACT_FAD_lib/hdl/dna_gen.vhd@ 14788

Last change on this file since 14788 was 11755, checked in by neise, 13 years ago
reinit of this svn repos .... it was all too messy deleted the old folders and restarted with FACT_FAD_lib only. (well and the testbenches)
File size: 3.3 KB
Line 
1----------------------------------------------------------------------------------
2-- Company: ETH Zurich, Institute for Particle Physics
3-- Engineer: Q. Weitzel
4--
5-- Create Date: 10/06/2010
6-- Design Name:
7-- Module Name: FTU_dna_gen - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: entity to read out the FPGA DNA identifier
12--
13--
14-- Dependencies:
15--
16-- Revision:
17-- Revision 0.01 - File Created
18-- Additional Comments:
19--
20----------------------------------------------------------------------------------
21library IEEE;
22use IEEE.STD_LOGIC_1164.ALL;
23use IEEE.STD_LOGIC_ARITH.ALL;
24use IEEE.STD_LOGIC_UNSIGNED.ALL;
25
26---- Uncomment the following library declaration if instantiating
27---- any Xilinx primitives in this code.
28library UNISIM;
29use UNISIM.VComponents.all;
30
31entity dna_gen is
32 Port (
33 clk : IN STD_LOGIC;
34 dna : OUT STD_LOGIC_VECTOR(63 downto 0) := (others => '0');
35 ready : OUT STD_LOGIC := '0'
36 );
37end dna_gen;
38
39architecture Behavioral of dna_gen is
40 constant DNA_FOR_SIM : bit_vector := X"01710000E000FAD2"; -- for simulation only
41 signal dout_sig : STD_LOGIC := '0';
42 signal read_sig : STD_LOGIC := '0';
43 signal shift_sig : STD_LOGIC := '0';
44 signal dna_sig : STD_LOGIC_VECTOR(63 downto 0) := (others => '0');
45
46 type FTU_dna_gen_StateType is (IDLE, READ_DNA, SHIFT_DNA, DNA_READY);
47 signal FTU_dna_gen_State : FTU_dna_gen_StateType;
48
49 signal shift_cntr : INTEGER range 0 to 64 := 0;
50 signal start_sig : std_logic := '0';
51
52begin
53
54 DNA_PORT_inst : DNA_PORT
55 generic map (
56 SIM_DNA_VALUE => DNA_FOR_SIM) -- Specifies the Pre-programmed factory ID value
57 port map (
58 DOUT => dout_sig, -- 1-bit DNA output data
59 CLK => clk, -- 1-bit clock input
60 DIN => '0', -- 1-bit user data input pin
61 READ => read_sig, -- 1-bit input, active high load DNA, active low read
62 SHIFT => shift_sig -- 1-bit input, active high shift enable
63 );
64
65 FTU_dna_gen_FSM : process(clk)
66 begin
67 if Falling_edge(clk) then
68 if (start_sig = '0') then -- do it only once.
69 start_sig <= '1';
70 end if;
71 case FTU_dna_gen_State is
72 when IDLE =>
73 ready <= '0';
74 read_sig <= '0';
75 shift_sig <= '0';
76 if (start_sig = '1') then
77 FTU_dna_gen_State <= READ_DNA;
78 else
79 FTU_dna_gen_State <= IDLE;
80 end if;
81 when READ_DNA =>
82 ready <= '0';
83 read_sig <= '1';
84 shift_sig <= '0';
85 FTU_dna_gen_State <= SHIFT_DNA;
86 when SHIFT_DNA =>
87 shift_cntr <= shift_cntr + 1;
88 ready <= '0';
89 read_sig <= '0';
90 if (shift_cntr < 57) then
91 dna_sig <= dna_sig(62 downto 0) & dout_sig; -- put in from right
92 shift_sig <= '1';
93 FTU_dna_gen_State <= SHIFT_DNA;
94 --elsif (shift_cntr = 56) then
95 --dna_sig <= dna_sig(62 downto 0) & dout_sig; -- put in from right
96 --shift_sig <= '0';
97 --FTU_dna_gen_State <= SHIFT_DNA;
98 else
99 shift_sig <= '1';
100 FTU_dna_gen_State <= DNA_READY;
101 end if;
102 when DNA_READY =>
103 ready <= '1';
104 start_sig <= '0';
105 read_sig <= '0';
106 shift_sig <= '0';
107 end case;
108 end if;
109 end process FTU_dna_gen_FSM;
110
111 dna <= dna_sig;
112
113end Behavioral;
Note: See TracBrowser for help on using the repository browser.