菜鸟求助verilog问题
时间:10-02
整理:3721RD
点击:
要用verilog要实现步进电机的四细分驱动芯片是18245的程序如下其中AD_RP是输入信号由单片机实现 am bm是输出接到驱动芯片的但是程序出错还请各位高手帮忙
module bujintest(AD_RP,am,bm);
input[7:0] AD_RP;
output[3:0] am;
output[3:0] bm;
always @ (AD_RP)
begin
case(AD_RP)
8'b01111111: am<=4'b1111; bm<=4'b0000;
8'b10111111: am<=4'b1110; bm<=4'b0110;
8'b11011111: am<=4'b1011; bm<=4'b1011;
8'b11101111: am<=4'b0110; bm<=4'b1110;
8'b11110111: am<=4'b0000; bm<=4'b1111;
8'b11111011: am<=4'b0110; bm<=4'b1110;
8'b11111101: am<=4'b1011; bm<=4'b1011;
8'b11111110: am<=4'b1110; bm<=4'b0110;
default:am<=4'b0000;bm<=4'b0000;
endcase
end
endmodule
谢谢各位!
quartusii编译出了好多错
module bujintest(AD_RP,am,bm);
input[7:0] AD_RP;
output[3:0] am;
output[3:0] bm;
always @ (AD_RP)
begin
case(AD_RP)
8'b01111111: am<=4'b1111; bm<=4'b0000;
8'b10111111: am<=4'b1110; bm<=4'b0110;
8'b11011111: am<=4'b1011; bm<=4'b1011;
8'b11101111: am<=4'b0110; bm<=4'b1110;
8'b11110111: am<=4'b0000; bm<=4'b1111;
8'b11111011: am<=4'b0110; bm<=4'b1110;
8'b11111101: am<=4'b1011; bm<=4'b1011;
8'b11111110: am<=4'b1110; bm<=4'b0110;
default:am<=4'b0000;bm<=4'b0000;
endcase
end
endmodule
谢谢各位!
quartusii编译出了好多错
always语句里被赋值的必须是reg型
所以把am bm该为reg型
另外最好每个always里只对一个参数赋值
再增加一点,块语句begin......end在每个分支上要用
非常感谢楼上的 ,问题已经解决,谢谢高手呵呵!