微电子课程设计.docx

上传人:b****2 文档编号:23036905 上传时间:2023-04-30 格式:DOCX 页数:18 大小:16.75KB
下载 相关 举报
微电子课程设计.docx_第1页
第1页 / 共18页
微电子课程设计.docx_第2页
第2页 / 共18页
微电子课程设计.docx_第3页
第3页 / 共18页
微电子课程设计.docx_第4页
第4页 / 共18页
微电子课程设计.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

微电子课程设计.docx

《微电子课程设计.docx》由会员分享,可在线阅读,更多相关《微电子课程设计.docx(18页珍藏版)》请在冰豆网上搜索。

微电子课程设计.docx

微电子课程设计

1.流水灯实验

2.出租车计价器

3.交通灯实验

4.乘法器实验

1.moduletop(clk,t,out);

outputwire[0:

2]out;

inputclk;

input[1:

0]t;

wireoutclk;

div#1000mydiff(outclk,t,clk);

jishumyjishu(out,outclk);

endmodule

 

modulediv(outclk,t,clk);

outputregoutclk;

input[1:

0]t;

inputclk;

parametercount=1000;

integern=0,m=0;

initial

outclk=1;

always@(t)

case(t)

2'b00:

m=count;

2'b01:

m=2*count;

2'b10:

m=3*count;

2'b11:

m=4*count;

default:

m=count;

endcase

always@(edgeclk)

begin

