四位乘法器代码

module lee(q,Dp,sel,k,z,clk);
output [6:0]q
output Dp;
output [2:0]sel;
input clk;
input [3:0]k,z;
integer i;
reg [3:0]a,b,c,out;
reg [6:0]q;
reg Dp;
reg [2:0]sel;
  alway@(k,z)
   begin
   i=0;
    begin i=k*z; end
   end
  always@(i)
   begin
   5:c=i/100;
   6:b=(i-c*100)/10;
   7:a=i-c*100-b*10;
   end
  alawys@(posedge clk)
   begin
   sel=sel+1;
    case(sel)
    0:out=10;
    1:out=10;
    2:out=10;
    3:out=10;
    4:out=10;
    5:begin if(out<=9) out=a; else out=10; end
    6:begin if(out<=9) out=b; else out=10; end
    7:begin if(out<=9) out=c; else out=10; end
    endcase
   end
  always@(out)
   begin
    case(out)
     0:q=8'b00111111;
     1:q=8'b00000110;
     2:q=8'b01011011;
     3:q=8'b01001111;
     4:q=8'b01100110;
     5:q=8'b00010001;
     6:q=8'b01111101;
     7:q=8'b00000111;
     8:q=8'b01111111;
     9:q=8'b01101111;
    10:q=8'b00000000;
 default:q=8'b00000000;
    endcase
  end
endmodule

 


 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值