AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
generate_3.vhd
1 -- PROGRAM "Quartus II"
2 -- VERSION "Version 10.1 Build 197 01/19/2011 Service Pack 1 SJ Full Version"
3 -- CREATED "Mon Jul 08 17:43:34 2013"
4 
5 LIBRARY ieee;
6 USE ieee.std_logic_1164.all;
7 use ieee.numeric_std.all;
8 use ieee.std_logic_unsigned.all;
9 
10 ENTITY generate_3 IS
11  PORT
12  (
13  clock : IN STD_LOGIC;
14  START : IN STD_LOGIC;
15  LOAD_SEED : IN STD_LOGIC;
16  SEED : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
17  rnd : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
18  );
19 END generate_3;
20 
21 ARCHITECTURE behavioral OF generate_3 IS
22 
23 
24 signal result : std_logic_vector(7 downto 0);
25 signal adder : std_logic_vector(7 downto 0);
26 signal multi : std_logic_vector(10 downto 0);
27 signal interm : std_logic_vector(7 downto 0);
28 
29 signal del_ld_seed : std_logic;
30 
31 --*****************************************************************************
32 BEGIN
33 
34 process(clock)
35 begin
36  if rising_edge(clock) then
37  del_ld_seed <= LOAD_SEED;
38  end if;
39 end process;
40 
41 -- initial x(i) or x(n+1)
42 process(clock)
43 begin
44  if rising_edge(clock) then
45  if LOAD_SEED = '1' then
46  interm <= SEED;
47  elsif START = '1' then
48  interm <= adder;
49  end if;
50  end if;
51 end process;
52 
53 -- the rnd is build x(n) <= x(n-1) * 5 + 3
54 -- multiplication
55 process(interm)
56  variable term : integer;
57  variable produit : integer;
58 begin
59  term := TO_INTEGER(UNSIGNED(interm));
60  produit := term * 5;
61  multi <= STD_LOGIC_VECTOR( TO_SIGNED(produit,11) );
62 end process;
63 
64 -- adder
65 process(multi)
66 begin
67  adder <= multi(7 downto 0) + x"03";
68 end process;
69 
70 
71 -- out the result
72 process(clock)
73 begin
74  if rising_edge(clock) then
75  if del_ld_seed = '1' or START = '1' then
76  result <= adder(7 downto 0);
77  end if;
78  end if;
79 end process;
80 
81 rnd <= result;
82 
83 END behavioral;