马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
1,公式化简然后画电路图,要求用尽量少的门(简单) 2,序列检测,用状态机实现测出0121则输出1,否则输出为0 3,就题二写testbench 4,改错并优化,代码如下 Module U(a,b,c,d,e,sel,out); Input [15:0] a,b,c,d,e; Input [1:0] sel; Output [15:0] out; wire [31:0] out; always@(a or b or c or d or sel or out)begin case(sel) 2’b00 ut=a*b; 2’b01 ut=c*d+c; 2’b10 ut=(e+1)/4; Endcase End endmodule ----------------------------------我改的---大家帮我看看改得行不行--- Module U(a,b,c,d,e,sel,out); Input [15:0] a,b,c,d,e; Input [1:0] sel; Output [31:0] out; Wire [16:0]; Reg [31:0] out; Assign m = e+1; always@(a or b or c or d or e or sel or out)begin case(sel) 2’b00:out<=a&b[0]+{a,0} & b[1]+{a,2{0}} & b[2]+{a,3{0}} & b[3]+{a,4{0}} & b[4]+{a,5{0}} & b[5]+{a,6{0}} & b[6]+{a,7{0}} & b[7]+{a,8{0}} & b[8]+{a,9{0}} & b[9]+{a,10{0}} & b[10]+{a,11{0}} & b[11]+{a,12{0}} & b[12]+{a,13{0}} & b[13]+{a,14{0}} & b[14]+{a,15{0}} & b[15]; 2’b01:out<=c+d&c[0]+{d,0}& c[1]+{d,2{0}} & c[2]+{d,3{0}} & c[3]+{d,4{0}} & c[4]+{d,5{0}} & c[5]+{d,6{0}} & c[6]+{d,7{0}} & c[7]+{d,8{0}} & c[8]+{d,9{0}} & c[9]+{d,10{0}} & c[10]+{d,11{0}} & c[11]+{d,12{0}} & c[12]+{d,13{0}} & c[13]+{d,14{0}} & c[14]+{d,15{0}} & c[15]; 2’b10:out<={17{0},m[16:2]};//商的整数部分 2’b11:out<={30{0},m[1:0]};// 商的小数部分 Endcase End Endmodule 5,用perl或C实现二进制文件“binary.txt”,转化为十进制文件并保存到“decimal.txt”----不会,大家有谁会perl的,能否共享答案 |