Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

My First CPU but.. one problem

Hello to all,

I completed my first CPU in VHDL, an incredibly satisfying feeling! : D

I simulated successfully but I did not understand what it means to a signal colored red in ModelSim:

http://imageshack.us/a/img824/7039/modelsimproblem.png (http://imageshack.us/photo/my-images/824/modelsimproblem.png/)

I notice the signal that is in red has a change of more bits at the same time, it is perhaps hazard or something? How can I eliminate the problem in the case?

The register in question is an SRAM synthesized with normal flip-flop, the writing of a data element in memory involves a change of more bits and seems to require two clock pulses to stabilize the signal ..

VHDL code is attached

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    There are two possibilities for an 'X' condition in multisim.

    1. The signal is uninitialized, therefore the value is unknown and 'X'.

    2. The signal is in contention with one side driving a '1' and the other driving a '0'. Multisim can't determine the resulting state and indicates unknown ('X')

    You are having issues with contention. When we_synth is set to '1', you must wait one clock for your ram to place the data bus in high impedance before applying data.

    It may be a good idea to use a RAM with a data in port and a data out port instead of a single bidirectional data port. This way, you can avoid using 'Z' inside your design (for the RAM interface at least).

    Just so you know - the blue areas are times of high impedance. ('Z')
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thank you very much for your valuable informations.

    I've adjusted code and removed red warning in Modelsim with:

    
    case state is
    	-- ...
    	when sexec =>				
    		-- Read data
    		case data(7 downto 6) is
    			-- ...
    			-- Store
    			when "01" => 
    				we 	<= '1';					
    				addr 	<= data(5 downto 0);							
    				state <= sstore;
    			-- ...
    		end case;						
    	when sstore =>
    		-- write to memory, data is ready next clock								
    		data 	<= reg;
    		state <= sfetch;
    	when others => null;
    end case;
    

    I just moved:

    data <= reg;

    In the state sstore.

    So using high impedance Z signals in design is a worst practice?

    Thank you
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    High impedance should only be used on external pins when it is required (usually on a bidirectional bus).

    On internal signals the FPGA hardware isn't capable of putting a line in high impedance, so if you use it the synthesizer will change it to OR gates. It is absolutely possible to use it inside an FPGA design but it is considered bad practise because it doesn't correspond to the generated hardware.