FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Case?

Altera_Forum
Honored Contributor II
805 Views

Can anyone help me shorten this if into a case ? 

Is it smart? 

-- Signaltap end PROCESS (CLOCK_50, KEY(0), KEY(1)) BEGIN IF (CLOCK_50'EVENT AND CLOCK_50 = '1') THEN -- Trigger Condition IF KEY(0) = '0' AND KEY(1) = '0' THEN q <= q; ELSE IF KEY(0) = '1' AND KEY(1) = '0' THEN q <= '1'; -- Set ELSE IF KEY(0) = '0' AND KEY(1) = '1' THEN q <= '0'; -- Reset END IF; END IF; END IF; END IF; END PROCESS;
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
87 Views

PROCESS (CLOCK_50)  

BEGIN  

IF (CLOCK_50'EVENT AND CLOCK_50 = '1') THEN -- Trigger Condition  

IF KEY(0) = '1' AND KEY(1) = '0' THEN  

q <= '1'; -- Set  

ELSIF KEY(0) = '0' AND KEY(1) = '1' THEN  

q <= '0'; -- Reset  

ELSE 

null; 

END IF;  

END IF;  

END PROCESS;
Altera_Forum
Honored Contributor II
87 Views

 

--- Quote Start ---  

Can anyone help me shorten this if into a case ? 

--- Quote End ---  

 

PROCESS (CLOCK_50) -- Key() should not be in the list , KEY(0), KEY(1)) variable KeyCode: natural range 0 to 3; BEGIN IF (CLOCK_50'EVENT AND CLOCK_50 = '1') THEN -- Trigger Condition -- Assuming that Key is a std_logic_vector and possibly longer than -- just two bits. KeyCode := to_integer(unsigned(Key(1 downto 0)); case KeyCode is when 1 => q <= '1'; -- Set when 2 => q <= '0'; -- Reset when others => null; end case; END IF; END PROCESS; 

 

--- Quote Start ---  

 

Is it smart? 

 

--- Quote End ---  

 

No it is not smart...people can be smart, but 'it' cannot. 

 

Kevin Jennings
Reply