2020年2月6日 星期四

數位IC設計入門-Verilog combinational logic 8 to 1 Multiplexer 多工器 Behavioral Modeling (& Test Bench)

數位IC設計入門-Verilog combinational logic 
8 to 1 Multiplexer 多工器 Behavioral Modeling (& Test Bench)



//數位IC設計入門-Verilog combinational logic 
// 8 to 1 Multiplexer 多工器 Behavioral Modeling (& Test Bench)

 module MUX8x1(a, b, c, d, e, f, g, h, select, out);
  input a, b, c, d, e, f, g, h;
  input [2:0] select;
  output out;
  reg out;
  
  always@(a or b or c or d or e or f or g or h or select)
  begin
        case(select)
        3'd0 : out = a;
        3'd1 : out = b;
        3'd2 : out = c;
        3'd3 : out = d;
        3'd4 : out = e;
        3'd5 : out = f;
        3'd6 : out = g;
        3'd7 : out = h;
        endcase
  end

  endmodule

// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps    
module Test_bench;
  //module MUX8x1(a, b, c, d, e, f, g, h, select, out);
  //input a, b, c, d, e, f, g, h;
  //input [2:0] select;
  //output out;

// Inputs
reg a=0, b=0, c=0, d=0, e=0, f=0, g=0, h=0;
reg [2:0] select=3'b000;

// Outputs
wire out;


// Instantiate the Unit Under Test (UUT)
//DECODER3X8(enable, in, out);

MUX8x1 UUT(a, b, c, d, e, f, g, h, select, out);

initial begin
 $monitor(a, b, c, d, e, f, g, h, select, out);
    // Initialize Inputs
 //#25 {a,b,c,d,e,f,g,h}=8'b0000_0000 ; select[2:0]=3'b000 ;
 #25 {a,b,c,d,e,f,g,h}=8'b1000_0000 ; select[2:0]=3'b000 ;

 #25 {a,b,c,d,e,f,g,h}=8'b0000_0000 ; select[2:0]=3'b001 ;
 #25 {a,b,c,d,e,f,g,h}=8'b0100_0000 ; select[2:0]=3'b001 ;

 #25 {a,b,c,d,e,f,g,h}=8'b0000_0000 ; select[2:0]=3'b010 ;
 #25 {a,b,c,d,e,f,g,h}=8'b0010_0000 ; select[2:0]=3'b010 ;

 #25 {a,b,c,d,e,f,g,h}=8'b0000_0000 ; select[2:0]=3'b011 ;
 #25 {a,b,c,d,e,f,g,h}=8'b0001_0000 ; select[2:0]=3'b011 ;

 #25 {a,b,c,d,e,f,g,h}=8'b0000_0000 ; select[2:0]=3'b100 ;
 #25 {a,b,c,d,e,f,g,h}=8'b0000_1000 ; select[2:0]=3'b100 ;

 #25 {a,b,c,d,e,f,g,h}=8'b0000_0000 ; select[2:0]=3'b101 ;
 #25 {a,b,c,d,e,f,g,h}=8'b0000_0100 ; select[2:0]=3'b101 ;

 #25 {a,b,c,d,e,f,g,h}=8'b0000_0000 ; select[2:0]=3'b110 ;
 #25 {a,b,c,d,e,f,g,h}=8'b0000_0010 ; select[2:0]=3'b110 ;

 #25 {a,b,c,d,e,f,g,h}=8'b0000_0000 ; select[2:0]=3'b111 ;
 #25 {a,b,c,d,e,f,g,h}=8'b0000_0001 ; select[2:0]=3'b111 ;



end

initial
begin
  #425;   // 模擬終止時間  425 ns
  $stop;
end


endmodule

  
  

沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...