module xiyi(QP,cp,MUSIC,k,zheng,fan,rst,CLK,BCD1,BCD2,Segout, SG1,SG2,SG3,SG4,SG5,SG6);
input k,rst;
input cp;
input [7:0]QP;
input CLK;
input [3:0]BCD1,BCD2;
output [6:0]Segout;
output SG1,SG2,SG3,SG4,SG5,SG6;
output zheng,fan,MUSIC;
reg zheng = 1'b1;
reg fan = 1'b1;
reg MUSIC = 1'b1;
reg [7:0]cnt;
reg [7:0]count_ge;
reg [7:0]count_shi;
reg kai = 1'b1;
reg [3:0]Q,P,A,B;
reg [6:0] Segout;
reg [2:0] Count;
reg [3:0] Seg_in;
always @ (posedge cp) begin
if(~rst) begin
count_shi <= 8'h00;
count_ge <=8'h00;
kai <= 1'b1;
Q <= 4'd0;
P <= 4'd0;
B <= 4'd0;
A <= 4'd0;
MUSIC <= 1'b1;
zheng <= 1'b1;
fan <= 1'b1;
end
if(~k) begin
count_shi <= QP;
MUSIC <= 1'b1;
kai <= ~kai;
end
else if(k)
count_shi <= count_shi;
if(~kai) begin
count_ge <= count_ge - 1'b1;
if(count_ge[3:0] == 4'd0) begin
count_ge[3:0] <= 4'd9;
count_ge[7:4] <= count_ge[7:4] - 1'b1;
if(count_ge[7:4] == 4'd0) begin
count_shi[3:0] <= count_shi[3:0] - 1'b1;
count_ge[7:4] <= 4'd5;
if(count_shi[3:0] == 4'd0) begin
count_shi[7:4] <= count_shi[7:4] - 1'b1;
count_shi[3:0] <= 4'd9;
if(count_shi[7:4] == 4'd0)
count_shi[7:4] <= 4'd5;
end
end
end
end
if(~kai) begin
P <= count_shi[7:4];
Q <= count_shi[3:0];
if((count_ge < 8'h11) && (count_ge >= 8'h01) ) begin
zheng <= 1'b1;
fan <= 1'b1;
end
else if((count_ge > 8'h10) && (count_ge < 8'h31)) begin
zheng <= 1'b1;
fan <= 1'b0;
end
else if((count_ge > 8'h30) && (count_ge < 8'h41)) begin
zheng <= 1'b1;
fan <= 1'b1;
end
else if((count_ge > 8'h40) && (count_ge < 8'h60)) begin
zheng <= 1'b0;
fan <= 1'b1;
end
end
always @(posedge CLK)
case (Count)
3'b000: begin {SG1,SG2,SG3,SG4,SG5,SG6} = 6'b011111;
Seg_in = BCD1;
Count = Count+1;
end
3'b001: begin {SG1,SG2,SG3,SG4,SG5,SG6} = 6'b101111;
Seg_in = BCD2;
Count = Count+1;
end
3'b010: begin {SG1,SG2,SG3,SG4,SG5,SG6} = 6'b110111;
Seg_in = Q;
Count = Count+1;
end
3'b011: begin {SG1,SG2,SG3,SG4,SG5,SG6} = 6'b111011;
Seg_in = P;
Count = Count+1;
end
3'b100: begin {SG1,SG2,SG3,SG4,SG5,SG6} = 6'b111101;
Seg_in = A;
Count = Count+1;
end
3'b0101: begin {SG1,SG2,SG3,SG4,SG5,SG6} = 6'b111110;
Seg_in = B;
Count = 3'b000;
end
endcase
end
always @(Seg_in)
case (Seg_in)
4'b0000: Segout=7'b1000000; //0(40H)
4'b0001: Segout=7'b1111001; //1(79H)
4'b0010: Segout=7'b0100100; //2(24H)
4'b0011: Segout=7'b0110000; //3(30H)
4'b0100: Segout=7'b0011001; //4(19H)
4'b0101: Segout=7'b0010010; //5(12H)
4'b0110: Segout=7'b0000010; //6(02H)
4'b0111: Segout=7'b1111000; //7(78H)
4'b1000: Segout=7'b0000000; //8(00H)
4'b1001: Segout=7'b0010000; //9(10H)
endcase
endmodule
错误提示如下:Error (10170): Verilog HDL syntax error at xiyi.v(88) near text "always"; expecting ";", or "@", or "end", or an identifier ("always" is a reserved keyword ), or a system task, or "{", or a sequential statement
Error (10170): Verilog HDL syntax error at xiyi.v(116) near text "always"; expecting ";", or "@", or "end", or an identifier ("always" is a reserved keyword ), or a system task, or "{", or a sequential statement
此帖出自
小平头技术问答
一周热门 更多>