0
\$\begingroup\$

I need to create a MUX block that works with inout pins. My module has n inputs and n outputs. I want to be able to switch between different outputs.

The problem is that I need to do that with inout pins; if my output pin is pulled down, the input pin of the MUX should see that. This doesn't work with a common assign statement, since it will only write in one direction. I have tried an alias statement, which works like a bidirectional assign, but I can't combine this with an if statement for the MUX.

What I want to do:

alias net_out = (config) ? net1 : net2;

I have created an example on edaplayground

\$\endgroup\$

3 Answers 3

1
\$\begingroup\$

It would have helped if you mentioned the fact that you are using real number nets to start with. SystemVerilog's tran primitives are only defined with Verilog's wire strength model, and to do what you want requires that you define your own resolution model which very few simulators have implemented yet.

More likely you are thinking in terms of analog (AMS) design and need to move up a level of abstraction to get what you want in SystemVerilog.

Update: IEEE SystemVerilog Std p1800-2023 has updated the standard to allow user defined nets connected to tran primitives.

\$\endgroup\$
1
  • \$\begingroup\$ I have a resolution model and a simulator that supports real number nets. My current work-around is to instantiate the blocks in a top-block and abstract the "switches" as high-Z mathematically. It is not the most elegant solution, but it works for now. \$\endgroup\$
    – ptrck
    Commented Jul 4, 2018 at 7:29
0
\$\begingroup\$

If you are trying to model a bidirectional mux, the tranif primitives might be more appropriate/easier, depending on what your end goal is.

tranif1 #(t_on, t_off) ( a, b, ena);

so

tranif1 #(1, 1) ( net1, net2, config );

tranif0 #(1, 1) ( net2, net1, config );

\$\endgroup\$
3
  • \$\begingroup\$ Yes thats what I am trying to do, the problem is that I do not know which port is driving at which moment, so i can not switch the direction manually. Is that a Problem with the tranif function? \$\endgroup\$
    – ptrck
    Commented Jun 25, 2018 at 14:22
  • \$\begingroup\$ Ok, I just tried that and I can not use it with real number nets. \$\endgroup\$
    – ptrck
    Commented Jun 25, 2018 at 14:49
  • \$\begingroup\$ tranif models a FET switch, which is directionless. The control enables the connection only. If you are trying to actively read/drive bidir signals without knowing the direction, you are going to have issues (look at bidirectional voltage translator devices to see how difficult it is) \$\endgroup\$
    – GMilliorn
    Commented Jun 25, 2018 at 15:23
0
\$\begingroup\$

This is the problem that the new alias construct was designed to solve. Alias means "these two symbols refer to the same net."

alias foo = bar;

alias is supported by xcelium, but unfortunately, some PD tools don't yet support the alias construct.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.