Shop OBEX P1 Docs P2 Docs Learn Events
GETNIB D,{#}S,#N Get nibble N of S into D. D = {28'b0, S.NIBBLE[N]). Syntax Question — Parallax Forums

GETNIB D,{#}S,#N Get nibble N of S into D. D = {28'b0, S.NIBBLE[N]). Syntax Question

GETNIB D,{#}S,#N
Get nibble N of S into D. D = {28'b0, S.NIBBLE[N]).

Instruction works very simiar to SETNIB no issue using it. But what does " D = {28'b0, S.NIBBLE[N])."
mean? Does 28'b0 somehow mean 28 original bit s masked with the addition of S.NIBBLE[N] does some one have a description of this notation. and should last bracket be" }" not ")" or is this part of the notation?
Regards and Thanks
Bob (WRD)

Comments

  • evanhevanh Posts: 16,027

    That's Verilog HDL code from the chip design files. It means 28 bits of zeros concatenated with 4 bits from S, in order, from left as most significant, to right as least significant.

  • evanhevanh Posts: 16,027
    edited 2021-08-10 21:33

    Yeah, the mismatched brackets do seem wrong to me too. Looking at the spreadsheet I see there many such duplications in that group of instructions. But further down there is examples of curly's being used for both opening and closing.

    Update: I think that syntax muddle probably came about due to Verilog using curly's for concatenation but in the instruction sheet they indicate an option list instead as well.

    Update2: Okay, more reading, parentheses seem to be only for precedence, same as general maths. So I guess it should be matching braces in that description.

  • AribaAriba Posts: 2,690

    Never seen this .NIBBLE[n] syntax in Verilog. Maybe it's pseudo verilog or Chip has defined a macro for it.
    I would write it in Verilog like this:

    D = {28'b0, S[N*4+3:N*4]};
    

    Andy

  • evanhevanh Posts: 16,027

    Yeah, I saw it as the 28b0 being the central question Bob was asking. The syntax is mixed, for sure.

  • The D= {28'b0, S[N4+3:N4]} accounts for the position of bits to add . I am going to put this into my notes . Not knowing verilog the {,} operation is concantenation function wouldn' that
    result in 00000000_00000000_00000000_0000_S[N4:+3:N4] eg N=6 should be 00000000_S[N4+3:N4]_0000_00000000_00000000 does "28'b0" with apostrophe somehow account for this when
    you interpet this.
    Regards and Thanks
    Bob (WRD)

  • evanhevanh Posts: 16,027
    edited 2021-08-12 16:44

    The S[N:M] means the parameters inside the square brackets are applied to S, not D. So, what part of S gets used for the least four bits of D is what changes.

  • Testing GETNIB D,S,#N S =N7N6N5N4N3N2N1N0 it doesn' seem to matter which nibble is written from S it is always placed in Nibble N0 of D . D = 00000000_00000000_00000000_0000_ssss
    this seems to match D = {28'b0,S[N4+3:N4]}

    Testing "GETNIB D" (using "ALTGN D,{#}S" Alter subsequent GETNIB/ROLNIB instruction. Next S field = (D[11:3] + S) & $1FF, N field = D[2:0]. D += sign-extended S[17:9]) S =N7N6N5N4N3N2N1N0 it doesn' seem to matter which nibble is written from S it is always placed in Nibble N0 of D . D = 00000000_00000000_00000000_0000_ssss D = 00000000_00000000_00000000_0000_ssss
    this seems to match D = {28'b0,S[N4+3:N4]}

    Everything resolved
    Regards and Thanks
    Bob (WRD)

  • woops corected Testing "GETNIB D" (using "ALTGN D,{#}S) result the same for syntax
    Bob (WRD)

Sign In or Register to comment.