|
//产生1hz的时钟信号
module div(clk_i,rst,clk_o);
input clk_i,rst;
output reg clk_o;
parameter m=50_000_000;
parameter n=24_999_999;
reg [25:0]cnt;
always @(posedge clk_i,negedge rst)
begin
if(!rst)
cnt<=26'b0;
else
begin
if(cnt==m-1)
cnt<=26'b0;
else
cnt<=cnt+26'b1;
end
end
always @(posedge clk_i,negedge rst)
begin
if(!rst)
clk_o<=0;
else
begin
if(cnt<=n)
clk_o<=1;
else
clk_o<=0;
end
end
endmodule
//数码管显示
module dis(dig,seg);
input [3:0]dig;
output reg [6:0]seg;
always @(dig)
begin
case(dig)
4'h0:seg=7'b1000000;
4'h1:seg=7'b0000110;
4'h2:seg=7'b0100100;
4'h3:seg=7'b0110000;
4'h4:seg=7'b0011001;
4'h5:seg=7'b0010010;
4'h6:seg=7'b0000010;
4'h7:seg=7'b1111000;
4'h8:seg=7'b0000000;
4'h9:seg=7'b0010000;
4'ha:seg=7'b1000000;
4'hb:seg=7'b0000110;
4'hc:seg=7'b0100100;
4'hd:seg=7'b0110000;
4'he:seg=7'b0011001;
4'hf:seg=7'b0010010;
endcase
end
endmodule
//顶层文件
module part2(clk_50,key0,hex0,hex1,hex2);
input clk_50,key0;
output [6:0]hex0,hex1,hex2;
wire clk_1hz;
reg [11:0]cnt;
parameter M=65535;
div u0(clk_50,rst,clk_1hz);
always @(posedge clk_1hz or negedge key0)
begin
if(!keyo)
cnt<=12'b0;
else
begin
if(cnt<=M)
cnt<=cnt+12'b1;
else
cnt<=12'b0;
end
end
always @(cnt)
begin
if(cnt[3:0]<=4'd9)
begin
dis h0(cnt[3:0],hex0);//出错
dis h1(cnt[7:4],hex1);//出错
if(cnt[7:4]<=4'd9)
begin
dis h1(cnt[7:4],hex1);//出错
dis h2(cnt[11:8],hex2);//出错
end
else
begin
dis h1(cnt[7:4],hex1);//出错
dis h2((cnt[11:8]+4'b1),hex2);//出错
end
end
else
begin
dis h0(cnt[3:0],hex0);//出错
dis h1((cnt[7:4]+4'b1),hex1);//出错
if((cnt[7:4]+4'b1)<=4'd9)
begin
dis h1((cnt[7:4]+4'b1),hex1);//出错
dis h2(cnt[11:8],hex2);//出错
end
else
begin
dis h1((cnt[7:4]+4'b1),hex1);//出错
dis h2((cnt[11:8]+4'b1),hex2);//出错
end
end
end
endmodule
上面这段代码用来实现三位BCD码计数器,最后一部分是顶层文件,在编译的时候,提示出错Error (10170): Verilog HDL syntax error at part2.v(105) near text "("; expecting ";"
,出错处在代码中已经标出,请问这该怎么改才能编译正确,谢谢 |
|