2012年10月11日 星期四

8x1 MUX 改寫成DE2 實驗板執行程式 (import pin assignment)

8x1 MUX 改寫成DE2 實驗板執行程式 (import pin assignment)
1) 2x1 Mux
2) 4x1 MUX

3). 8X1 MUX
//==========================================
module de2_mux8x1 (SW, LEDR, LEDG);
input [17:0] SW; // toggle switches
output [17:0] LEDR; // red LEDs    
  output [7:0] LEDG; // green LEDs
  
wire [7:0]I;        //input 8 bit
wire [2:0]S;
wire Y8;
    wire [1:0]y8;
   
    //mapping to hardware 
    assign LEDR = SW;
assign I = SW[7:0];
assign S = SW[11:8];
mux4x1 UUT41 (.I(I[3:0]),.S(S[1:0]),.Y4(y8[0]));//mux4x1 (I0,I1,S,Y) 2x1 mux 
    mux4x1 UUT42 (.I(I[7:4]),.S(S[1:0]),.Y4(y8[1]));//mux4x1 (I0,I1,S,Y) 2x1 mux 
    mux2x1 UUT43 (.I(y8[1:0]),.S(S[2]),.Y2(Y8)); //mux2x1 (I0,I1,S,Y) 2x1 mux 

    assign LEDG[0]=Y8;

endmodule

// orginal program    
//module mux8x1 (I,S,Y8);//2x1 mux 
// input [7:0]I;
// input [2:0]S;
// output Y8;
// wire [1:0]y8;
// mux4x1 UUT41 (.I(I[3:0]),.S(S[1:0]),.Y4(y8[0]));//mux4x1 (I0,I1,S,Y) 2x1 mux 
//  mux4x1 UUT42 (.I(I[7:4]),.S(S[1:0]),.Y4(y8[1]));//mux4x1 (I0,I1,S,Y) 2x1 mux 
//  mux2x1 UUT43 (.I(y8[1:0]),.S(S[2]),.Y2(Y8));//mux2x1 (I0,I1,S,Y) 2x1 mux 
// endmodule


//=============================================


module mux4x1 (I,S,Y4);//2x1 mux 
input [3:0]I;
input [1:0]S;
output Y4;

wire [1:0]y4;

mux2x1 UUT21 (.I(I[1:0]),.S(S[0]),.Y2(y4[0])); //mux2x1 (I0,I1,S,Y) 2x1 mux 

    mux2x1 UUT22 (.I(I[3:2]),.S(S[0]),.Y2(y4[1]));//mux2x1 (I0,I1,S,Y) 2x1 mux 
    
    mux2x1 UUT23 (.I(y4[1:0]),.S(S[1]),.Y2(Y4));//mux2x1 (I0,I1,S,Y) 2x1 mux 
    
   
endmodule


//=========================================

module mux2x1 (I,S,Y2);//2x1 mux 
input [1:0]I;
input S;
output Y2;

bufif0(Y2,I[0],S);   //2x1 mux 
    bufif1(Y2,I[1],S);
    
endmodule

//======================================================

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...