2021年4月20日 星期二

HBLbits_Verilog Basic_Gates4

 HBLbits_Verilog Basic_Gates4

Build a combinational circuit with four inputs, in[3:0].

There are 3 outputs:

  • out_and: output of a 4-input AND gate.
  • out_or: output of a 4-input OR gate.
  • out_xor: output of a 4-input XOR gate.

module top_module( 
    input [3:0] in,
    output out_and,
    output out_or,
    output out_xor
);
    wire [3:0] in1;
    wire xor12,xor34;
    assign in1=~in;
    assign out_and=in[0]&&in[1]&&in[2]&&in[3];
    assign out_or=in[0]||in[1]||in[2]||in[3];
    assign xor12=~((in1[0]||in1[1])&&(in[0]||in[1]));
    assign xor34=~((in1[2]||in1[3])&&(in[2]||in[3]));
    assign out_xor=(((~xor12)||(~xor34))&&(xor12||xor34));
endmodule

沒有留言:

張貼留言

Modbus FC=1 (Coils read) & FC=15 (Coils Write)

Modbus FC=1  (Coils read)  & FC=15 (Coils Write)   「從 Modbus 設備讀取多個線圈(Coils)狀態,並立刻將這些狀態原封不動地轉寫到另一個記憶體位址(起始位址 16)」 。 整個流程使用了知名套件 node-red...