Sep 11, 2013 #1 A arishsu Member level 3 Joined Sep 10, 2013 Messages 66 Helped 6 Reputation 12 Reaction score 6 Trophy points 8 Location India Visit site Activity points 422 Is this syntax is right for 4:1 mux output? assign Y=(S==0x)?((S==00)? I[0]:I[1])((S==1x)?((S==10)? I[2]:I[3])); S is 2 bit reg(select line), I is 4 bit reg(input) and Y output.
Is this syntax is right for 4:1 mux output? assign Y=(S==0x)?((S==00)? I[0]:I[1])((S==1x)?((S==10)? I[2]:I[3])); S is 2 bit reg(select line), I is 4 bit reg(input) and Y output.
Sep 11, 2013 #2 mrflibble Advanced Member level 5 Joined Apr 19, 2010 Messages 2,720 Helped 679 Reputation 1,360 Reaction score 652 Trophy points 1,393 Visit site Activity points 19,551 Best get rid of the x don't cares. See this thread for some examples. Personally I use something like this: Code: assign o= (s[0]==0)?((s[1]==0)?i[0]:i[1]):((s[1]==0)?i[2]:i[3]);
Best get rid of the x don't cares. See this thread for some examples. Personally I use something like this: Code: assign o= (s[0]==0)?((s[1]==0)?i[0]:i[1]):((s[1]==0)?i[2]:i[3]);
Sep 11, 2013 #3 A arishsu Member level 3 Joined Sep 10, 2013 Messages 66 Helped 6 Reputation 12 Reaction score 6 Trophy points 8 Location India Visit site Activity points 422 Thank you..
Sep 11, 2013 #4 ads-ee Super Moderator Staff member Joined Sep 10, 2013 Messages 7,944 Helped 1,823 Reputation 3,656 Reaction score 1,808 Trophy points 1,393 Location USA Visit site Activity points 60,209 mrflibble said: Best get rid of the x don't cares. See this thread for some examples. Personally I use something like this: Code: assign o= (s[0]==0)?((s[1]==0)?i[0]:i[1]):((s[1]==0)?i[2]:i[3]); Click to expand... A little formatting might make it more readable... Code Verilog - [expand]1 2 3 4 assign o = (s[0]==0) ? ([s[1]==0) ? i[0] // 00 : i[1]) // 10 : ((s[1]==0) ? i[2] // 01 : i[3]); // 11
mrflibble said: Best get rid of the x don't cares. See this thread for some examples. Personally I use something like this: Code: assign o= (s[0]==0)?((s[1]==0)?i[0]:i[1]):((s[1]==0)?i[2]:i[3]); Click to expand... A little formatting might make it more readable... Code Verilog - [expand]1 2 3 4 assign o = (s[0]==0) ? ([s[1]==0) ? i[0] // 00 : i[1]) // 10 : ((s[1]==0) ? i[2] // 01 : i[3]); // 11
Sep 12, 2013 #5 mrflibble Advanced Member level 5 Joined Apr 19, 2010 Messages 2,720 Helped 679 Reputation 1,360 Reaction score 652 Trophy points 1,393 Visit site Activity points 19,551 ads-ee said: A little formatting might make it more readable... Click to expand... Fully agreed. I was just reciprocating laziness, and as such did a quick copy/paste from that other thread with the kind of code snippet I'd use.
ads-ee said: A little formatting might make it more readable... Click to expand... Fully agreed. I was just reciprocating laziness, and as such did a quick copy/paste from that other thread with the kind of code snippet I'd use.