完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在使用斯巴达6。
在本文末尾的代码片段中,我使用的是使用正边沿驱动某些寄存器的时钟,以及使用负边沿的其他寄存器。 正边沿和负边沿驱动触发器在模块“存储器”内一起使用,以在两个边缘上存储输入。 状态机是16位加法器,每个位存储在“存储”元素中。 “storage”元素的4个输出在LED上设置,以便我可以看到结果。 我看到的问题是我将正确地看到counterdataout [12:0]按预期计数,但最重要的位counterdataout [15:13]将陷入相同的状态; 就好像在一定数量的这些“存储”元素之后,附加的“存储”元素停止正常工作。 如果我使用单边触发器(正边沿或负边沿)实现模块“存储”,则状态机的所有16位都按预期计数。 所以我的问题是,为什么在设计中混合正负边缘触发器不起作用? 模块存储(输入线clk,输入线数据,输出线数据输出); reg r1,r2; 总是@(posedge clk)r1总是@(negedge clk)r2指定dataout = clk? r1:r2; / *取消注释使用正边缘触发器。 reg r; 总是@(posedge clk)r赋值dataout = r; * / / *取消注释使用负边缘触发器。 reg r; 总是@(negedge clk)r assign dataout = r; * / endmodulemodule main(输入线clk,输出线[3:0] leds); //状态机,它是一个计数器逻辑//其状态的每个位都存储在每个存储模块中。 电线[15:0]反击; wire [15:0] counterdataout; assign counteratat = counterdataout + 16'b1; //设置4位LED。 assign leds = counterdataout [15:12]; 存储计数器0(clk,counterdatain [0],counterdataout [0]); 存储计数器1(clk,counterdatain [1],counterdataout [1]); 存储计数器2(clk,counterdatain [2],counterdataout [2]); 存储计数器3(clk,counterdatain [3],counterdataout [3]); storage counter4(clk,counterdatain [4],counterdataout [4]); 存储计数器5(clk,counterdatain [5],counterdataout [5]); 存储计数器6(clk,counterdatain [6],counterdataout [6]); 存储计数器7(clk,counterdatain [7],counterdataout [7]); 存储计数器8(clk,counterdatain [8],counterdataout [8]); 存储计数器9(clk,counterdatain [9],counterdataout [9]); 存储计数器10(clk,counterdatain [10],counterdataout [10]); 存储计数器11(clk,counterdatain [11],counterdataout [11]); 存储计数器12(clk,counterdatain [12],counterdataout [12]); 存储计数器13(clk,counterdatain [13],counterdataout [13]); 存储计数器14(clk,counterdatain [14],counterdataout [14]); 存储计数器15(clk,counterdatain [15],counterdataout [15]); endmodule 以上来自于谷歌翻译 以下为原文 I am using a Spartan 6. In the code snippet at the end of this post, I am using a clock that drives some registers using a positive edge, and other registers using a negative edge. A positive edge and a negative edge driven flipflop, are used together within the module "storage" to store an input on both edges. The state machine is a 16 bits adder, for which each bit is stored in a "storage" element. The output of 4 of the "storage" element is set on the LEDs so that I can visualize the result. The issue that I am seeing is that I will correctly see counterdataout[12:0] count up as expected, but the most significant bits counterdataout[15:13] will just get stuck with the same state; it is as if after a certain number of these "storage" elements, additonal "storage" elements stop working correctly. If I implement the module "storage" using a single flipflop that is either positive edge or negative edge, all the 16 bits of the state machine count up as expected. So my question is, why mixing positive and negative edge flipflop in a design does not work ? module storage( input wire clk, input wire datain, output wire dataout ); reg r1, r2; always @(posedge clk) r1 <= datain; always @(negedge clk) r2 <= datain; assign dataout = clk ? r1 : r2; /* Uncomment to use positive edge flipflop. reg r; always @(posedge clk) r <= datain; assign dataout = r; */ /* Uncomment to use negative edge flipflop. reg r; always @(negedge clk) r <= datain; assign dataout = r; */ endmodule module main( input wire clk, output wire[3:0] leds ); // State machine which is a counter logic // for which each bit of its state is stored // in each of the storage modules. wire[15:0] counterdatain; wire[15:0] counterdataout; assign counterdatain = counterdataout + 16'b1; // Set the 4 bits leds. assign leds = counterdataout[15:12]; storage counter0(clk, counterdatain[0], counterdataout[0]); storage counter1(clk, counterdatain[1], counterdataout[1]); storage counter2(clk, counterdatain[2], counterdataout[2]); storage counter3(clk, counterdatain[3], counterdataout[3]); storage counter4(clk, counterdatain[4], counterdataout[4]); storage counter5(clk, counterdatain[5], counterdataout[5]); storage counter6(clk, counterdatain[6], counterdataout[6]); storage counter7(clk, counterdatain[7], counterdataout[7]); storage counter8(clk, counterdatain[8], counterdataout[8]); storage counter9(clk, counterdatain[9], counterdataout[9]); storage counter10(clk, counterdatain[10], counterdataout[10]); storage counter11(clk, counterdatain[11], counterdataout[11]); storage counter12(clk, counterdatain[12], counterdataout[12]); storage counter13(clk, counterdatain[13], counterdataout[13]); storage counter14(clk, counterdatain[14], counterdataout[14]); storage counter15(clk, counterdatain[15], counterdataout[15]); endmodule |
|
相关推荐
5个回答
|
|
分配dataout = clk?
r1:r2; 这行代码可能会在时钟路由中产生一些问题。 也许你有 一些严重的违规行为? 如果你想尝试在两个时钟边缘运行,你应该重新设计你的内部“DDR” 寄存器使您不需要时钟作为输出多路复用器的逻辑输入。 标准 这样做的方法是使用XOR门: reg r1 = 0; reg r2 = 0;指定dataout = r1 ^ r2;总是@(posedge clk)if(R | S)start r1 endelse begin r1 endalways @(negedge clk)if(R | S)begin r2 endelse begin r2结束 - Gabor [编辑]将设置/复位逻辑更改为零r2。 如最初发布的那样,S或R都会导致 输出变为零。 此代码是从实际上没有使用set或设计的设计中剪切的 重置,但“实现”它们以允许dropin替换DDR原语。 - Gabor 在原帖中查看解决方案 以上来自于谷歌翻译 以下为原文 assign dataout = clk ? r1 : r2; This line of code probably creates some problems in clock routing. Perhaps you have some serious hold time violations? If you want to try to run on both clock edges, you should re-design your internal "DDR" register so that you don't need the clock as a logic input to the output mux. The standard way to do this is with XOR gates like: reg r1 = 0; reg r2 = 0; assign dataout = r1 ^ r2; always @ (posedge clk) if (R | S) begin r1 <= S; end else begin r1 <= datain ^ r2; end always @ (negedge clk) if (R | S) begin r2 <= 0; end else begin r2 <= datain ^ r1; end -- Gabor [Edit] Changed set/reset logic to zero r2. As originally posted, either S or R would cause the output to go to zero. This code was clipped from a design that didn't actually use set or reset, but "implemented" them to allow dropin replacement of a DDR primitive. -- GaborView solution in original post |
|
|
|
你的时钟速度是多少?
当你使用两个边缘时,很难达到计时 时钟因为你只有1/2个时钟周期的设置时间。 上层的事实 计数器的位不起作用表明设计不符合计时(你确实有 时间约束)当你使用两个边时,高位是第一个显示它 因为进位链的长度。 - Gabor - Gabor 以上来自于谷歌翻译 以下为原文 What's your clock speed? It's much harder to meet timing when you use both edges of the clock because you can have only 1/2 clock cycle of setup time. The fact that the upper bits of a counter don't work suggests that the design doesn't meet timing (you do have timing constraints) when you use both edges, and the upper bits are the first to show it because of the length of the carry chain. -- Gabor -- Gabor |
|
|
|
我使用了一个低至1Hz的时钟,以便能够在LED上显示它;
而且,最重要的位数counterdataout [15:13]将陷入相同的状态; 使用单边触发器(正边沿或负边沿)实现模块“存储”,状态机的所有16位按预期计数; 而且,在整个过程中我使用的时钟足够慢,可以让我在LED上看到结果。 在我的代码片段中,我没有包含我用来减慢时钟的逻辑,因为我想保持我的帖子简单。 以上来自于谷歌翻译 以下为原文 I used a clock as low as 1Hz in order to be able to visualize it on the LEDs; and again, the most significant bits counterdataout[15:13] will just get stuck with the same state; implementing the module "storage" using a single flipflop that is either positive edge or negative edge, all the 16 bits of the state machine count up as expected; and again, throughout I am using a clock that is slow enough for me to see the result on the LEDs. In my code snippet, I did not include the logic that I used to slow down the clock, because I wanted to keep my post simple. |
|
|
|
分配dataout = clk?
r1:r2; 这行代码可能会在时钟路由中产生一些问题。 也许你有 一些严重的违规行为? 如果你想尝试在两个时钟边缘运行,你应该重新设计你的内部“DDR” 寄存器使您不需要时钟作为输出多路复用器的逻辑输入。 标准 这样做的方法是使用XOR门: reg r1 = 0; reg r2 = 0;指定dataout = r1 ^ r2;总是@(posedge clk)if(R | S)start r1 endelse begin r1 endalways @(negedge clk)if(R | S)begin r2 endelse begin r2结束 - Gabor [编辑]将设置/复位逻辑更改为零r2。 如最初发布的那样,S或R都会导致 输出变为零。 此代码是从实际上没有使用set或设计的设计中剪切的 重置,但“实现”它们以允许dropin替换DDR原语。 - Gabor 以上来自于谷歌翻译 以下为原文 assign dataout = clk ? r1 : r2; This line of code probably creates some problems in clock routing. Perhaps you have some serious hold time violations? If you want to try to run on both clock edges, you should re-design your internal "DDR" register so that you don't need the clock as a logic input to the output mux. The standard way to do this is with XOR gates like: reg r1 = 0; reg r2 = 0; assign dataout = r1 ^ r2; always @ (posedge clk) if (R | S) begin r1 <= S; end else begin r1 <= datain ^ r2; end always @ (negedge clk) if (R | S) begin r2 <= 0; end else begin r2 <= datain ^ r1; end -- Gabor [Edit] Changed set/reset logic to zero r2. As originally posted, either S or R would cause the output to go to zero. This code was clipped from a design that didn't actually use set or reset, but "implemented" them to allow dropin replacement of a DDR primitive. -- Gabor |
|
|
|
你解决了!!!
现在我有了第二个经验法则:永远不要将时钟用作组合逻辑的输入,以避免时钟的有趣路由(通过非优化时钟路径),这可能会造成保持时间违规。 我的第一个经验法则是:永远不要使用组合逻辑的输出作为时钟,因为潜在的危险会导致不必要的时钟转换。 以上来自于谷歌翻译 以下为原文 You solved it !!! Now I have a second rule of thumb: Never use the clock as an input to a combinational logic, to avoid funny routing of the clock(through non-optimized clock paths), that could create hold time violations. My first rule of thumb was: Never use the output of a combinational logic as clock because of potential hazards which result in unwanted clock transitions. |
|
|
|
只有小组成员才能发言,加入小组>>
2416 浏览 7 评论
2821 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2292 浏览 9 评论
3372 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2459 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
1135浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
581浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
447浏览 1评论
2002浏览 0评论
726浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 10:39 , Processed in 1.281740 second(s), Total 83, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号