|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
Warning (12019): Can't analyze file -- file moundetector_tb.v is missing
Warning (10036): Verilog HDL or VHDL warning at moundetector.v(13): object "i" assigned a value but never read
Warning (10036): Verilog HDL or VHDL warning at moundetector.v(13): object "j" assigned a value but never read
Warning (10762): Verilog HDL Case Statement warning at moundetector.v(28): can't check case statement for completeness because the case expression has too many possible states
Warning (10762): Verilog HDL Case Statement warning at moundetector.v(64): can't check case statement for completeness because the case expression has too many possible states
Warning (10240): Verilog HDL Always Construct warning at moundetector.v(15): inferring latch(es) for variable "markdown", which holds its previous value in one or more paths through the always construct
Warning (13024): Output pins are stuck at VCC or GND
Warning (13410): Pin "Counter[0]" is stuck at VCC
Warning (13410): Pin "Counter[1]" is stuck at GND
Warning (13410): Pin "Counter[2]" is stuck at GND
Warning (13410): Pin "Counter[3]" is stuck at GND
Warning (13410): Pin "Counter[4]" is stuck at GND
Warning (13410): Pin "Counter[5]" is stuck at GND
Warning (13410): Pin "Counter[6]" is stuck at GND
Warning (13410): Pin "Counter[7]" is stuck at GND
Warning (21074): Design contains 66 input pin(s) that do not drive logic
Warning (15610): No output dependent on input pin "IN_Up[0]"
Warning (15610): No output dependent on input pin "IN_Up[1]"
Warning (15610): No output dependent on input pin "IN_Up[2]"
Warning (15610): No output dependent on input pin "IN_Up[3]"
Warning (15610): No output dependent on input pin "IN_Up[4]"
Warning (15610): No output dependent on input pin "IN_Up[5]"
Warning (15610): No output dependent on input pin "IN_Up[6]"
Warning (15610): No output dependent on input pin "IN_Up[7]"
Warning (15610): No output dependent on input pin "IN_Up[8]"
Warning (15610): No output dependent on input pin "IN_Up[9]"
Warning (15610): No output dependent on input pin "IN_Up[10]"
Warning (15610): No output dependent on input pin "IN_Up[11]"
Warning (15610): No output dependent on input pin "IN_Up[12]"
Warning (15610): No output dependent on input pin "IN_Up[13]"
Warning (15610): No output dependent on input pin "IN_Up[14]"
Warning (15610): No output dependent on input pin "IN_Up[15]"
Warning (15610): No output dependent on input pin "IN_Up[16]"
Warning (15610): No output dependent on input pin "IN_Up[17]"
Warning (15610): No output dependent on input pin "IN_Up[18]"
Warning (15610): No output dependent on input pin "IN_Up[19]"
Warning (15610): No output dependent on input pin "IN_Up[20]"
Warning (15610): No output dependent on input pin "IN_Up[21]"
Warning (15610): No output dependent on input pin "IN_Up[22]"
Warning (15610): No output dependent on input pin "IN_Up[23]"
Warning (15610): No output dependent on input pin "IN_Up[24]"
Warning (15610): No output dependent on input pin "IN_Up[25]"
Warning (15610): No output dependent on input pin "IN_Up[26]"
Warning (15610): No output dependent on input pin "IN_Up[27]"
Warning (15610): No output dependent on input pin "IN_Up[28]"
Warning (15610): No output dependent on input pin "IN_Up[29]"
Warning (15610): No output dependent on input pin "IN_Up[30]"
Warning (15610): No output dependent on input pin "IN_Up[31]"
Warning (15610): No output dependent on input pin "IN_Down[0]"
Warning (15610): No output dependent on input pin "IN_Down[1]"
Warning (15610): No output dependent on input pin "IN_Down[2]"
Warning (15610): No output dependent on input pin "IN_Down[3]"
Warning (15610): No output dependent on input pin "IN_Down[4]"
Warning (15610): No output dependent on input pin "IN_Down[5]"
Warning (15610): No output dependent on input pin "IN_Down[6]"
Warning (15610): No output dependent on input pin "IN_Down[7]"
Warning (15610): No output dependent on input pin "IN_Down[8]"
Warning (15610): No output dependent on input pin "IN_Down[9]"
Warning (15610): No output dependent on input pin "IN_Down[10]"
Warning (15610): No output dependent on input pin "IN_Down[11]"
Warning (15610): No output dependent on input pin "IN_Down[12]"
Warning (15610): No output dependent on input pin "IN_Down[13]"
Warning (15610): No output dependent on input pin "IN_Down[14]"
Warning (15610): No output dependent on input pin "IN_Down[15]"
Warning (15610): No output dependent on input pin "IN_Down[16]"
Warning (15610): No output dependent on input pin "IN_Down[17]"
Warning (15610): No output dependent on input pin "IN_Down[18]"
Warning (15610): No output dependent on input pin "IN_Down[19]"
Warning (15610): No output dependent on input pin "IN_Down[20]"
Warning (15610): No output dependent on input pin "IN_Down[21]"
Warning (15610): No output dependent on input pin "IN_Down[22]"
Warning (15610): No output dependent on input pin "IN_Down[23]"
Warning (15610): No output dependent on input pin "IN_Down[24]"
Warning (15610): No output dependent on input pin "IN_Down[25]"
Warning (15610): No output dependent on input pin "IN_Down[26]"
Warning (15610): No output dependent on input pin "IN_Down[27]"
Warning (15610): No output dependent on input pin "IN_Down[28]"
Warning (15610): No output dependent on input pin "IN_Down[29]"
Warning (15610): No output dependent on input pin "IN_Down[30]"
Warning (15610): No output dependent on input pin "IN_Down[31]"
Warning (15610): No output dependent on input pin "Clk"
Warning (15610): No output dependent on input pin "Rst"
Warning (15714): Some pins have incomplete I/O assignments. Refer to the I/O Assignment Warnings report for details
Warning (332068): No clocks defined in design.
Warning (332068): No clocks defined in design.
Warning (332068): No clocks defined in design.
Warning (332068): No clocks defined in design.
代码:
- module moundetector (IN_Up,IN_Down,Clk,Rst,Counter);
-
- input Clk;
- input Rst;
- output reg [7:0] Counter;
- parameter channel=32;
- parameter s0=4'b0000,s1=4'b0001,s2=4'b0010,s3=3'b0011,s4=4'b0100,s5=4'b0101,s6=4'b0110,s7=4'b0111,
- s8=4'b1000,s9=4'b1001,s10=4'b1010,s11=4'b1011,s12=4'b1100,s13=4'b1101,s14=4'b1110,s15=4'b1111;
- input [channel-1:0]IN_Up,IN_Down;
- reg Up,Down,Up_state,Down_state;
- reg [3:0]cur_state, next_state;
- reg markup=1'b0, markdown=1'b0 ;
- reg [5:0]i,j;
- reg res;
- always @(IN_Up or IN_Down or res )//////应该想的是 信号可以随时变化 每次变化都赋给寄存器 但是当有信号是 只把对应的变化信号持续给Up、Down
- begin
- if(~res)
- begin
- Up=0;
- Down=0;
- markup=0;
- markdown=0;
- i=6'b100000;
- j=6'b100000;
- end
- else
- begin
- case(IN_Up)
- 32'b00000000_00000000_00000000_00000001 : begin Up=IN_Up[0]; i=6'b000000;markup=1;end
- 32'b00000000_00000000_00000000_00000010 : begin Up=IN_Up[1]; i=6'b000001;markup=1;end
- 32'b00000000_00000000_00000000_00000100 : begin Up=IN_Up[2]; i=6'b000010;markup=1;end
- 32'b00000000_00000000_00000000_00001000 : begin Up=IN_Up[3]; i=6'b000011;markup=1;end
- 32'b00000000_00000000_00000000_00010000 : begin Up=IN_Up[4]; i=6'b000100;markup=1;end
- 32'b00000000_00000000_00000000_00100000 : begin Up=IN_Up[5]; i=6'b000101;markup=1;end
- 32'b00000000_00000000_00000000_01000000 : begin Up=IN_Up[6]; i=6'b000110;markup=1;end
- 32'b00000000_00000000_00000000_10000000 : begin Up=IN_Up[7]; i=6'b000111;markup=1;end
- 32'b00000000_00000000_00000001_00000000 : begin Up=IN_Up[8]; i=6'b001000;markup=1;end
- 32'b00000000_00000000_00000010_00000000 : begin Up=IN_Up[9]; i=6'b001001;markup=1;end
- 32'b00000000_00000000_00000100_00000000 : begin Up=IN_Up[10]; i=6'b001010;markup=1;end
- 32'b00000000_00000000_00001000_00000000 : begin Up=IN_Up[11]; i=6'b001011;markup=1;end
- 32'b00000000_00000000_00010000_00000000 : begin Up=IN_Up[12]; i=6'b001100;markup=1;end
- 32'b00000000_00000000_00100000_00000000 : begin Up=IN_Up[13]; i=6'b001101;markup=1;end
- 32'b00000000_00000000_01000000_00000000 : begin Up=IN_Up[14]; i=6'b001110;markup=1;end
- 32'b00000000_00000000_10000000_00000000 : begin Up=IN_Up[15]; i=6'b001111;markup=1;end
- 32'b00000000_00000001_00000000_00000000 : begin Up=IN_Up[16]; i=6'b010000;markup=1;end
- 32'b00000000_00000010_00000000_00000000 : begin Up=IN_Up[17]; i=6'b010001;markup=1;end
- 32'b00000000_00000100_00000000_00000000 : begin Up=IN_Up[18]; i=6'b010010;markup=1;end
- 32'b00000000_00001000_00000000_00000000 : begin Up=IN_Up[19]; i=6'b010011;markup=1;end
- 32'b00000000_00010000_00000000_00000000 : begin Up=IN_Up[20]; i=6'b010100;markup=1;end
- 32'b00000000_00100000_00000000_00000000 : begin Up=IN_Up[21]; i=6'b010101;markup=1;end
- 32'b00000000_01000000_00000000_00000000 : begin Up=IN_Up[22]; i=6'b010110;markup=1;end
- 32'b00000000_10000000_00000000_00000000 : begin Up=IN_Up[23]; i=6'b010111;markup=1;end
- 32'b00000001_00000000_00000000_00000000 : begin Up=IN_Up[24]; i=6'b011000;markup=1;end
- 32'b00000010_00000000_00000000_00000000 : begin Up=IN_Up[25]; i=6'b011001;markup=1;end
- 32'b00000100_00000000_00000000_00000000 : begin Up=IN_Up[26]; i=6'b011010;markup=1;end
- 32'b00001000_00000000_00000000_00000000 : begin Up=IN_Up[27]; i=6'b011011;markup=1;end
- 32'b00010000_00000000_00000000_00000000 : begin Up=IN_Up[28]; i=6'b011100;markup=1;end
- 32'b00100000_00000000_00000000_00000000 : begin Up=IN_Up[29]; i=6'b011101;markup=1;end
- 32'b01000000_00000000_00000000_00000000 : begin Up=IN_Up[30]; i=6'b011110;markup=1;end
- 32'b10000000_00000000_00000000_00000000 : begin Up=IN_Up[31]; i=6'b011111;markup=1;end
- default : begin Up=1'b0;i=6'b100000;markup=1'b0;end /////将i=32设为初始状态
- endcase
-
- case(IN_Down)
- 32'b00000000_00000000_00000000_00000001 : begin Down=IN_Down[0]; i=6'b000000;markup=1;end
- 32'b00000000_00000000_00000000_00000010 : begin Down=IN_Down[1]; i=6'b000001;markup=1;end
- 32'b00000000_00000000_00000000_00000100 : begin Down=IN_Down[2]; i=6'b000010;markup=1;end
- 32'b00000000_00000000_00000000_00001000 : begin Down=IN_Down[3]; i=6'b000011;markup=1;end
- 32'b00000000_00000000_00000000_00010000 : begin Down=IN_Down[4]; i=6'b000100;markup=1;end
- 32'b00000000_00000000_00000000_00100000 : begin Down=IN_Down[5]; i=6'b000101;markup=1;end
- 32'b00000000_00000000_00000000_01000000 : begin Down=IN_Down[6]; i=6'b000110;markup=1;end
- 32'b00000000_00000000_00000000_10000000 : begin Down=IN_Down[7]; i=6'b000111;markup=1;end
- 32'b00000000_00000000_00000001_00000000 : begin Down=IN_Down[8]; i=6'b001000;markup=1;end
- 32'b00000000_00000000_00000010_00000000 : begin Down=IN_Down[9]; i=6'b001001;markup=1;end
- 32'b00000000_00000000_00000100_00000000 : begin Down=IN_Down[10]; i=6'b001010;markup=1;end
- 32'b00000000_00000000_00001000_00000000 : begin Down=IN_Down[11]; i=6'b001011;markup=1;end
- 32'b00000000_00000000_00010000_00000000 : begin Down=IN_Down[12]; i=6'b001100;markup=1;end
- 32'b00000000_00000000_00100000_00000000 : begin Down=IN_Down[13]; i=6'b001101;markup=1;end
- 32'b00000000_00000000_01000000_00000000 : begin Down=IN_Down[14]; i=6'b001110;markup=1;end
- 32'b00000000_00000000_10000000_00000000 : begin Down=IN_Down[15]; i=6'b001111;markup=1;end
- 32'b00000000_00000001_00000000_00000000 : begin Down=IN_Down[16]; i=6'b010000;markup=1;end
- 32'b00000000_00000010_00000000_00000000 : begin Down=IN_Down[17]; i=6'b010001;markup=1;end
- 32'b00000000_00000100_00000000_00000000 : begin Down=IN_Down[18]; i=6'b010010;markup=1;end
- 32'b00000000_00001000_00000000_00000000 : begin Down=IN_Down[19]; i=6'b010011;markup=1;end
- 32'b00000000_00010000_00000000_00000000 : begin Down=IN_Down[20]; i=6'b010100;markup=1;end
- 32'b00000000_00100000_00000000_00000000 : begin Down=IN_Down[21]; i=6'b010101;markup=1;end
- 32'b00000000_01000000_00000000_00000000 : begin Down=IN_Down[22]; i=6'b010110;markup=1;end
- 32'b00000000_10000000_00000000_00000000 : begin Down=IN_Down[23]; i=6'b010111;markup=1;end
- 32'b00000001_00000000_00000000_00000000 : begin Down=IN_Down[24]; i=6'b011000;markup=1;end
- 32'b00000010_00000000_00000000_00000000 : begin Down=IN_Down[25]; i=6'b011001;markup=1;end
- 32'b00000100_00000000_00000000_00000000 : begin Down=IN_Down[26]; i=6'b011010;markup=1;end
- 32'b00001000_00000000_00000000_00000000 : begin Down=IN_Down[27]; i=6'b011011;markup=1;end
- 32'b00010000_00000000_00000000_00000000 : begin Down=IN_Down[28]; i=6'b011100;markup=1;end
- 32'b00100000_00000000_00000000_00000000 : begin Down=IN_Down[29]; i=6'b011101;markup=1;end
- 32'b01000000_00000000_00000000_00000000 : begin Down=IN_Down[30]; i=6'b011110;markup=1;end
- 32'b10000000_00000000_00000000_00000000 : begin Down=IN_Down[31]; i=6'b011111;markup=1;end
- default: begin Down=1'b0;j=6'b100000;markdown=0; end /////
- endcase
- end
- end
- always @(posedge Clk or negedge Rst)//////状态变化 ,为时序逻辑
- begin
- if(~Rst)
- begin
- cur_state<=s0;//////初始状态
- next_state<=s0;
- Up_state<=0;
- Down_state<=0;
- Counter<=8'b0000_0000;
- end
- else
- begin /////////////////应该限制为当某一信号时 进行选择 操作 否则 就是已选择过正在处理 if 然后怎么样 而不是当来一个时钟下降沿就要进行一次寻找 操作
- Up_state<=Up;
- Down_state<=Down;
- cur_state<=next_state;
-
- case(cur_state)
- s0 : begin //////继续等待或进入下一状态 ,可能 上板先到 也可能下板先到
- if({markup,Up_state,markdown,Down_state}==4'b1111)//////表明处理后的信号同时到达为μ 子 计数器加1 并且系统复位
- begin
- Counter<=Counter+8'b0000_0001;
- res<=0;
-
- end
- else if({markup,Up_state,markdown,Down_state}==4'b1100)/////上板比下板先到
- begin
- next_state<=s1;
- end
- else if({markup,Up_state,markdown,Down_state}==4'b0011)/////下板比上板先到
- begin
- next_state<=s5;
- end
- else
- begin /////表明仍为等待状态
- next_state<=s0;
- end
- end
- s1:begin
- if({markup,Up_state,markdown,Down_state}==4'b1111)
- begin
- Counter<=Counter+8'b0000_0001;
- res<=0;
- end
- else
- begin
- next_state<=s2;
- end
- end
- s2:begin
- if({markup,Up_state,markdown,Down_state}==4'b1111)
- begin
- Counter<=Counter+8'b0000_0001;
- res<=0;
- end
- else
- begin
- next_state<=s3;
- end
- end
- s3: begin
- if({markup,Up_state,markdown,Down_state}==4'b1111)
- begin
- Counter<=Counter+8'b0000_0001;
- res<=0;
- end
- else
- begin
- next_state<=s4;
- end
- end
- s4:begin
- if({markup,Up_state,markdown,Down_state}==4'b1111)
- begin
- Counter<=Counter+8'b0000_0001;
- res<=0;
- end
- else
- begin //////大于20ns时 复位
- next_state<=s0;
- res<=0;
- end
- end
- s5:begin//////下板先到
- if({markup,Up_state,markdown,Down_state}==4'b1111)
- begin
- Counter<=Counter+8'b0000_0001;
- res<=0;
- end
- else
- begin
- next_state<=s6;
- end
- end
- s6:begin
- if({markup,Up_state,markdown,Down_state}==4'b1111)
- begin
- Counter<=Counter+8'b0000_0001;
- res<=0;
- end
- else/////下板比上板早到超过10ns
- begin
- res<=0;
- end
- end
- default:begin
- res<=0;
- end
- endcase
- end
- end
- endmodule
复制代码 |
|