- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Altera Friends,
I have an issue with design of clock. I have written a program for a clock to count from 0 to 9 and returns to zero. I use a switch as start/stop as in std_logic and i want a logic that I can use that when i press button ones, it will toggle between 1 and 0 so that the button can perform the two tasks start and stop. I will appreciate your urgent reply. Thanks.Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
please post the code you have already done with specific questions about what the problem is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I correctly understood your needs, you can try changing your code this way:
SIGNAL 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;
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
still not working

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page