begin
count<=count+1'b1;
clk_4hz<=0;
end
else
begin
count<=0;
clk_4hz<=1;
end
end
endmodule
生成模块:
(2)扫描,控制速度:
modulesudu(clk,cnt);
inputclk;
outputcnt;
regcnt;
reg[15:
0]p;
always(posedgeclk)
begin
if(p==16'b1111111111111111)
begin
cnt<=1'b1;
p<=16'b0000000000000000;
end
else
begin
p<=p+16'b1;
cnt<=1'b0;
end
end
endmodule
生成模块:
(3)显示汉字模块:
modulexianshi(clk2,clk3,row,con,k);
inputclk2,clk3,k;
output[15:
0]row;
output[15:
0]con;
reg[15:
0]row;
reg[15:
0]con;
integercnt,b;
reg[15:
0]r[111:
0];
initial
begin
//中
r[0]<=16'b1111111111111111;
r[1]<=16'b1111111111111111;
r[2]<=16'b1111100000011111;
r[3]<=16'b1111101111011111;
r[4]<=16'b1111101111011111;
r[5]<=16'b1111101111011111;
r[6]<=16'b1111101111011111;
r[7]<=16'b1000000000000001;
r[8]<=16'b1111101111011111;
r[9]<=16'b1111101111011111;
r[10]<=16'b1111101111011111;
r[11]<=16'b1111101111011111;
r[12]<=16'b1111100000011111;
r[13]<=16'b1111111111111111;
r[14]<=16'b1111111111111111;
r[15]<=16'b1111111111111111;
//国
r[16]<=16'b1111111111111111;
r[17]<=16'b1111111111111111;
r[18]<=16'b1100000000000111;
r[19]<=16'b1101111111110111;
r[20]<=16'b1101011011010111;
r[21]<=16'b1101011011010111;
r[22]<=16'b1101011011010111;
r[23]<=16'b1101000000010111;
r[24]<=16'b1101011011010111;
r[25]<=16'b1101011011010111;
r[26]<=16'b1101001011010111;
r[27]<=16'b1101011011010111;
r[28]<=16'b1101111111110111;
r[29]<=16'b1100000000000111;
r[30]<=16'b1111111111111111;
r[31]<=16'b1111111111111111;
//石
r[32]<=16'b1111111111111111;
r[33]<=16'b1111111111111111;
r[34]<=16'b1110111111110111;
r[35]<=16'b1111011111110111;
r[36]<=16'b1111101111110111;
r[37]<=16'b1111110111110111;
r[38]<=16'b1110100001110111;
r[39]<=16'b1110111100110111;
r[40]<=16'b1110111101010111;
r[41]<=16'b1110111101100111;
r[42]<=16'b1110111101100111;
r[43]<=16'b1110000001110111;
r[44]<=16'b1111111111110111;
r[45]<=16'b1111111111110111;
r[46]<=16'b1111111111111111;
r[47]<=16'b1111111111111111;
//油
r[48]<=16'b1111111111111111;
r[49]<=16'b1111111111111111;
r[50]<=16'b1111111011101111;
r[51]<=16'b1000000111011111;
r[52]<=16'b1111101110111111;
r[53]<=16'b1111111111111111;
r[54]<=16'b1100000001111111;
r[55]<=16'b1101101101111111;
r[56]<=16'b1101101101111111;
r[57]<=16'b1100000000000111;
r[58]<=16'b1101101101111111;
r[59]<=16'b1101101101111111;
r[60]<=16'b1100000001111111;
r[61]<=16'b1111111111111111;
r[62]<=16'b1111111111111111;
r[63]<=16'b1111111111111111;
//大
r[64]<=16'b1111111111111111;
r[65]<=16'b1101111111111111;
r[66]<=16'b1110111111111111;
r[67]<=16'b1110111110111111;
r[68]<=16'b1111011110111111;
r[69]<=16'b1111101110111111;
r[70]<=16'b1111110010111111;
r[71]<=16'b1111111100001111;
r[72]<=16'b1111110010111111;
r[73]<=16'b1111101110111111;
r[74]<=16'b1111011110111111;
r[75]<=16'b1110111110111111;
r[76]<=16'b1110111111111111;
r[77]<=16'b1101111111111111;
r[78]<=16'b1111111111111111;
r[79]<=16'b1111111111111111;
//学
r[80]<=16'b1111111111111111;
r[81]<=16'b1111111111111111;
r[82]<=16'b1111111101111111;
r[83]<=16'b1111011110111111;
r[84]<=16'b1111011111011101;
r[85]<=16'b1111011011010011;
r[86]<=16'b1011011011011101;
r[87]<=16'b1000001011010011;
r[88]<=16'b1111010011011111;
r[89]<=16'b1111011011000111;
r[90]<=16'b1111011111011001;
r[91]<=16'b1111011101011111;
r[92]<=16'b1111111110011111;
r[93]<=16'b1111111111111111;
r[94]<=16'b1111111111111111;
r[95]<=16'b1111111111111111;
//中
r[96]<=16'b1111111111111111;
r[97]<=16'b1111111111111111;
r[98]<=16'b1111100000011111;
r[99]<=16'b1111101111011111;
r[100]<=16'b1111101111011111;
r[101]<=16'b1111101111011111;
r[102]<=16'b1111101111011111;
r[103]<=16'b1000000000000001;
r[104]<=16'b1111101111011111;
r[105]<=16'b1111101111011111;
r[106]<=16'b1111101111011111;
r[107]<=16'b1111101111011111;
r[108]<=16'b1111100000011111;
r[109]<=16'b1111111111111111;
r[110]<=16'b1111111111111111;
r[111]<=16'b1111111111111111;
end
always(posedgeclk3)
begin
if(k==0)
begin
if(b==95)
b<=0;
else
b<=b+1;
end
else
begin
if(b==0)
b<=95;
else
b<=b-1;
end
end
always(posedgeclk2)
begin
if(cnt==15)
begin
cnt<=0;
end
else
cnt<=cnt+1;
case(cnt)
0:
con<=16'b0000_0000_0000_0001;
1:
con<=16'b0000_0000_0000_0010;
2:
con<=16'b0000_0000_0000_0100;
3:
con<=16'b0000_0000_0000_1000;
4:
con<=16'b0000_0000_0001_0000;
5:
con<=16'b0000_0000_0010_0000;
6:
con<=16'b0000_0000_0100_0000;
7:
con<=16'b0000_0000_1000_0000;
8:
con<=16'b0000_0001_0000_0000;
9:
con<=16'b0000_0010_0000_0000;
10:
con<=16'b0000_0100_0000_0000;
11:
con<=16'b0000_1000_0000_0000;
12:
con<=16'b0001_0000_0000_0000;
13:
con<=16'b0010_0000_0000_0000;
14:
con<=16'b0100_0000_0000_0000;
15:
con<=16'b1000_0000_0000_0000;
endcase
//行使能
if(k==0)
begin
case(cnt)
0:
row<=r[b+0];
1:
row<=r[b+1];
2:
row<=r[b+2];
3:
row<=r[b+3];
4:
row<=r[b+4];
5:
row<=r[b+5];
6:
row<=r[b+6];
7:
row<=r[b+7];
8:
row<=r[b+8];
9:
row<=r[b+9];
10:
row<=r[b+10];
11:
row<=r[b+11];
12:
row<=r[b+12];
13:
row<=r[b+13];
14:
row<=r[b+14];
15:
row<=r[b+15];
endcase
end
elsebegin
case(cnt)
0:
row<=r[b-0];
1:
row<=r[b-1];
2:
row<=r[b-2];
3:
row<=r[b-3];
4:
row<=r[b-4];
5:
row<=r[b-5];
6:
row<=r[b-6];
7:
row<=r[b-7];
8:
row<=r[b-8];
9:
row<=r[b-9];
10:
row<=r[b-10];
11:
row<=r[b-11];
12:
row<=r[b-12];
13:
row<=r[b-13];
14:
row<=r[b-14];
15:
row<=r[b-15];
endcase
end
end
endmodule
生成模块:
电路的仿真:
分析与总结:
这次数点实习我去测试了俩次,第一次测试时,什么现象都没有,我回去后反复检查,程序都没有问题,后来我觉得可能是我生成模块时,全都放在一个文件夹里,混乱了。
所以我又重新生成模块,规规矩矩的连了一遍,第二次去测试时,成功了。
看着自己实验出来的效果真是特别的高兴。
通过这次课程设计,我学会了基本的的quartusⅡ操作,会自己编写简单的verilog程序。
最受益的是学会了如何将自己所学过的知识和查找的资料有机的融合在一起。
真是受益匪浅。
参考资料:
[1]Verilog数字系统设计教程(第2版)(夏宇闻,航空航天大学出版)
[2]VerilogHDL入门(第3版)
[3]数字电子技术基础(润华,于云华,中国石油大学,2008)