#28 casex vs casez in verilog | Explained with verilog code

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ม.ค. 2025

ความคิดเห็น • 39

  • @jitubaba5450
    @jitubaba5450 4 ปีที่แล้ว +1

    Thank you for sharing. Always love learning your verilog tutorial.

  • @abhilash29130
    @abhilash29130 ปีที่แล้ว

    at 10:24 , Sir u have said XX can be 1X, 0X, X0. So according to it when a=0X then b should be equal to 1 instead of 0 ?

    • @ComponentByte
      @ComponentByte  ปีที่แล้ว

      For casex
      When a=0X
      b=0
      When a=XX
      b=1

    • @abhilash29130
      @abhilash29130 ปีที่แล้ว

      As u have said in 1st example of casex,
      2'b1X = 2'b10, 2'b11, 2'b1X, 2'b1Z and 1 should be fix and X should change
      So, why in testbench code in casex 2'b1X as, a=XX is taken? Will here 1 is not fixed ?
      [I mean how XX is inside casex ?]
      Please clarify..

    • @ComponentByte
      @ComponentByte  ปีที่แล้ว

      Xx can be 1x,0x,x1,x0,00,01,10,11 and few others for casex only and not case.
      So when a=xx it results b=1 as here xx can be 1x also

    • @abhilash29130
      @abhilash29130 ปีที่แล้ว

      Sir then why,
      When a=0X
      b=0
      It should be b=1 right ?
      I am bit confused in this!!
      Please clarify..

    • @ComponentByte
      @ComponentByte  ปีที่แล้ว

      When a=0X
      Here second bit is fixed that is 0 and can't be changed and 1st bit is X so can be 0,1,Z
      So 0x can't be 1x
      For 1X , we get b=1 for 10,11,1x,1z and for rest we get 0

  • @ujwalkumarbcj9362
    @ujwalkumarbcj9362 10 หลายเดือนก่อน +1

    Hi sir, at 10:25 you took case expression as 2'bxx (i.e a = 2'bxx) and we have case item as 2'b1x, you said that it will match the case statement, so the b became 1. When I tried from my side
    for the below code I am getting
    Matched for case items: 00 ,01,0x,0z,x0,x1,xz,xx,z0,z1,zx,zz
    Not Matched for case items: 10,11,1x,1z
    module tb;
    reg [0:0] a=2'bxx,b;
    initial begin
    casex(a)
    2'b1x: $display("Matched");
    default: $display("Not Matched");
    endcase
    end
    endmodule
    my doubt is as we are giving case expression as 2'bxx , then it should match the case items (10,11,1x,1z also). But here it is not happening. Could you please give me clarification regarding this?

    • @ujwalkumarbcj9362
      @ujwalkumarbcj9362 10 หลายเดือนก่อน +1

      It’s now resolved sir, I did a mistake while declaring varibales it should be reg [1:0] a,b;
      Now for all the values i am getting b = 1 .
      Thank you for the explanation sir

  • @rajsambhav665
    @rajsambhav665 2 ปีที่แล้ว +1

    Great explanation.
    what if there are multiple ones in the input.
    e.g
    for an input encoding = 4'b011x
    which next state will be executed ?

    • @ComponentByte
      @ComponentByte  2 ปีที่แล้ว

      Thank you.
      It is decided by simulator. 011x equals 0110 and 0111 so next can be 8,9,10.... so 1xxx is enough for 8 to 15

  • @teketinikhilkumar7905
    @teketinikhilkumar7905 2 ปีที่แล้ว +1

    sir In 1st example , given encoding =10xz it can be 101z right so in the third case(xx1x = 101z) so cant we write next state=1

    • @ComponentByte
      @ComponentByte  2 ปีที่แล้ว

      It's decided by simulator.
      If input=10xz then simulator will first check 1st case : if it matches then it will give 1st case output, if no matches it will go to next state.
      Thus 10xz matches 1st case 1xxx so simulator stops there and gives corresponding output .

    • @teketinikhilkumar7905
      @teketinikhilkumar7905 2 ปีที่แล้ว

      @@ComponentByte thank you sir

  • @Deadpie_speaking
    @Deadpie_speaking 2 ปีที่แล้ว +1

    Sir in case statement eg. Case( s1, s2) =case(s1, s2) are same ????

    • @ComponentByte
      @ComponentByte  2 ปีที่แล้ว

      No.They are different. 'case' is case sensitive(If I have written somewhere then it's just an example and definitely it's not in program)

  • @digambarbhole9467
    @digambarbhole9467 ปีที่แล้ว +1

    sir,
    what is the physical significance of caseX and caseZ statements? can you please clear it?

    • @ComponentByte
      @ComponentByte  ปีที่แล้ว

      This is a tool dependent construct means it generates a piece of different hardware as described in a synthesis tool.
      It generates mostly MUX based hardware.

    • @digambarbhole9467
      @digambarbhole9467 ปีที่แล้ว

      Ok thank you sir

  • @darageorgieva3203
    @darageorgieva3203 ปีที่แล้ว

    Imagine we are in casex and we have 3'b1xz as in the first slide of the presentation. Aren't the possible options: 3'b1xz, 3'b1zx, 3'b1zz, 3'b1xx, 3'b100, 3'b101, 3'b110 and 3'b111?

    • @ComponentByte
      @ComponentByte  ปีที่แล้ว

      Yes, you are absolutely correct.

  • @muhammedsayedm8174
    @muhammedsayedm8174 9 หลายเดือนก่อน

    In case of casex why xz=zx compilation is not coming

  • @prasannan2084
    @prasannan2084 2 ปีที่แล้ว +1

    In casex 2'bzz also possible right?

    • @ComponentByte
      @ComponentByte  2 ปีที่แล้ว

      Yes, possible. 2'bzz , here zz is considered as 2 don't care.
      zz can be 00,01,10,11

  • @SebJames55
    @SebJames55 3 ปีที่แล้ว +1

    Thank you 😁

  • @vishalmoladiya2735
    @vishalmoladiya2735 3 ปีที่แล้ว +2

    Nice explanation:
    But in the last example
    When a=xx then I think b=1 and c=1 or 0 in c value I confused because in verilog casex has value of x is 0 1 x and z!
    But in simulation x take only value of 0 and 1 ? Is this r8?

    • @ComponentByte
      @ComponentByte  3 ปีที่แล้ว +1

      In casex X value can be 0 or 1 and Z value can be 0 or 1.
      X is 0,1,X
      Z is 0,1,Z

    • @hulkmania9487
      @hulkmania9487 2 ปีที่แล้ว +1

      @@ComponentByte so why in starting u have taken 2'b1Z (first example in casex)

    • @ComponentByte
      @ComponentByte  2 ปีที่แล้ว

      You mean why 2'b1X = 2'b1Z ?
      If it's your query then in casex all X and Z can be considered as don't care so X can be 0,1,X,Z
      So 2'b1x = 2'b10,11,1x,1z
      Don't care means your output doesn't depend on those input bits.
      If it's not your query then please let me know.

    • @hulkmania9487
      @hulkmania9487 2 ปีที่แล้ว +1

      @@ComponentByte cleared 👌

  • @sarathchandra5305
    @sarathchandra5305 4 ปีที่แล้ว

    can you tell me where do we use the casez in real time?

    • @ComponentByte
      @ComponentByte  4 ปีที่แล้ว +1

      It can be used to design multiplexer if resources are available.
      Casez is used for testing the RTL code. During verification process code coverage is done to test every lines of code to check whether every lines of code is executed with valid input or not.
      In casez Z means if input is souriously 1 or 0 then the output should not be propagated and must be filtered out. Hope it helps.

  • @shivammahato163
    @shivammahato163 ปีที่แล้ว

    what is casee instl ?

    • @ComponentByte
      @ComponentByte  ปีที่แล้ว

      casee is module name (in module casee() )and inst1 is the name of module instatitaion.it can be any name you wish to write.

    • @shivammahato163
      @shivammahato163 ปีที่แล้ว +1

      @@ComponentByte thank you