微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > verilog 编码问题 求解答

verilog 编码问题 求解答

时间:10-02 整理:3721RD 点击:
请教大家一个基础的问题。自己写一个数据源,如下.状态在i=1时,Dataout有跳变,在状态i=2时,只计数,计1600次,信号LEN跳变,不管Dataout;经在开发板上测试发现,在这1600次计数过程中,Dataout会有输出。这是为什么呢,不是有时钟来了Dataout才会有输出吗?
initial
begin
  i <= 6'd0;
  j <=0;
end
always @(negedge clk)
                begin
                        case (i)
                                6'd0:        
                                                begin
                                                       LEN <= 0;
                                                        i <= 6'd1;
                                                end
                                6'd1:
                                                begin
                                                        if(j >= 20)
                                                                begin
                                                                        i <= 6'd2;
                                                                        j <= 0;
                                                                        LEN <=1;
                                                                        Dataout <= Dataout + 1;
                                                                end
                                                        else
                                                                begin
                                                                        i <= 6'd1;
                                                                        j <= j + 1;
                                                                end
                                                end
                                6'd2:
                                                begin
                                                        if(col_cnt >= 1600)
                                                                begin
                                                                        LEN <= 1;
                                                                        col_cnt <= 0;
                                                                        i <= 6'd3;
                                                                        line_cnt <= line_cnt + 1;
                                                                end
                                                        else
                                                                begin
                                                                        i <= 6'd2;
                                                                  col_cnt <= col_cnt + 1;                                 
                                                              end
                                                end
                                          ..........................

你定义的i是几比特宽带啊?



   这不是重点 代码是两分钟随便写的

Do you know what is the blocking and non-blocking assignment?
That is the first topic of the learn the coding of verilog.
The rtl coding has many concept doesn't same as c language.
The RTL has some block can be parallel execution but the c language does the sequential execution of the program.
So I suggest you to make sure you are understand what's differnt of blocking and non-blocking assignment.

谢谢,学习学习

关注一下  同求答案

同求答案

The first make sure your code is a behavior model or synthesizable RTL code.
If the RTL code that can't have a initial statement. You may be written a test bench to connect your DUT to do the function simulation.

硬件代码岂能随便写?要明白每一段代码,实际上,就是对应的某一个既定固件,看得到摸得着的物理存在
一般来讲,小编提到的现象,就是代码风格问题,你想要的逻辑控制单元,并不是那么复杂



    呵呵

其实不太懂你的意思
dataout本来就应该有输出
除非你赋予它z值
initial语法通常是在testbanch里写
如果是RTL建模层级 建议使用nRST来做起始状态
always @( posedge CLK or negedge nRST )
    if(nRST) begin ...(所有register起始值) end
    else
        case(i) ...

你这个代码有initial 语句,是不可综合的,这个只能在仿真里适用

其实我是想表达一个意思,Dataout在我设计的1600个时钟里有输出,在其他时刻不要有输出;我翻了下语法书,说是在i=2时,Dataout处会生成寄存器,保存原值;那怎么写才能使得不会有输出呢?

不要有输出是什么意思?初始值?默认值?高阻?一个IO口输出可以有三种状态:1、0、高阻。你想要哪种赋值就行啦!

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top