简体   繁体   English

Xilinx,Isim在仿真中处理Verilog整数类型

[英]Xilinx, Isim treatment of Verilog integer types in simulation

I'm pretty new to FPGA and Verilog, but I'm having a problem getting my code to run in the simulator they way I would expect. 我对FPGA和Verilog还是很陌生,但是我无法按我期望的方式在模拟器中运行我的代码。 It seems the Isim simulator is not "operating" on integers in my code. 似乎Isim仿真器未在代码中对整数进行“操作”。 Below is a snippet of the relevant code. 以下是相关代码的片段。 I'm trying to divide the clk pulse by toggling SCK_gen every time integer i reaches 10. When I run this code in Isim, SCK_gen never changes value. 我试图通过在每次到达整数10时切换SCK_gen来划分clk脉冲。当我在Isim中运行此代码时,SCK_gen永远不会更改值。 Also it When I impliment the code on the FPGA, it behaves as I would expect, I can observe a pulse at 1/10 the clock frequency. 同样,当我将代码嵌入到FPGA上时,它的行为符合我的预期,我可以观察到时钟频率为1/10的脉冲。 If anyone can point me in the right direction I'd be grateful. 如果有人能指出正确的方向,我将不胜感激。 Thanks 谢谢

    //signals
//for SCK_clock
reg SCK_gen, SCK_hold;
integer i;
reg en_SCK;
wire neg_edge_SCK;


//SCK_generator
always @(posedge clk, posedge reset)
    if (reset)
        begin 
            SCK_gen <= 0;
        end
    else
        begin
            i <= i+1;
            SCK_hold <= SCK_gen;
                if(i == 10)
                    begin
                        SCK_gen <= ~SCK_gen;
                        i <= 0;
                    end
        end

//detect neg edge of SCK
assign neg_edge_SCK = SCK_hold & SCK_gen;

The result of any arithmetic or logical equality operation is 'x' if any of the operands are 'x'. 如果任何操作数为“ x”,则任何算术或逻辑相等运算的结果为“ x”。 Since it looks like i is not initialized, the statement i <= i+1 has no effect on i and so the comparison (i == 10) will always be false. 由于看起来i尚未初始化,因此语句i <= i+1i无效,因此比较(i == 10)始终为false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM