Forum Discussion
7 Replies
- Altera_Forum
Honored Contributor
please post the code you have already done with specific questions about what the problem is.
- Altera_Forum
Honored Contributor
PORT
( clOCK : IN STD_LOGIC; ce : IN STD_LOGIC; rst : IN STD_LOGIC; d1: BUFFER STD_LOGIC_VECTOR (3 DOWNTO 0); clk_2: OUT STD_LOGIC ); -- {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE! END mod_mod; -- Architecture Body ARCHITECTURE mod_mod_architecture OF mod_mod IS SIGNAL M: STD_LOGIC; BEGIN PROCESS (clock,rst,M) BEGIN IF (rst = '0') THEN d1 <= "0000"; ELSIF (clOCK 'EVENT AND clOCK='1') THEN IF (ce = '0') THEN d1<= "0000" ; ELSE d1<= d1 + '1'; M<= '0'; END IF; IF d1= "1001" THEN d1<= "0000"; M<= '1'; END IF; END IF; clk_2<=M; END PROCESS; end mod_mod; I want ce to perform the function of start and stop.I want it to be like if i press ce switch it should change the logic from 1 to 0 to purse and for the next state to start after pressing same ce switch. - Altera_Forum
Honored Contributor
Hi Ebony,
Not sure what you are referring to here. If you wanted a CE using a KEY, you could simply read the KEY press (remember in DE2 boards its active LOW) and feed it as an enable input in a tri-state buffer. When key isnt pressed the clock output will be driven to Z. Not sure if this is what you wanted!? BP - Altera_Forum
Honored Contributor
if i press the switch button on the altera board down without removing hand, it will purse or stop. if i rmove my hand from the button, it will start counting. I want the state to change such that if i press the switch button and remove my hand it will purse or stop and if i press the switch button and remove my hand next it should start counting.
ce i assigned to start/stop switch. hope you understand it? - Altera_Forum
Honored Contributor
if i press the switch button on the altera board down without removing hand, it will purse or stop. if i rmove my hand from the button, it will start counting. I want the state to change such that if i press the switch button and remove my hand it will purse or stop and if i press the switch button and remove my hand next it should start counting.
ce is assigned as start/stop switch button. hope you understand it? - Altera_Forum
Honored Contributor
If I correctly understood your needs, you can try changing your code this way:
RegardsSIGNAL M: STD_LOGIC; SIGNAL run: STD_LOGIC; SIGNAL last_ce: STD_LOGIC; PROCESS (clock,rst,M) BEGIN IF (rst = '0') THEN d1 <= "0000"; run <= '0'; last_ce <= ce; ELSIF (clOCK 'EVENT AND clOCK='1') THEN IF (run='1') THEN d1<= d1 + '1'; M <= '0'; END IF; IF d1= "1001" THEN d1<= "0000"; M <= '1'; END IF; IF (ce='1' and last_ce='0') run <= not run; END IF; END IF; clk_2<=M; END PROCESS; - Altera_Forum
Honored Contributor
still not working