Fabrication industrielle
Internet des objets industriel | Matériaux industriels | Entretien et réparation d'équipement | Programmation industrielle |
home  MfgRobots >> Fabrication industrielle >  >> Industrial programming >> Verilog

Encodeur de Priorité Verilog : Sélecteur Fiable 4 Entrées 8 Bits

Conception

module pr_en (
  input [7:0] a,
  input [7:0] b,
  input [7:0] c,
  input [7:0] d,
  input [1:0] sel,
  output reg [7:0] out
);
  always @ (a or b or c or d or sel) begin
    if (sel == 2'b00) out <= a;
    else if (sel == 2'b01) out <= b;
    else if (sel == 2'b10) out <= c;
    else out <= d;
  end
endmodule

Schéma matériel

Testbench

module tb_4to1_mux;
  reg [7:0] a;
  reg [7:0] b;
  reg [7:0] c;
  reg [7:0] d;
  wire [7:0] out;
  reg [1:0] sel;
  integer i;
  pr_en pr_en0 (
    .a (a), .b (b), .c (c), .d (d), .sel (sel), .out (out)
  );
  initial begin
    sel <= 0;
    a <= $random;
    b <= $random;
    c <= $random;
    d <= $random;
    for (i = 1; i < 4; i=i+1) begin
      #5 sel <= i;
    end
    #5 $finish;
  end
endmodule

Verilog

  1. Maîtriser Verilog : Tutoriel complet pour la conception de circuits numériques
  2. Maîtriser la concaténation Verilog : Guide pratique
  3. Comprendre les affectations Verilog : Types, Syntaxe et Bonnes Pratiques
  4. Verilog Blocking vs Non-Blocking : Différences Clés Expliquées
  5. Maîtriser les Fonctions Verilog pour une Conception RTL Efficace
  6. Comprendre les Tasks Verilog : Fonctions vs Tasks, Syntaxe et Utilisation
  7. Générateur d'Horloge Verilog : Guide de Conception et d'Implémentation
  8. Maîtriser les Fonctions Mathématiques Verilog pour une Conception Matérielle Efficace
  9. Maîtriser Verilog $timeformat : Contrôle de Précision et d'Affichage