if(n

elseif(n==m)

begin

outclk=~outclk;

n=0;

end

end

endmodule

modulejishu(out,clk);

outputreg[2:

0]out;

inputclk;

integerq=0;

always@(posedgeclk)

begin

q=q+1;

case(q)

1:

out=3'b100;

2:

out=3'b010;

3:

out=3'b001;

4:

out=3'b110;

5:

out=3'b011;

6:

out=3'b101;

7:

out=3'b111;

8:

begin

out=3'b000;

q=0;

end

default:

q=0;

endcase

end

endmodule

 

2.

moduletop(start,pause,stop,clk,display);

output[14:

0]display;

inputstart,stop,pause,clk;

wireclkd,clkt;

wire[13:

0]out;

wire[13:

0]outp;

wire[15:

0]money;

wire[15:

0]distance;

wirep_s;

assignp_s=~pause;

div#1000mydiv1(clkd,clk,stop);

div#1000mydiv2(clkt,clk,p_s);

jifeimyjifeei(out,outp,start,stop,pause,clkd,clkt);

bcdmybcd(out,money);

bcdmybcd2(outp,distance);

dongtaimydongtai(display,distance,money,clk);

endmodule

modulejifei(out,outp,restart,stop,pause,clkd,clkt);

outputreg[0:

13]out;

outputreg[0:

13]outp;

inputclkd,clkt;

inputrestart,stop,pause;

integerp=0,t=0;

always@(restart,posedgeclkd)

begin

if((!

pause)&&(!

stop))

begin

p=p+1;

if(p<6)out=1000;

elseif(p>5)out=out+140;

if(p>5&&out>5000)out=out+70;

end

if(restart==1)

begin

p=0;

out=14'b0000_0000_0000_00;

end

outp=p;

end

always@(posedgeclkt)

//begin

//if(pause)

begin

t=t+1;

if(t==3)

begin

out=out+50;

t=0;

end

end

//end

endmodule

modulediv(oclk,clk,rst);

outputregoclk;

inputclk,rst;

integerp=0;

parameterCOUNT=1000;

initial

oclk=1'b1;

always@(edgeclk)

begin

if(!

rst)

begin

p=p+1;

if(p==COUNT)

begin

oclk=~oclk;

p=0;

end

end

else

p=0;

end

endmodule

 

modulebcd(in,out);

input[13:

0]in;

output[15:

0]out;

reg[13:

0]bin;

reg[15:

0]result;

always@(in)

begin

result=16'b0;

bin=in;

repeat(13)

begin

result[0]=bin[13];

if(result[3:

0]>4)

result[3:

0]=result[3:

0]+4'd3;

if(result[7:

4]>4)

result[7:

4]=result[7:

4]+4'd3;

if(result[11:

8]>4)

result[11:

8]=result[11:

8]+4'd3;

if(result[15:

12]>4)

result[15:

12]=result[15:

12]+4'd3;

result=result<<1;

bin=bin<<1;

end

result[0]=bin[13];

end

assignout=result;

endmodule

//**.**##

moduledongtai(out,ind16,inm16,clk);

output[14:

0]out;

input[15:

0]ind16;

input[15:

0]inm16;

inputclk;

reg[14:

0]ott;

reg[3:

0]inn;

integeri=1;

initial

ott=13'b1;

always@(ind16,inm16,posedgeclk)

begin

case(i)

1:

begin

inn=inm16[15:

12];

ott[14:

8]=7'b1000_000;

end

2:

begin

inn=inm16[11:

8];

ott[14:

8]=7'b0100_000;

end

3:

begin

inn=4'b1111;

ott[14:

8]=7'b0010_000;

end

4:

begin

inn=inm16[7:

4];

ott[14:

8]=7'b0001_000;

end

5:

begin

inn=inm16[3:

0];

ott[14:

8]=7'b0000_100;

end

6:

begin

inn=ind16[7:

4];

ott[14:

8]=7'b0000_010;

end

7:

begin

inn=ind16[3:

0];

ott[14:

8]=7'b0000_001;

i=0;

end

endcase

case(inn)

4'b0000:

ott[7:

0]=8'b11111100;//0

4'b0001:

ott[7:

0]=8'b01100000;//1

4'b0010:

ott[7:

0]=8'b11011010;//2

4'b0011:

ott[7:

0]=8'b11110010;//3

4'b0100:

ott[7:

0]=8'b01100110;//4

4'b0101:

ott[7:

0]=8'b10110110;//5

4'b0110:

ott[7:

0]=8'b10111110;//6

4'b0111:

ott[7:

0]=8'b11100000;//7

4'b1000:

ott[7:

0]=8'b11111110;//8

4'b1001:

ott[7:

0]=8'b11110110;//9

4'b1111:

ott[7:

0]=8'b00000001;//.

default:

ott=8'b1111_1111;

endcase

i=i+1;

end

assignout=ott;

endmodule

3.modulejtd(z,g,c,clk,reset);

outputreg[2:

0]z,g;

inputc;

inputclk;

inputreset;

rege,f,s;

integercountg=0,countz=0;

always@(posedgeclk)

begin

if(reset==1)

begin

z=3'b001;g=3'b100;countz=0;countg=0;

end

else

begin

if(c==0)

begin

z=3'b001;

g=3'b100;

countg=0;

if(countz<16)

countz=countz+1;

end

else

begin

if(z!

=3'b100)

begin

if(countz<16)

countz=countz+1;

elseif(countz<20)

begin

z=3'b010;

countz=countz+1;

end

else

begin

z=3'b100;

countz=0;

g=3'b001;

end

end

else

if(g!

=3'b100)

begin

if(countg>19)

begin

g=3'b100;

countg=0;

z=3'b001;

end

elseif(countg>15)

begin

g=3'b010;

countg=countg+1;

end

elsecountg=countg+1;

end

end

end

end

endmodule

4.

moduletop(in1,in2,outd,restart,clk);

inputrestart;

input[7:

0]in1,in2;

inputclk;

output[12:

0]outd;

wire[19:

0]outbcd;

wire[15:

0]binary;

mulmymul(in1,in2,binary,restart);

bcdmybcd(binary,outbcd);

dongtaimydongtai(outd,outbcd,clk);

endmodule

modulemul(in1,in2,out,restart);

output[15:

0]out;

input[7:

0]in1;

input[7:

0]in2;

inputrestart;

reg[15:

0]add;

always@(in1,in2,restart)

begin

if(restart==1)

add=16'b0;

else

begin

if(in2[0]==1)

add={8'b0,in1[7:

0]};

else

add=16'b0;

if(in2[1]==1)

add=add+{7'b0,in1[7:

0],1'b0};

if(in2[2]==1)

add=add+{6'b0,in1[7:

0],2'b0};

if(in2[3]==1)

add=add+{5'b0,in1[7:

0],3'b0};

if(in2[4]==1)

add=add+{4'b0,in1[7:

0],4'b0};

if(in2[5]==1)

add=add+{3'b0,in1[7:

0],5'b0};

if(in2[6]==1)

add=add+{2'b0,in1[7:

0],6'b0};

if(in2[7]==1)

add=add+{1'b0,in1[7:

0],7'b0};

end

end

assignout=add;

endmodule

modulebcd(binary,bcd);

input[15:

0]binary;

output[19:

0]bcd;

reg[15:

0]bin;

reg[19:

0]result;

always@(binary)

begin

result=20'b0;

bin=binary;

repeat(15)

begin

result[0]=bin[15];

if(result[3:

0]>4)

result[3:

0]=result[3:

0]+4'd3;

if(result[7:

4]>4)

result[7:

4]=result[7:

4]+4'd3;

if(result[11:

8]>4)

result[11:

8]=result[11:

8]+4'd3;

if(result[15:

12]>4)

result[15:

12]=result[15:

12]+4'd3;

if(result[19:

16]>4)

result[19:

16]=result[19:

16]+4'd3;

result=result<<1;

bin=bin<<1;

end

result[0]=bin[15];

end

assignbcd=result;

endmodule

moduledongtai(outd,in20,clk);

output[12:

0]outd;

input[19:

0]in20;

inputclk;

reg[12:

0]ott;

reg[3:

0]inn;

integeri=1;

initial

ott=13'b1;

always@(in20,posedgeclk)

begin

case(i)

1:

begin

inn=in20[19:

16];

ott[12:

8]=5'b10000;

end

2:

begin

inn=in20[15:

12];

ott[12:

8]=5'b01000;

end

3:

begin

inn=in20[11:

8];

ott[12:

8]=5'b00100;

end

4:

begin

inn=in20[7:

4];

ott[12:

8]=5'b00010;

end

5:

begin

inn=in20[3:

0];

ott[12:

8]=5'b00001;

i=0;

end

endcase

i=i+1;

case(inn)

4'b0000:

ott[7:

0]=8'b11111100;//0

4'b0001:

ott[7:

0]=8'b01100000;//1

4'b0010:

ott[7:

0]=8'b11011010;//2

4'b0011:

ott[7:

0]=8'b11110010;//3

4'b0100:

ott[7:

0]=8'b01100110;//4

4'b0101:

ott[7:

0]=8'b10110110;//5

4'b0110:

ott[7:

0]=8'b10111110;//6

4'b0111:

ott[7:

0]=8'b11100000;//7

4'b1000:

ott[7:

0]=8'b11111110;//8

4'b1001:

ott[7:

0]=8'b11110110;//9

default:

ott=8'b1111_1111;

endcase

end

assignoutd=ott;

endmodule

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 广告传媒

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1