1-2 Verilog 4位 二选一 多路选择器

  • Post author:
  • Post category:其他


使用工具:Xilinx ISE 14.7

如原理图所示,用信号s选择输入a和b作为输出y,代码如下:

module code(
    input wire [3:0]a,
    input wire [3:0]b,
    input wire s,
    output wire [3:0]y
    );
assign y = s? b : a;

endmodule

仿真代码:

initial begin
		// Initialize Inputs
		a = 12;
		b = 3;
      s = 0;

		// Wait 100 ns for global reset to finish
		#100;
		
		a = 12;
		b = 3;
      s = 0;
		
		#100;
        
		// Add stimulus here

	end

仿真结果:




版权声明:本文为hyhop150原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。