File: mux2.v

package info (click to toggle)
iverilog 12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,148 kB
  • sloc: cpp: 109,972; ansic: 62,713; yacc: 10,216; sh: 3,470; vhdl: 3,246; perl: 1,814; makefile: 1,774; python: 78; csh: 2
file content (37 lines) | stat: -rw-r--r-- 519 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * A simple test of some of the structural elements.
 */

module testbench;
  wire o;
  reg  i0, i1, sel;

  mux2 uut(o, i0, i1, sel);

  initial begin
    i0 <= 1;
    i1 <= 0;
    sel <= 0;
    #1;
    sel <= 1;
    #1;
    i1 <= 1;
    #1;
  end

  always @(o)
    $display(o);

endmodule // testbench

module mux2(c, a, b, s);
  input a, b, s;
  output c;
  wire s_bar, a_and_s_bar, b_and_s;

  not(s_bar, s);
  and(a_and_s_bar, a, s_bar);
  and(b_and_s, b, s);
  or(c, a_and_s_bar, b_and_s);

endmodule // mux2