我对Verilog/FPGA编程非常陌生,我正在尝试实现UART。我的源代码是基于fpga4fun.com的教程。我的代码如下:
module async_transmitter(
input clk,
input TxD_start,
input [7:0] TxD_data,
output TxD,
output TxD_busy
);
parameter ClkFrequency = 25000000; // 25MHz
parameter Baud = 115200;
generate
if(ClkFrequency<Baud*8 && (ClkFrequency % Baud!=0)) ASSERTION_ERROR PARAMETER_OUT_OF_RANGE("Frequency incompatible with requested Baud rate");
endgenerate
// ... do something more
endmodule给定的值是本教程中包含的默认值。但是当我尝试合成代码时,它总是在if条件下失败。
对于async_receiver,我得到了类似的结果:
module async_receiver(
input clk,
input RxD,
output reg RxD_data_ready = 0,
output reg [7:0] RxD_data = 0,
output RxD_idle, // asserted when no data has been received for a while
output reg RxD_endofpacket = 0 // asserted for one clock cycle when a packet has been detected (i.e. RxD_idle is going high)
);
parameter ClkFrequency = 25000000; // 25MHz
parameter Baud = 115200;
parameter Oversampling = 8;
generate
if(ClkFrequency<Baud*Oversampling) ASSERTION_ERROR PARAMETER_OUT_OF_RANGE("Frequency too low for current Baud rate and oversampling");
if(Oversampling<8 || ((Oversampling & (Oversampling-1))!=0)) ASSERTION_ERROR PARAMETER_OUT_OF_RANGE("Invalid oversampling value");
endgenerate
// ... do something more
endmodulePlanAhead告诉我,如果接收方满足了这两个条件,则这两个条件都满足。但是例如,当我计算过采样* Baud (8 * 115200) = 921600时,它实际上小于25000000。你知道我哪里做错了吗?
发布于 2015-07-25 23:53:35
那么,您已经有了ASSERTION_ERROR的模块定义,这将是我的第一个猜测。
我已经使用相同的参数在Quartus 13.0sp1上尝试了HDL,我没有得到任何错误--我当前没有ISE/PlanAhead,所以可以将其隔离。我可以通过减少ClkFrequency或增加Baud来确认生成“工作”是否正确。仔细检查您是否获得了正确的值,并且这些值没有被任何实例化async_transmitter的模块覆盖。
也就是说,如果您确信这些值是正确的,那么您可以简单地注释掉generate块-毕竟它实际上不会生成任何东西。
https://stackoverflow.com/questions/31619877
复制相似问题