2020年3月1日 星期日

EX5-7 已知五變數布林函數 F(a, b, c, d,e) = Σ(1,3,5,7,8,11,12,17,19,21,23,24,27,28)

EX5-7 已知五變數布林函數 F(a, b, c, d,e) = Σ(1,3,5,7,8,11,12,17,19,21,23,24,27,28)

//===========================
// ex5.7  F(a,b,c,d,e) circuit

module EX10_4( a ,b, c, d, e, F);

input  a ,b, c ,d ,e; // 1位元輸入

output  reg F  ; // Output    1位元輸出

always@ ( a ,b, c, d, e) begin
case ({a,b,c,d,e})
5'b0_0000: F=1'b0;
5'b0_0001: F=1'b1;
5'b0_0010: F=1'b0;
5'b0_0011: F=1'b1;

5'b0_0100: F=1'b0;
5'b0_0101: F=1'b1;
5'b0_0110: F=1'b0;
5'b0_0111: F=1'b1;

5'b0_1000: F=1'b1;
5'b0_1001: F=1'b0;
5'b0_1010: F=1'b0;
5'b0_1011: F=1'b1;

5'b0_1100: F=1'b1;
5'b0_1101: F=1'b0;
5'b0_1110: F=1'b0;
5'b0_1111: F=1'b0;

5'b1_0000: F=1'b0;
5'b1_0001: F=1'b1;
5'b1_0010: F=1'b0;
5'b1_0011: F=1'b1;

5'b1_0100: F=1'b0;
5'b1_0101: F=1'b1;
5'b1_0110: F=1'b0;
5'b1_0111: F=1'b1;

5'b1_1000: F=1'b1;
5'b1_1001: F=1'b0;
5'b1_1010: F=1'b0;
5'b1_1011: F=1'b1;

5'b1_1100: F=1'b1;
5'b1_1101: F=1'b0;
5'b1_1110: F=1'b0;
5'b1_1111: F=1'b0;

endcase

end
endmodule

//===========================
// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps     
module Test_bench;
    // Inputs
    reg a ,b, c ,d ,e ;

    // Outputs
    wire F ;

    // Instantiate the Unit Under Test (UUT)
    // Ch5.3  F(a,b,c,d) circuit 
     EX10_4  UUT (
        .a(a), 
        .b(b), 
        .c(c), 
        .d(d),
        .e(e),
        .F(F)
    );

    initial begin
        $monitor( a ,b, c, d,e, F);

        //Apply inputs
a=1'b0; b=1'b0; c=1'b0; d=1'b0; e=1'b0;
        #100;
{a,b,c,d,e}=5'b0_0001;
        #100;
{a,b,c,d,e}=5'b0_0010;
        #100;
{a,b,c,d,e}=5'b0_0011;
        #100;
{a,b,c,d,e}=5'b0_0100;
        #100;
        {a,b,c,d,e}=5'b0_0101;
        #100;
        {a,b,c,d,e}=5'b0_0110;
        #100;
{a,b,c,d,e}=5'b0_0111;
        #100;
{a,b,c,d,e}=5'b0_1000;
        #100;
{a,b,c,d,e}=5'b0_1001;
        #100;
{a,b,c,d,e}=5'b0_1010;
        #100;
{a,b,c,d,e}=5'b0_1011;
        #100;
{a,b,c,d,e}=5'b0_1100;
        #100;
{a,b,c,d,e}=5'b0_1101;
        #100;
{a,b,c,d,e}=5'b0_1110;
        #100;
{a,b,c,d,e}=5'b0_1111;
#100;
a=1'b1; b=1'b0; c=1'b0; d=1'b0; e=1'b0;
        #100;
{a,b,c,d,e}=5'b1_0001;
        #100;
{a,b,c,d,e}=5'b1_0010;
        #100;
{a,b,c,d,e}=5'b1_0011;
        #100;
{a,b,c,d,e}=5'b1_0100;
        #100;
        {a,b,c,d,e}=5'b1_0101;
        #100;
        {a,b,c,d,e}=5'b1_0110;
        #100;
{a,b,c,d,e}=5'b1_0111;
        #100;
{a,b,c,d,e}=5'b1_1000;
        #100;
{a,b,c,d,e}=5'b1_1001;
        #100;
{a,b,c,d,e}=5'b1_1010;
        #100;
{a,b,c,d,e}=5'b1_1011;
        #100;
{a,b,c,d,e}=5'b1_1100;
        #100;
{a,b,c,d,e}=5'b1_1101;
        #100;
{a,b,c,d,e}=5'b1_1110;
        #100;
{a,b,c,d,e}=5'b1_1111;
        #100;
   
    end
    initial begin
#3300  $stop;
end
endmodule
//===========================

沒有留言:

張貼留言

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

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