101汇总程序题.docVIP

  • 28
  • 0
  • 约 48页
  • 2016-12-27 发布于重庆
  • 举报
1.用verilog中case语句设计一个3-8译码器 答案:module decode3-8(G1,Y,G2,A,G3); input G1,G2,G3; wire G1,G2,G3; input [2:0] A; wire [2:0]A; output [7:0]Y; reg [7:0]Y; alway@(A,G1,G2,G3) begin S=G2!G3; if(G1==0) Y=8’ else case(A) 3抌001:Y=8 3抌010:Y=8 3抌011:Y=8 3抌100:Y=8 3抌101:Y=8 3抌110:Y=8 3抌111:Y=8 default:Y=8抌xxxxxxxx; endcase end endmodule 2. 用verilog语言编写一个二进制半减器 答案: module suber(x,y,diff,out); input x,y; output diff,out; assign diff=x^y; assign out=(~x)y; endmodule 3. 用verilog语言编写一个4选1多路选择器 答案:module mux(A,B,C,D,S0,S1,S2,S3,Y); output Y; input A,B,C,D; input S0,S1,S2,S3; reg Y; always@(A,B,C,S0,S1,S2,S3)begin if(S0==0) Y=A; else if(S1==0) Y=B; else if(S2==0) Y=C; else if(S3==0) Y=D; end endmodule 4. 用verilog语言设计数据比较器 答案:module compare(x,y,xgy,xsy,xey); input [width-1:0] x,y; output xgy,xsy,xey; reg xgy,xsy,xey; paramer width=8; always@(x or y) begin if(x==y) xey=0; else xey=0; if(xy) xgy=1; else xgy=0; if(xy) xsy=1; else xsy=0; end endmodule 5. 用Verilog HDL来描述乘法器 答案: module mult(x,y,product); input [3:0] x,y; output [7:0] product; assign product=x*y; endmodule 6.自己设计一款数据锁存器(8位输入端Q,8位输出端D)编写完整程序。 module shujusuocunqi(Q,D,OE,G); output [7:0]Q; reg[7:0]Q; input [7:0]D; input OE,G; always@(*) (-----------------) (-----------------) (-----------------) (-----------------) (-----------------) (-----------------) (-----------------) endmodu

文档评论(0)

1亿VIP精品文档

相关文档