Industriële fabricage
Industrieel internet der dingen | Industriële materialen | Onderhoud en reparatie van apparatuur | Industriële programmering |
home  MfgRobots >> Industriële fabricage >  >> Industrial programming >> Verilog

4-bit Johnson Teller in Verilog – Ontwerp, Testbench & Simulatie

Johnson teller diagram

Ontwerp

module johnson_ctr #(parameter WIDTH=4) (
  input clk,
  input rstn,
  output reg [WIDTH-1:0] out
);
  always @ (posedge clk) begin
    if (!rstn) out <= 1;
    else begin
      out[WIDTH-1] <= ~out[0];
      for (int i = 0; i < WIDTH-1; i = i+1) begin
        out[i] <= out[i+1];
      end
    end
  end
endmodule

Testbench

module tb;
  parameter WIDTH = 4;
  reg clk;
  reg rstn;
  wire [WIDTH-1:0] out;
  johnson_ctr u0 (.clk (clk), .rstn (rstn), .out (out));
  always #10 clk = ~clk;
  initial begin
    {clk, rstn} <= 0;
    $monitor ("T=%0t out=%b", $time, out);
    repeat (2) @(posedge clk);
    rstn <= 1;
    repeat (15) @(posedge clk);
    $finish;
  end
endmodule

Simulatie Log:

ncsim> run
T=0 out=xxxx
T=10 out=0001
T=50 out=0000
T=70 out=1000
T=90 out=1100
T=110 out=1110
T=130 out=1111
T=150 out=0111
T=170 out=0011
T=190 out=0001
T=210 out=0000
T=230 out=1000
T=250 out=1100
T=270 out=1110
T=290 out=1111
T=310 out=0111
Simulation complete via $finish(1) at time 330 NS + 0

Verilog

  1. Verilog beheersen: Complete tutorial voor digitale schakelingontwerp
  2. Verilog concatenatie beheersen: Een praktische gids
  3. Verilog-toewijzingen begrijpen: types, syntax en best practices
  4. Verilog Blocking vs. Non-Blocking: belangrijkste verschillen uitgelegd
  5. Verilog-functies beheersen voor efficiënt RTL-ontwerp
  6. Verilog Tasks begrijpen: Functions vs Tasks, Syntax en Gebruik
  7. Verilog Clock Generator: Ontwerp & Implementatie Gids
  8. Verilog Math Functions beheersen voor efficiënt Hardware-ontwerp
  9. Verilog $timeformat beheersen: Precisie en Weergave-controle
  10. Verilog Mod-N Teller Ontwerp: Geparametriseerde Module & Testbench
  11. Verilog Gray-code Teller Module – 4-bit Gray Code Generator