You can use same test bench for all the multiplexer codes here. This output and wave diagrams are same for all the codes. This example is very similar to previous one, but instead of using continuous assignments, here always statement is used. Left side of expressions inside an always block must be of register type. So, here q is.
can't put my finger on why is it not working, I ran a simulation on eda playground and I get an 'x' in the output every time the select changes to 0. I properly get '1' when sel is '1' though. thanks!
the code:
and the testbench:
Roman Andreevitch Biriukov
Roman Andreevitch BiriukovRoman Andreevitch Biriukov
1 Answer
I can't reproduce your results; the
OUT
signal is always known for me.But, I do get a compile warning:
This can be fixed:
In your code
sel
inherited the width from the previous signal ([3:0]b
). Your code is equivalent to:Adding another
input
keyword before sel
forces it to use the default width of 1 bit.toolictoolic