Forum Discussion

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

help me complete the simple design

I want design a time recorder that can recored servral time stamp by seconds.4 leds for display,1 for display the counter or a serial number range 0-9,and this means what i design can recored 10 recoreds at most.Left 3leds display seconds and change every seconds.4 bouttons fuctions as fellow:

'PRE NEX PLUSONE DO',all of them is :IN STD_LOGIC.

Firstly push the 'DO' boutton and ths timmer start to run while the 3leds begin to change with seconds,later,at a time,we can pust 'PLUSONE',then current time will be recored to a SIGNAL named 'TR1',the fellow push will generate 'TR2',at most 'TR10'.OR before 10 times push on 'PLUSONE',We push DO,the timmer will stop.

Regardless which way to stop the recored process,the 3leds will be static.then it reachs a state.Then we can push 'PRE' or 'NEX' to view the recored time stamp,the first led display the id with antother 3leds display related time by seconds.

I have write some codes,event not correct enought,it can express my thought better:

Library IEEE;

USE IEEE.std_logic_1164.all;

ENTITY CLK_CONTROL IS

PORT(DO,CLK_IN:IN STD_LOGIC;

CLK_OUT:OUT STD_LOGIC);

END CLK_CONTROL;

ARCHITECTURE BEHAV OF CLK_CONTROL IS BEGIN

--PROCESS (DO) BEGIN

PROCESS (DO,CLK_IN) BEGIN

IF DO='1' THEN

CLK_OUT<=CLK_IN;

ELSE

CLK_OUT<='0';

END IF;

END PROCESS;

END BEHAV;

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL;

USE IEEE.STD_LOGIC_UNSIGNED.ALL;

USE IEEE.STD_LOGIC_ARITH.ALL;

ENTITY MUL_TIME_REC IS

PORT (CLK,DO,PLUSONE,PRE,NEX: IN STD_LOGIC;

N,S1,S2,S3:BUFFER STD_LOGIC_VECTOR(3 DOWNTO 0)

);

END MUL_TIME_REC;

ARCHITECTURE BEHAV OF MUL_TIME_REC IS

SIGNAL CLKN:STD_LOGIC;

--SIGNAL COUNT:INTEGER RANGE 0 TO 999;

--SIGNAL S1V,S2V,S3V:STD_LOGIC_VECTOR(3 DOWNTO 0);

SIGNAL TR1,TR2,TR3,TR4,TR5,TR6,TR7,TR8,TR9,TR10:STD_LOGIC_VECTOR(11 DOWNTO 0);

COMPONENT CLK_CONTROL is

PORT(DO,CLK_IN:IN STD_LOGIC;

CLK_OUT:OUT STD_LOGIC);

END COMPONENT CLK_CONTROL;

BEGIN

u1:CLK_CONTROL PORT MAP(CLK_IN=>CLK,DO=>DO,CLK_OUT=>CLKN);

PROCESS (DO) BEGIN

IF rising_edge(DO) THEN

N<="0000";

END IF;

END PROCESS;

PROCESS(CLKN) BEGIN

IF (CLKN'EVENT AND CLKN='1') THEN

N<=N+1;

END IF;

END PROCESS;

PROCESS(PLUSONE) BEGIN

CASE N IS

WHEN "0001"=>TR1<=S1&S2&S3;

WHEN "0010"=>TR2<=S1&S2&S3;

WHEN "0011"=>TR3<=S1&S2&S3;

WHEN "0100"=>TR4<=S1&S2&S3;

WHEN "0101"=>TR5<=S1&S2&S3;

WHEN "0110"=>TR6<=S1&S2&S3;

WHEN "0111"=>TR7<=S1&S2&S3;

WHEN "1000"=>TR8<=S1&S2&S3;

WHEN "1001"=>TR9<=S1&S2&S3;

WHEN "1010"=>TR10<=S1&S2&S3;

WHEN OTHERS=>NULL;

END CASE;

N<=N+1;--CONV_STD_LOGIC_VECTOR(CONV_INTEGER(N)+1,4);

END PROCESS;

PROCESS(PRE,NEX,N) BEGIN

IF rising_edge(PRE) THEN

N<=N-1;--CONV_STD_LOGIC_VECTOR(CONV_INTEGER(N)-1,4);

END IF;

IF rising_edge(NEX) THEN

N<=N+1;--CONV_STD_LOGIC_VECTOR(CONV_INTEGER(N)+1,4);

END IF;

CASE N IS

WHEN "0001"=>S1<=TR1(3 DOWNTO 0);S2<=TR1( 7 DOWNTO 4);S3<=TR1(11 DOWNTO 8);

WHEN "0010"=>S1<=TR2(3 DOWNTO 0);S2<=TR2( 7 DOWNTO 4);S3<=TR2(11 DOWNTO 8);

WHEN "0011"=>S1<=TR3(3 DOWNTO 0);S2<=TR3( 7 DOWNTO 4);S3<=TR3(11 DOWNTO 8);

WHEN "0100"=>S1<=TR4(3 DOWNTO 0);S2<=TR4( 7 DOWNTO 4);S3<=TR4(11 DOWNTO 8);

WHEN "0101"=>S1<=TR5(3 DOWNTO 0);S2<=TR5( 7 DOWNTO 4);S3<=TR5(11 DOWNTO 8);

WHEN "0110"=>S1<=TR6(3 DOWNTO 0);S2<=TR6( 7 DOWNTO 4);S3<=TR6(11 DOWNTO 8);

WHEN "0111"=>S1<=TR7(3 DOWNTO 0);S2<=TR7( 7 DOWNTO 4);S3<=TR7(11 DOWNTO 8);

WHEN "1000"=>S1<=TR8(3 DOWNTO 0);S2<=TR8( 7 DOWNTO 4);S3<=TR8(11 DOWNTO 8);

WHEN "1001"=>S1<=TR9(3 DOWNTO 0);S2<=TR9( 7 DOWNTO 4);S3<=TR9(11 DOWNTO 8);

WHEN "1010"=>S1<=TR10(3 DOWNTO 0);S2<=TR10( 7 DOWNTO 4);S3<=TR10(11 DOWNTO 8);

WHEN OTHERS=>NULL;

END CASE;

END PROCESS;

END BEHAV;

My email is cpuzer(shift+2)gmail.com,hope your contact.BY the way,english is not my mother lang,so forgive my stuppid statements.

Attachements is MAX+PLUS proecject archivements.
No RepliesBe the first to reply