Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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


List of 54 messages in thread
TopicAuthorDate
VHDL FPGA            01/01/70 00:00      
   Hello, world?            01/01/70 00:00      
      LCD display            01/01/70 00:00      
         video overlay            01/01/70 00:00      
            funny you should say that            01/01/70 00:00      
   bcd to binary            01/01/70 00:00      
      Try a different algorithm            01/01/70 00:00      
      easier way            01/01/70 00:00      
         LUT            01/01/70 00:00      
   This is what you want!            01/01/70 00:00      
      It is not as easy as it seems!            01/01/70 00:00      
   Here\'s a little exercise ...            01/01/70 00:00      
      more info required            01/01/70 00:00      
         I don't think its very fair.            01/01/70 00:00      
            consider this ...            01/01/70 00:00      
         pick an arbitrary frequency            01/01/70 00:00      
   warnings            01/01/70 00:00      
      Give us a clue,what do they say?            01/01/70 00:00      
         warnings sample            01/01/70 00:00      
            You can ignore most of them, but Quartus is buggy            01/01/70 00:00      
               Combinational Loops            01/01/70 00:00      
                  No doubt about it ...            01/01/70 00:00      
            gated/ripple clocks            01/01/70 00:00      
               ... but those complaints aren\'t always relevant            01/01/70 00:00      
            warnings            01/01/70 00:00      
               Andy, how would YOU construct a latch?            01/01/70 00:00      
                  latches in FPGAs            01/01/70 00:00      
                     Excellent Posting            01/01/70 00:00      
                     more about latches            01/01/70 00:00      
                        I like clear terms in my latches            01/01/70 00:00      
                           The point is i think ... unitentional latches            01/01/70 00:00      
                              exactly ...            01/01/70 00:00      
                                 elsif            01/01/70 00:00      
                                    Bad code            01/01/70 00:00      
                                    elsif            01/01/70 00:00      
                                 Quartus complains if you use the library latch            01/01/70 00:00      
                           latch reset inputs            01/01/70 00:00      
                              the library latch has no clear function            01/01/70 00:00      
                                 Brand A vs Brand X            01/01/70 00:00      
                                    true enough            01/01/70 00:00      
   Modelsim            01/01/70 00:00      
      about the only limitations on modelsim are ;-            01/01/70 00:00      
      ModelSim, PicoBlaze, MicroBlaze            01/01/70 00:00      
         there's a CPLD <=>LCD app note            01/01/70 00:00      
            JTAG interface            01/01/70 00:00      
            darn            01/01/70 00:00      
               Xilinx CPLD applications handbook            01/01/70 00:00      
   Mahmood, stick with the recommended circuit            01/01/70 00:00      
      Recommended circuit            01/01/70 00:00      
         I would be really careful ...            01/01/70 00:00      
            Thanks Richard            01/01/70 00:00      
               don't be distracted by the unnecessary parts            01/01/70 00:00      
                  Xilinx Jtag for Altera            01/01/70 00:00      
                     How about Altera JTAG for ALTERA            01/01/70 00:00      

Back to Subject List