我正在学习verilog,我认为总有一些东西我不能理解@ *并且总是(@posedge clk,...)
这是一段应该通过uart发送位的代码。它在合成时失败了。 错误是 “逻辑for与已知的FF或Latch模板不匹配。当前软件版本不支持用于描述寄存器或锁存器的描述样式。” (和其他3个错误) 如果我总是用@ *改变always @(...),那么下一步就会失败(“实现设计”),因为事情没有连接。
在我所拥有的书中,他们为状态实现了一个始终(posedge clk)的fsmd,而对于其他逻辑,它总是@ *,但我不明白为什么这不起作用。
在另一个论坛上,我读到错误可能来自过于复杂的情况。但我也简化了一些事情(不是在这里编写代码,但基本上我删除了案例(状态)和ifs用?:或二元条件进行单行赋值,但它也没有用)
我之前在我编写的其他代码中看到过这个错误,但我没有深究它,所以如果你能帮我理解一般问题(用这个uart的东西作为对具体的支持例如),我会很开心。 谢谢 托马斯
P.S:我正在使用xilinx spartan 3e入门套件和xilinx ise 14.4
module UART_out #(parameter [3:0] NUM_BITS = 8)
(
input wire baud_clk,
input wire send_tick,
input wire[NUM_BITS-1:0] data_in,
output wire tx,
output wire debug_done
);
localparam
IDLE = 0,
TRANSMIT = 1;
reg[NUM_BITS:0] bits_to_send;
reg state;
reg out_bit;
reg[4:0] cnt;
always @(posedge baud_clk, posedge send_tick)
begin
case (state)
IDLE:
if (send_tick)
begin
bits_to_send <= {data_in, 0};
state <= TRANSMIT;
cnt <= 0;
end
TRANSMIT:
begin
if (cnt < NUM_BITS)
cnt <= cnt + 1;
else
state <= IDLE;
bits_to_send <= {1, bits_to_send[NUM_BITS:1]};
out_bit <= bits_to_send[0];
end
endcase
end
assign tx = (state == IDLE ? 1 : out_bit);
assign debug_done = (state == IDLE);
endmodule
答案 0 :(得分:5)
错误:
The logic for does not match a known FF or Latch template. The description style you are using to describe a register or latch is not supported in the current software release.
指的是综合工具没有任何符合您描述的硬件单元。
您想要什么硬件:
always @(posedge baud_clk, posedge send_tick)
这看起来像你想要一个带有启用信号的触发器。使能信号(send_tick)应为1个时钟周期宽。然后,这用于选择时钟边沿上的逻辑路径。不作为替代触发器。
我认为这就是你真正需要的:
always @(posedge baud_clk) begin
case (state)
IDLE:
if (send_tick) begin
//...
end
//...
endcase
end
如果send_tick
来自另一个时钟域,那么您需要进行一些时钟域交叉以将其转换为baud_clk
上的时钟脉冲。
您可能会对具有多个触发器的块感到困惑,它们通常是clk和reset。通常会为重置(初始化)条件添加negedge reset_n
或posedge reset
。
如果添加重置:
always @(posedge baud_clk or negedge reset_n) begin
if (~reset_n) begin
//reset conditions
state <= IDLE;
//...
end
else begin
// Standard logic
end
end
你会注意到这里有一个非常明确的结构,如果重置,则...综合工具将其识别为具有异步复位的触发器。复位条件下的数据也是静态的,通常将所有内容设置为零。