Verilog 3位集中了2个变量

时间:2013-06-26 21:27:36

标签: verilog

我正在尝试理解这段Verilog代码..

reg [2:0] SYNC;
always @(posedge clk) SYNC <= {SYNC[1:0], ASYNC};
wire SYNC_risingedge = (SYNC[2:1] == 2'b01);
wire SYNC_fallingedge = (SYNC[2:1] == 2'b10);
wire SYNC_on = ~SYNC[1];

据我所知。 进行3位注册(同步) 当时钟上升时,sync等于位1和0的组合,其当前值为(async)。 SYNC_risingedge等于(sync)位2和1以及二进制'01'的值 SYNC_fallingedge等于(sync)位2和1以及二进制“10”的值 SYNC_on等于sync的反转。

我的问题在引号旁边。

reg [2:0] SYNC;
always @(posedge clk) SYNC <= {SYNC[1:0], ASYNC}; *"does this mean that it concentrates         the state of ASYNC with only bits 1 and 0?"*
wire SYNC_risingedge = (SYNC[2:1] == 2'b01); *"is the binary number 01 placed only in  bits 2 and 1? if so, how does it affect the previous line?"*
wire SYNC_fallingedge = (SYNC[2:1] == 2'b10); *"same question as previous line"*
wire SYNC_on = ~SYNC[1]; *"What does the [1] mean in ~SYNC[1]?"*

我已经在网上搜索,寻找Verilog语法来理解这段代码,但是已经很短了。 任何援助将不胜感激。

1 个答案:

答案 0 :(得分:2)

  1. 问题1

    always @(posedge clk) SYNC <= {SYNC[1:0], ASYNC};
    
         

    这是否意味着它只集中了ASYNC的状态,只有1位和0位?

    我认为你的意思是“连接”,而你是对的,是的。该语句基本上将SYNC左移',然后将ASYNC的值放入位0.此移位操作发生在每个上升时钟边沿。

    完整的表格:

       SYNC  |   ASYNC   |  New SYNC Setting
    ---------+-----------|--------------------
       000   |     0     |       000
       001   |     0     |       010
       010   |     0     |       100
       011   |     0     |       110
       100   |     0     |       000
       101   |     0     |       010
       110   |     0     |       100
       111   |     0     |       110
       000   |     1     |       001
       001   |     1     |       011
       010   |     1     |       101
       011   |     1     |       111
       100   |     1     |       001
       101   |     1     |       011
       110   |     1     |       101
       111   |     1     |       111
    
  2. 问题2

    wire SYNC_risingedge = (SYNC[2:1] == 2'b01);
    
         

    是仅在位2和1中放置的二进制数01?如果是这样,它如何影响前一行呢?

    不,==测试,而不是作业。如果这两个SYNC位匹配2b'01,则SYNC_risingedge线将为高。否则它会很低。

    注意:SYNC_risingedge的“赋值”是异步的 - 它只是组合逻辑。

  3. 问题3

    wire SYNC_fallingedge = (SYNC[2:1] == 2'b10);
    
         

    与前一行相同的问题

    同样的答案。

  4. 问题4

    wire SYNC_on = ~SYNC[1];
    
         

    〜[1]中[1]的含义是什么?

    它只是指SYNC的第1位。 SYNC [1]为低电平时SYNC_on为高电平,反之亦然。

相关问题