Binary-BCD转换器仿真正常但FPGA板卡运行异常求助
Basys3开发板Binary转BCD转换器板级运行异常排查
问题现象
我为Basys3开发板设计了一款Binary转BCD转换器,仿真时结果符合预期且时序完全正确。将该转换器集成到顶层模块后,通过另一模块生成的输入脉冲启动转换流程,但板卡实际运行时结果异常:
- 多数输入值对应的输出为全0
- 仅输入1时,输出的BCD值为15|15|15|14
问题仅出现在板卡运行阶段,推测是模块综合环节存在问题,但尚未定位到具体原因。
综合警告信息
[Synth 8-567] referenced signal 'i' should be on the sensitivity list ["C:/Xilinx/VivadoProjects/BCD/BCD.srcs/sources_1/new/Binary2BCDTranscoder.v":80] [Synth 8-567] referenced signal 'j' should be on the sensitivity list ["C:/Xilinx/VivadoProjects/BCD/BCD.srcs/sources_1/new/Binary2BCDTranscoder.v":80] [Synth 8-567] referenced signal 'state' should be on the sensitivity list ["C:/Xilinx/VivadoProjects/BCD/BCD.srcs/sources_1/new/Binary2BCDTranscoder.v":150] [Synth 8-567] referenced signal 'iEn' should be on the sensitivity list ["C:/Xilinx/VivadoProjects/BCD/BCD.srcs/sources_1/new/Binary2BCDTranscoder.v":150] [Synth 8-567] referenced signal 'inner_in' should be on the sensitivity list ["C:/Xilinx/VivadoProjects/BCD/BCD.srcs/sources_1/new/Binary2BCDTranscoder.v":150] [Synth 8-567] referenced signal 'jEn' should be on the sensitivity list ["C:/Xilinx/VivadoProjects/BCD/BCD.srcs/sources_1/new/Binary2BCDTranscoder.v":150] [Synth 8-327] inferring latch for variable 'inner_out_reg' ["C:/Xilinx/VivadoProjects/BCD/BCD.srcs/sources_1/new/Binary2BCDTranscoder.v":155] [Synth 8-7080] Parallel synthesis criteria is not met
相关代码模块
Binary2BCDTranscoder模块代码
`timescale 1ns / 1ps module Binary2BCDTranscoder #(parameter INPUT_SIZE = 12, parameter OUTPUT_DIGITS = 4, parameter ICNTR_SIZE = 4, parameter JCNTR_SIZE = 2) ( input clk, input rst, input convStart, input [INPUT_SIZE-1:0] data, output reg convDone, output reg [4 * OUTPUT_DIGITS - 1:0] convOut ); localparam WAIT = 2'b00; localparam CONV_CHK = 2'b01; localparam FINISHED = 2'b11; reg iRst, jRst, iEn, jEn; wire [ICNTR_SIZE-1:0] i; wire [JCNTR_SIZE-1:0] j; reg [1:0] state, next_state; reg [INPUT_SIZE-1:0] inner_in; reg [4 * OUTPUT_DIGITS - 1:0] inner_out; always @(posedge clk) begin if(!rst) state <= WAIT; else state <= next_state; end always @(posedge clk) begin if(!rst) inner_in <= 0; else if(convDone) inner_in <= data; end always @(posedge convDone) begin convOut <= inner_out; end counter #(.SIZE(ICNTR_SIZE)) iCounter ( .clk(clk), .rst(iRst), .en(iEn), .out(i) ); counter #(.SIZE(JCNTR_SIZE)) jCounter ( .clk(clk), .rst(jRst), .en(jEn), .out(j) ); always @(state, convStart) begin case(state) WAIT: begin convDone = 1; iRst = 0; iEn = 0; jRst = 0; jEn = 0; next_state = convStart ? CONV_CHK : WAIT; end CONV_CHK: begin if(i == INPUT_SIZE) begin convDone = 1; next_state = FINISHED; iRst = 0; jRst = 0; iEn = 0; jEn = 0; end else if(j == OUTPUT_DIGITS-1) begin next_state = CONV_CHK; convDone = 0; iRst = 1; jRst = 0; iEn = 1; jEn = 0; end else begin next_state = CONV_CHK; convDone = 0; iRst = 1; jRst = 1; iEn = 0; jEn = 1; end end FINISHED: begin next_state = WAIT; convDone = 1; iRst = 0; iEn = 0; jRst = 0; jEn = 0; end default: begin next_state = WAIT; convDone = 1; iRst = 0; iEn = 0; jRst = 0; jEn = 0; end endcase end always @(i,j) begin case(state) WAIT: begin inner_out = 0; end CONV_CHK: begin if(iEn) begin inner_out = {inner_out[4*OUTPUT_DIGITS - 2 : 0], inner_in[INPUT_SIZE - 1 - i]}; end else if(jEn) begin inner_out = inner_out; if(inner_out[4*j+:4] >= 5) inner_out[4*j+:4] = inner_out[4*j+:4] + 3; end else begin inner_out = inner_out; end end FINISHED: begin inner_out = 0; end default: begin inner_out = 0; end endcase end endmodule
顶层模块代码
module top( input clk, input rst, input convStart, input [11:0] data, output convDone, output [15:0] convOut ); wire convPulse; wire [9:0] clkDivOut; counter #(.SIZE(10)) CLK_DIVIDER( .clk(clk), .rst(!rst), .en(1'b1), .out(clkDivOut) ); pulseCreator #(.NUM_BITS(2)) convStartPulse ( .clk(clkDivOut[9]), .in(convStart), .out(convPulse), .regOutput() ); Binary2BCDTranscoder #(.INPUT_SIZE(12),.OUTPUT_DIGITS(4),.ICNTR_SIZE(4),.JCNTR_SIZE(2)) B2BCD ( .clk(clkDivOut[9]), .rst(!rst), .convStart(convPulse), .data(data), .convDone(convDone), .convOut(convOut) ); endmodule
辅助模块代码(计数器与脉冲生成器)
module counter #(parameter SIZE = 4) ( input clk, input rst, input en, output reg [SIZE-1:0] out ); always @(posedge clk) begin if(!rst) out <= 0; else if (en) out <= out + 1; end endmodule module serialRegister #(SIZE = 4)( input clk, input rst, input in, input en, output reg [SIZE-1:0] out ); always @(posedge clk, negedge rst) begin if(!rst) begin out <= 0; end else begin if(en) out <= {out[SIZE-2:0],in}; end end endmodule module pulseCreator #(NUM_BITS=3) ( input clk, input in, output out, output [NUM_BITS-1:0] regOutput ); //wire [NUM_BITS-1:0] regOutput; serialRegister #(.SIZE(NUM_BITS)) pulseReg( .clk(clk), .rst(in), .en(in), .in(in), .out(regOutput) ); assign out = in & !regOutput[NUM_BITS-1]; endmodule
内容的提问来源于stack exchange,提问作者Florinlego
相关产品推荐
相关产品推荐

