Current location - Education and Training Encyclopedia - Graduation thesis - Graduation design thesis of perpetual calendar
Graduation design thesis of perpetual calendar
/*

This experiment has realized a digital clock that can display hours, minutes and seconds.

*/

Module clock (clk, rst, dataout, en);

Input clk, rst

output[7:0]data out;

reg[7:0]data out;

output[7:0]en;

reg[7:0]en;

reg[3:0]data out _ buf[7:0];

reg[25:0]CNT;

reg[ 15:0]CNT _ scan;

reg[3:0]data out _ code;

wire[5:0]cal; //carry all levels of signs.

Assignment cal[0]=(dataout_buf[0]==9)? 1:0;

Assign cal [1] = (cal [0] & & ampdataout_buf[ 1]==5)? 1:0;

Assign cal [2] = (cal [1]&; & ampdataout_buf[3]==9)? 1:0;

Assign cal [3] = (cal [2]&; & ampdataout_buf[4]==5)? 1:0;

Assign cal [4] = (cal [3]&; & ampdataout_buf[6]==9)? 1:0;

Assign cal [5] = (cal [3]&; & ampdata out _ buf[6]= = 2 & amp; & ampdataout_buf[7]== 1)? 1:0;

Always @ (posedgclk or negedgrst)

begin

If (! Rst) start

cnt _ scan & lt=0;

en & lt= 8 ' b 1 1 1 1 _ 1 1 10;

end

Otherwise start.

cnt _ scan & lt= CNT _ scan+ 1;

if(CNT _ scan = = 16 ' hffff)begin

en[7: 1]& lt; = en[6:0];

en[0]& lt; = en[7];

end

end

end

Always @ (*)

begin

Case (English)

8 ' b 1 1 1 1 _ 1 1 10:

data out _ code = data out _ buf[0];

8 ' b 1 1 1 1 _ 1 10 1:

data out _ code = data out _ buf[ 1];

8 ' b 1 1 1 1 _ 10 1 1:

data out _ code = data out _ buf[2];

8 ' b 1 1 1 1 _ 0 1 1 1:

data out _ code = data out _ buf[3];

8 ' b 1 1 10 _ 1 1 1 1:

data out _ code = data out _ buf[4];

8 ' b 1 10 1 _ 1 1 1 1:

data out _ code = data out _ buf[5];

8 ' b 10 1 1 _ 1 1 1 1:

data out _ code = data out _ buf[6];

8 ' b 0 1 1 1 _ 1 1 1 1:

data out _ code = data out _ buf[7];

Default value:

data out _ code = data out _ buf[0];

Close the case

end

Always @ (posedgclk or negedgrst)

begin

If (! rst)

cnt & lt=0;

else if(cnt! =40000000)

cnt & lt= CNT+ 1;

other

cnt & lt=0;

end

Always @ (pose clk or neg edge rst)// realizes counting and carry functions.

begin

If (! Rst) start

data out _ buf[0]& lt; =0;

data out _ buf[ 1]& lt; =0;

data out _ buf[2]& lt; = 15;

data out _ buf[3]& lt; =0;

data out _ buf[4]& lt; =0;

data out _ buf[5]& lt; = 15;

data out _ buf[6]& lt; =2;

data out _ buf[7]& lt; = 1;

end

Otherwise start.

If(cnt==26'd40000000)

If (! cal[0])

data out _ buf[0]& lt; = data out _ buf[0]+ 1;

Otherwise start.

data out _ buf[0]& lt; =0;

If (! cal[ 1])

data out _ buf[ 1]& lt; = data out _ buf[ 1]+ 1;

Otherwise start.

data out _ buf[ 1]& lt; =0;

If (! Karl [2])

data out _ buf[3]& lt; = data out _ buf[3]+ 1;

Otherwise start.

data out _ buf[3]& lt; =0;

If (! Karl [3])

data out _ buf[4]& lt; = data out _ buf[4]+ 1;

Otherwise start.

data out _ buf[4]& lt; =0;

If (! Carl [4])

data out _ buf[6]& lt; = data out _ buf[6]+ 1;

Otherwise start.

data out _ buf[6]& lt; =0;

If (! Karl [5])

data out _ buf[7]& lt; = data out _ buf[7]+ 1;

other

data out _ buf[7]& lt; =0;

end

end

end

end

end

end

end

end

Always @ (data output code)

begin

Case (data output code)

4 ft b0000:

data out = 8 ' b 1 100 _ 0000;

4'b000 1:

data out = 8 ' b 1 1 1 1 _ 100 1;

4'b00 10:

data out = 8 ' b 10 10 _ 0 100;

4'b00 1 1:

data out = 8 ' b 10 1 1 _ 0000;

4'b0 100:

data out = 8 ' b 100 1 _ 100 1;

4'b0 10 1:

data out = 8 ' b 100 1 _ 00 10;

4'b0 1 10:

data out = 8 ' b 1000 _ 00 10;

4'b0 1 1 1:

data out = 8 ' b 1 1 1 1 _ 1000;

4'b 1000:

data out = 8 ' b 1000 _ 0000;

Close the case

end

Terminal module

You can change it again. It shouldn't be difficult. Good luck!