??? 04/20/07 08:11 Read: times |
#137608 - elsif Responding to: ???'s previous message |
I just wrote this psudo random number generator which produces 16 bit random number once GENerate key is pressed. This simple program ate about 50% of my XC9572XL CPLD's resources.
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity rand is Port ( FCLK : in STD_LOGIC; RSTn : in STD_LOGIC; GEN : in STD_LOGIC; OUTPUTS : out STD_LOGIC_VECTOR (15 downto 0)); end rand; architecture Behavioral of rand is signal shift_reg : std_logic_vector(15 downto 0); begin process(FCLK, RSTn) begin if(RSTn = '0') then shift_reg <= x"34fe"; elsif(rising_edge(FCLK)) then shift_reg <= shift_reg(14 downto 0) & (shift_reg(15) xor shift_reg(14) xor shift_reg(12) xor shift_reg(3)); if(shift_reg = x"0000") then shift_reg <= x"f432"; elsif(GEN = '0') then -- generate random number key OUTPUTS <= shift_reg; end if; end if; end process; end Behavioral; I got 0 errors and 0 warnings and it didnt complain about combinational latches. However I wrote the program with if and end if statements like this process(FCLK, RSTn) begin if(RSTn = '0') then shift_reg <= x"34fe"; end if; if(rising_edge(FCLK)) then shift_reg <= shift_reg(14 downto 0) & (shift_reg(15) xor shift_reg(14) xor shift_reg(12) xor shift_reg(3)); if(shift_reg = x"0000") then shift_reg <= x"f432"; elsif(GEN = '0') then -- generate random number key OUTPUTS <= shift_reg; end if; end if; end process; the compiler (SP3) gave me error message : "Signal shift_reg cannot be synthesized, bad synchronous description.". So the tool is getting better in detecting errors which were considered as warnings in the past. Mahmood |