为什么单个
仿真都是正确的,但是连起来nimei中计数值不对而且输入复位信号也不复位啊,
- module jishu (clk, rst,q,mh,ml,en);
- input clk,rst,en;
- input [1:0]mh;
- input [7:0]ml;
- output q;
- reg q;
- reg[7:0]countl;
- reg[1:0]counth;
- always @(posedge clk or negedge rst )
- begin
-
- if(!rst)
- begin
- countl<=8'b00000000;
- counth<=2'b00;
- end
- else
- begin
- if(!en)
- begin
-
- if(counth[1:0]>=mh)
- begin
- if(countl[7:0]==ml)
- begin
- q<=~q;
- countl<=8'b00000000;
- counth<=2'b00;
- end
- else
- countl<=countl+8'b00000001;
- end
- else
- begin
- if(countl==8'b11111111)
- begin
- countl<=8'b00000000;
- counth<=counth+2'b01;
- end
- else
- countl<=countl+8'b00000001;
-
-
- end
- end
- end
-
- end
- endmodule
- module nimei(clk ,en ,countl,counth,choose,rst);
- input clk,en,rst;
- input [1:0]choose;
- output [7:0]countl;
- output [1:0]counth;
- reg[7:0]countl;
- reg[1:0]counth;
- parameter zb=2'b10;
- always @(posedge clk or negedge rst)
- begin
- if(!rst)
- begin
- countl<=8'b11110101;
- counth<=2'b01;
- end
- else
- begin
- if(!en)
- begin
- if(choose==zb)
- begin
- if(counth<=2'b00)
- begin
- if(countl<=8'b10001100)
- begin
- countl<=8'b10001100;
- counth<=2'b00;
- end
- else
- countl<=countl-8'b00000100;
-
- end
- else
- begin
- if(countl==8'b00000000)
- begin
- counth<=counth-2'b01;
- countl<=8'b11111011;
- end
- else if(countl==8'b00000001)
- begin
- counth<=counth-2'b01;
- countl<=8'b11111100;
- end
-
- else if(countl==8'b00000010)
- begin
- counth<=counth-2'b01;
- countl<=8'b11111101;
-
- end
- else if(countl==8'b00000011)
- begin
- counth<=counth-2'b01;
- countl<=8'b11111100;
- end
-
-
- else
- countl<=countl-8'b00000100;
-
- end
-
-
- end
-
-
-
- end
-
- end
- end
- endmodule
复制代码高手们帮忙看看啊
一周热门 更多>