SlideShare una empresa de Scribd logo
1 de 6
Descargar para leer sin conexión
More Verilog                                                                  8-bit Register with Synchronous Reset


                                                                                    module     reg8 (reset, CLK, D, Q);
                                                                                    input          reset;
                                                                                    input          CLK;
                                                                                    input      [7:0] D;
                                                                                    output     [7:0] Q;
                                                                                    reg         [7:0] Q;

                                                                                        always @(posedge CLK)
                                                                                          if (reset)
                                                                                            Q = 0;
                                                                                          else
                                                                                            Q = D;

                                                                                    endmodule        // reg8



                                    Verilog - 1                                                                Verilog - 2




N-bit Register with Asynchronous Reset                                        Shift Register Example

                                                                               // 8-bit register can be cleared, loaded, shifted left
      module regN (reset, CLK, D, Q);                                          // Retains value if no control signal is asserted
      input      reset;
      input      CLK;                                                          module   shiftReg (CLK, clr, shift, ld, Din, SI, Dout);
                                                                               input            CLK;
      parameter N = 8;    // Allow N to be changed
                                                                               input            clr;           // clear register
      input [N-1:0] D;
                                                                               input            shift;         // shift
      output [N-1:0] Q;                                                        input            ld;            // load register from Din
      reg    [N-1:0] Q;                                                        input    [7:0] Din;             // Data input for load
                                                                               input            SI;            // Input bit to shift in
              always @(posedge CLK or posedge reset)                           output   [7:0] Dout;
                if (reset)                                                     reg      [7:0] Dout;
                  Q = 0;
                else if (CLK == 1)                                               always @(posedge CLK) begin
                                                                                   if (clr)          Dout <= 0;
                  Q = D;
                                                                                   else if (ld)      Dout <= Din;
                                                                                   else if (shift)   Dout <= { Dout[6:0], SI };
      endmodule          // regN                                                 end

                                                                               endmodule                 // shiftReg
                                    Verilog - 3                                                                Verilog - 4




Blocking and Non-Blocking Assignments                                         Swap (continued)

                            Q = A                                                          %         %

          !                                       "                                 %
  #   $                         Q <= A
                                                                                    always @(posedge CLK)      always @(posedge CLK)
                                                                                        begin                      begin
                                                                                            A = B;                     B = A;
                                         %                                              end                        end
                  &
                                                           !                    (
                                                                                                                  posedge CLK
  '       % & ! %
                                                                                    always @(posedge CLK)      always @(posedge CLK)
                 always @(posedge CLK)                                                  begin                      begin
                                                      always @(posedge CLK)                 A <= B;                    B <= A;
                     begin                                begin
                          temp = B;                                                     end                        end
                                                               A <= B;
                          B = A;                               B <= A;
                          A = temp;                       end
                     end
                                    Verilog - 5                                                                Verilog - 6
Non-Blocking Assignment                                                                         Counter Example

    #      $                                            !               )
                            !                                                                          %        %       !                                  %
                            $                $                      *         %$    %                           0                                   1 22

               & + ), + -               ./       "              %

 // this implements 3 parallel flip-flops
 always @(posedge clk)                                                                             // 8-bit counter with clear and count enable controls
    begin                                                                                          module count8 (CLK, clr, cntEn, Dout);
        B = A;    // this implements a shift register                                              input          CLK;
        C = B;    always @(posedge clk)
        D = C;                                                                                     input          clr;           // clear counter
                     begin
    end                  {D, C, B} = {C, B, A};
                                                                                                   input          cntEn;         // enable count
                     end                                                                           output [7:0] Dout;            // counter value
                                                     // this implements a shift register
                                                                                                   reg    [7:0] Dout;
                                                     always @(posedge clk)
                                                        begin                                         always @(posedge CLK)
                                                            B <= A;                                     if (clr)          Dout <= 0;
                                                            C <= B;                                     else if (cntEn)   Dout <= Dout + 1;
                                                            D <= C;
                                                        end                                        endmodule
                                                 Verilog - 7                                                                         Verilog - 8




Finite State Machines                                                                           Verilog FSM - Reduce 1s example

                                                                                                                    4       5                        46
                                                                    Mealy outputs                      '    %                        %

                                                 next state         Moore outputs
  inputs
                       combinational                                                               // State assignment
                          logic                                                                    parameter zero = 0, one1 = 1, two1s = 2;

                                                                        current state              module reduce (clk, reset, in, out);
                                                                                                     input clk, reset, in;
                                                                                                     output out;
                                                                                                     reg out;
                                                                                                     reg [1:0] state;       // state register
                                                                                                     reg [1:0] next_state;

                                    %                                                              // Implement the state register
                                                                                                     always @(posedge clk)
           3 %                                                           !                             if (reset) state = zero;
           3 %                  %                                                       !              else       state = next_state;




                                                 Verilog - 9                                                                         Verilog - 10




Moore Verilog FSM (cont’d)                                                                      Mealy Verilog FSM for Reduce-1s example

  always @(in or state)                                                                         module reduce (clk, reset, in, out);
    case (state)                                                                                  input clk, reset, in;
      out = 0;         // defaults                                                                output out;
      next_state = zero;                                                                          reg out;
      zero: begin      // last input was a zero                                                   reg state;            // state register
        if (in) next_state = one1;                                                                reg next_state;
      end                                                                                         parameter zero = 0, one = 1;

                                                                                                  always @(posedge clk)
        one1: begin      // we've seen one 1                                                        if (reset) state = zero;
        if (in) next_state = two1s;                                                                 else       state = next_state;
        end
                                                                                                  always @(in or state)
      two1s:    begin // we've seen at least 2 ones                                                 out = 0;
         out = 1;                                                                                   next_state = zero;
         if (in) next_state = two1s;                                                                case (state)
      end                                                                                           zero: begin          // last input was a zero
        // Don’t need case default because of default assignments                                     if (in) next_state = one;
endcase                                                                                             end
endmodule                                                                                           one:      // we've seen one 1
                                                                                                      if (in) begin
                                                                                                         next_state = one; out = 1;
                                                                                                      end
                                                                                                    endcase
                                                                                                endmodule

                                                 Verilog - 11                                                                        Verilog - 12

                                                                                            6
Single-always Moore Machine
Restricted FSM Implementation Style                                                                     (Not Recommended!)


                            "       !        !
                                %           )7                                                             module reduce (clk, reset, in, out);
            %           %                                                                                    input clk, reset, in;
                                                                                                             output out;
                                        !                      !                                             reg out;
                                                                                                             reg [1:0] state;       // state register
           22      %                                                                                         parameter zero = 0, one1 = 1, two1s = 2;


                                                                   %
                  %
                  !                         1




                                                Verilog - 13                                                                             Verilog - 14




Single-always Moore Machine
(Not Recommended!)                                                                                      Delays

  always @(posedge clk)
    case (state)
                                                                       All outputs are registered
     zero: begin
           out = 0;
           if (in) state = one1;
           else     state = zero;
        end
     one1:                                                                                                      3                                   1   0   !
        if (in) begin
             state = two1s;                                                                                     %          !
             out = 1;
        end else begin                                         This is confusing: the                      8 45                  45
             state = zero;
             out = 0;                                          output does not change
        end                                                    until the next clock cycle                 module and_gate (out, in1, in2);
     two1s:
        if (in) begin                                                                                       input         in1, in2;
            state = two1s;
            out = 1;                                                                                        output        out;
        end else begin
            state = zero;

        end
            out = 0;                                                                                           assign #10 out = in1 & in2;
      default: begin
           state = zero;
           out = 0;                                                                                       endmodule
        end
    endcase
endmodule
                                                Verilog - 15                                                                             Verilog - 16

                                                                                                    6




Verilog Propagation Delay                                                                               Initial Blocks

           !                                                                                               )        !

       assign #5 c = a | b;                                                                                               0
       assign #4 {Cout, S} = Cin + A + B;

       always @(A or B or Cin)
          #4 S = A + B + Cin;
          #2 Cout = (A & B) | (B & Cin) | (A & Cin);

       assign #3 zero = (sum == 0) ? 1 : 0;

       always @(sum)
          if (sum == 0)
              #6 zero = 1;
          else
              #3 zero = 0;

                                                Verilog - 17                                                                             Verilog - 18
Tri-State Buffers                                                                         Test Fixtures

                                                                                            <
   9: 6                  $
                                                                                            <                          =
               %     %             $                                ;
                                                                                                                                    %             %


   module tstate (EnA, EnB, BusA, BusB, BusOut);
     input EnA, EnB;                                                                                 %       %
     input [7:0] BusA, BusB;
     output [7:0] BusOut;                                                                                1       1         =!           1     2

     assign BusOut = EnA ? BusA : 8’bZ;                                                                                            Simulation
     assign BusOut = EnB ? BusB : 8’bZ;
   endmodule
                                                                                                                  Test Fixture                        Circuit Description
                                                                                                                 (Specification)                      (Synthesizeable)




                                       Verilog - 19                                                                                Verilog - 20




Verilog Clocks                                                                            Verilog Clocks

          >                                                                                 +
   module clockGenerator (CLK);
     parameter period = 10;                                                               module clock_gen (masterclk);                                           ! "
     parameter howlong = 100;                                                                                                                                        "
     output         CLK;
     reg            CLK;                                                                        `define PERIOD = 10;

     initial begin                                                                              output masterclk;
       CLK = 0;                                                                                 reg    masterclk;
       #(period/2);
       repeat (howlong) begin
         CLK = 1;                                                                               initial masterclk = 0;
         #(period-period/2);
         CLK = 0;                                                                               always begin                                                                "       #
         #(period/2);
       end
                                                                                                    #`PERIOD/2
       $finish;                                                                                     masterclk = ~masterclk;
     end                                                                                        end
   endmodule                     // clockGenerator
                                                                                          endmodule
                                       Verilog - 21                                                                                Verilog - 22




Example Test Fixture                                                                      Simulation Driver


  module stimulus (a, b, c);
                                                                                          module stimulus               (a, b);
    parameter    delay = 10;                    module full_addr1 (A, B, Cin, S, Cout);
                                                  input     A, B, Cin;
                                                                                            parameter                   delay = 10;
    output       a, b, c;
    reg    [2:0] cnt;                             output    S, Cout;                        output                      a, b;                                $%
    initial begin                                 assign {Cout, S} = A + B + Cin;           reg [1:0]                   cnt;
      cnt = 0;                                  endmodule
      repeat (8) begin
        #delay cnt=cnt+1;                                                                       initial begin                                                               &
      end
      #delay $finish;                                                                             cnt = 0;                                               #                      "
    end
                                                                                                  repeat (4) begin
    assign {c, a, b} = cnt;
  endmodule
                                                                                                    #delay cnt = cnt + 1;
                                                                                                  end
  module driver;      // Structural Verilog connects test-fixture to full adder
    wire       a, b, cin, sum, cout;                                                              #delay $finish;
    stimulus   stim (a, b, cin);
    full_addr1 fa1 (a, b, cin, sum, cout);                                                      end
    initial begin
      $monitor ("@ time=%0d cin=%b, a=%b, b=%b, cout=%d, sum=%d",                           assign {a, b} = cnt;
                   $time, cin, a, b, cout, sum);
    end                                                                                   endmodule
  endmodule
                                       Verilog - 23                                                                                Verilog - 24
Test Vectors                                                                                          Verilog Simulation


              module testData(clk, reset, data);
                                                                                                        3       %                   2         %
                input clk;                                                                                  %
                output reset, data;
                reg [1:0] testVector [100:0];                                                           )
                reg reset, data;
                integer count;

                  initial begin                                                                                             %
                    $readmemb("data.b", testVector);
                    count = 0;                                                                                                                                                            0       ?
                    { reset, data } = testVector[0];
                  end

                always @(posedge clk) begin
                  count = count + 1;
                  #1 { reset, data } = testVector[count];
                end
              endmodule




                                                Verilog - 25                                                                                                           Verilog - 26




Intepreted vs. Compiled Simulation                                                                    Simulation Level

  3       %                                                                                             '
                                                                 %                                                                                     "
                        !                                                         !                         %                                      %           !
                            &
                                            "        1                                                                                                                          !         $
                     1%             !                    "        1   %
      %
                                                                                                        >
          %                                                                   %       =       !
                                                                                                                                                                                          !                   $
                            &

                    %           !                                         !                       %                                      $
                                                %                         "                                                                                                                       1
                                        %                                     0                                                                    %       %                                              %
                                                                      *

                                                                                                                                                                                              %           @       %

                                                Verilog - 27                                                                                                           Verilog - 28




Simulation Time and Event Queues                                                                      Verilog Time

  '       "                                                                                             +           %                         %%               0                                      %
                                                    A            A%                       "             !
      "                                              %   %                                                  8                   $                                                                     %
      %             "           %                                                                                                   %                  "                  !     %
              %                                                       "                                     B           !           $!                                     1 22B %
                                                                                                                                                                              1                           !       //5
                                                                                                                                             %%                                                       "
                        !                                                         "                     ,                                                                       "     1
                                                                                                                                        %                                                                 %
                                                                                                                =!
      %                                     %
      !             !                               !        0                ?                                                                                                               %
                                                                                                                                    %                              !
                                                                                                                            %           C
                                                                                                                        %                                                   %


                                                Verilog - 29                                                                                                           Verilog - 30
Inertial and Transport Delays                                A few requirements for CSE467...

  3                                                               !           $       !
      8DE /+ F                                                    +                                   !         %
        ,    D        1                        +         E                                        G                      E
              !                                                   !
                                                                  +
       %                                                              ;           $
      E ./ 8 D + F                                                                        %                                      8   %
                      +                   E1         D                                        )             1
                                                   $ %                ;           %                                          %
                                                                                          6           )                  %
                                                                          0




                           Verilog - 31                                                                   Verilog - 32

Más contenido relacionado

La actualidad más candente

Introduction to Verilog & code coverage
Introduction to Verilog & code coverageIntroduction to Verilog & code coverage
Introduction to Verilog & code coverageJyun-Kai Hu
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical fileArchita Misra
 
Concepts of Behavioral modelling in Verilog HDL
Concepts of Behavioral modelling in Verilog HDLConcepts of Behavioral modelling in Verilog HDL
Concepts of Behavioral modelling in Verilog HDLanand hd
 
Lcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilogLcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilogsumedh23
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab reportRamesh Naik Bhukya
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesRicardo Castro
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECERamesh Naik Bhukya
 
Sequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experimentSequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experimentGouthaman V
 
J - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPSJ - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPSKrishma Parekh
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學 艾鍗科技
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab reportJinesh Kb
 
Stabilization of Furuta Pendulum: A Backstepping Based Hierarchical Sliding M...
Stabilization of Furuta Pendulum: A Backstepping Based Hierarchical Sliding M...Stabilization of Furuta Pendulum: A Backstepping Based Hierarchical Sliding M...
Stabilization of Furuta Pendulum: A Backstepping Based Hierarchical Sliding M...Shubhobrata Rudra
 
Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Ron Liu
 
Sequentialcircuits
SequentialcircuitsSequentialcircuits
SequentialcircuitsRaghu Vamsi
 
Flip flops, counters &amp; registers
Flip flops, counters &amp; registersFlip flops, counters &amp; registers
Flip flops, counters &amp; registersDharit Unadkat
 
GC in C++0x [eng]
GC in C++0x [eng]GC in C++0x [eng]
GC in C++0x [eng]yak1ex
 

La actualidad más candente (20)

Introduction to Verilog & code coverage
Introduction to Verilog & code coverageIntroduction to Verilog & code coverage
Introduction to Verilog & code coverage
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
 
Concepts of Behavioral modelling in Verilog HDL
Concepts of Behavioral modelling in Verilog HDLConcepts of Behavioral modelling in Verilog HDL
Concepts of Behavioral modelling in Verilog HDL
 
Lcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilogLcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilog
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab report
 
Travis jf flip flops
Travis jf flip flopsTravis jf flip flops
Travis jf flip flops
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gates
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
Fpga creating counter with internal clock
Fpga   creating counter with internal clockFpga   creating counter with internal clock
Fpga creating counter with internal clock
 
Sequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experimentSequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experiment
 
J - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPSJ - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPS
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab report
 
Trts d flip flop1
Trts d flip flop1Trts d flip flop1
Trts d flip flop1
 
Stabilization of Furuta Pendulum: A Backstepping Based Hierarchical Sliding M...
Stabilization of Furuta Pendulum: A Backstepping Based Hierarchical Sliding M...Stabilization of Furuta Pendulum: A Backstepping Based Hierarchical Sliding M...
Stabilization of Furuta Pendulum: A Backstepping Based Hierarchical Sliding M...
 
Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
 
Sequentialcircuits
SequentialcircuitsSequentialcircuits
Sequentialcircuits
 
Flip flops, counters &amp; registers
Flip flops, counters &amp; registersFlip flops, counters &amp; registers
Flip flops, counters &amp; registers
 
GC in C++0x [eng]
GC in C++0x [eng]GC in C++0x [eng]
GC in C++0x [eng]
 

Destacado

Verilog code all
Verilog code allVerilog code all
Verilog code allMNIT jaipur
 
Verilog Tutorial - Verilog HDL Tutorial with Examples
Verilog Tutorial - Verilog HDL Tutorial with ExamplesVerilog Tutorial - Verilog HDL Tutorial with Examples
Verilog Tutorial - Verilog HDL Tutorial with ExamplesE2MATRIX
 
verilog code for logic gates
verilog code for logic gatesverilog code for logic gates
verilog code for logic gatesRakesh kumar jha
 
Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits. Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits. shobhan pujari
 
たぶんできる!Verilog hdl
たぶんできる!Verilog hdlたぶんできる!Verilog hdl
たぶんできる!Verilog hdlcahara_mitsu
 
Evolution Of Microprocessors
Evolution Of MicroprocessorsEvolution Of Microprocessors
Evolution Of Microprocessorsharinder
 
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction setSaumitra Rukmangad
 

Destacado (13)

Verilog code all
Verilog code allVerilog code all
Verilog code all
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
8 Bit ALU
8 Bit ALU8 Bit ALU
8 Bit ALU
 
Verilog Tutorial - Verilog HDL Tutorial with Examples
Verilog Tutorial - Verilog HDL Tutorial with ExamplesVerilog Tutorial - Verilog HDL Tutorial with Examples
Verilog Tutorial - Verilog HDL Tutorial with Examples
 
verilog code for logic gates
verilog code for logic gatesverilog code for logic gates
verilog code for logic gates
 
Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
 
Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits. Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits.
 
Verilog HDL
Verilog HDLVerilog HDL
Verilog HDL
 
たぶんできる!Verilog hdl
たぶんできる!Verilog hdlたぶんできる!Verilog hdl
たぶんできる!Verilog hdl
 
Shift registers
Shift registersShift registers
Shift registers
 
Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
 
Evolution Of Microprocessors
Evolution Of MicroprocessorsEvolution Of Microprocessors
Evolution Of Microprocessors
 
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
 

Similar a 07 sequential verilog

VLSI Sequential Circuits II
VLSI Sequential Circuits IIVLSI Sequential Circuits II
VLSI Sequential Circuits IIGouthaman V
 
Fpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineFpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineMalik Tauqir Hasan
 
Digital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential CircuitsDigital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential CircuitsIndira Priyadarshini
 
HDL PROGRAMMING-3.pdf
HDL PROGRAMMING-3.pdfHDL PROGRAMMING-3.pdf
HDL PROGRAMMING-3.pdfkaarthikK6
 
SPICE MODEL of TC7WZ74FK in SPICE PARK
SPICE MODEL of TC7WZ74FK in SPICE PARKSPICE MODEL of TC7WZ74FK in SPICE PARK
SPICE MODEL of TC7WZ74FK in SPICE PARKTsuyoshi Horigome
 
SPICE MODEL of TC7WZ74FU in SPICE PARK
SPICE MODEL of TC7WZ74FU in SPICE PARKSPICE MODEL of TC7WZ74FU in SPICE PARK
SPICE MODEL of TC7WZ74FU in SPICE PARKTsuyoshi Horigome
 
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Shinya Takamaeda-Y
 
FlipFlopsLatches1.ppt
FlipFlopsLatches1.pptFlipFlopsLatches1.ppt
FlipFlopsLatches1.pptdiganta das
 
FlipFlopsLatches1 (3).ppt
FlipFlopsLatches1 (3).pptFlipFlopsLatches1 (3).ppt
FlipFlopsLatches1 (3).pptSalmanHameed26
 
FlipFlopsLatches1.ppt
FlipFlopsLatches1.pptFlipFlopsLatches1.ppt
FlipFlopsLatches1.pptdiganta das
 
FlipFlopsLatches off different inputs a and b
FlipFlopsLatches off different inputs a and bFlipFlopsLatches off different inputs a and b
FlipFlopsLatches off different inputs a and bMeenakshi Munjal
 
Theorie, Praxis und Perspektiven der operationsbasierten formalen Schaltungsv...
Theorie, Praxis und Perspektiven der operationsbasierten formalen Schaltungsv...Theorie, Praxis und Perspektiven der operationsbasierten formalen Schaltungsv...
Theorie, Praxis und Perspektiven der operationsbasierten formalen Schaltungsv...Förderverein Technische Fakultät
 
VHDL summary.pdf
VHDL summary.pdfVHDL summary.pdf
VHDL summary.pdfwafawafa52
 

Similar a 07 sequential verilog (20)

VLSI Sequential Circuits II
VLSI Sequential Circuits IIVLSI Sequential Circuits II
VLSI Sequential Circuits II
 
Vhdl programs
Vhdl programsVhdl programs
Vhdl programs
 
Fpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineFpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machine
 
Verilog_Examples (1).pdf
Verilog_Examples (1).pdfVerilog_Examples (1).pdf
Verilog_Examples (1).pdf
 
Digital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential CircuitsDigital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential Circuits
 
HDL PROGRAMMING-3.pdf
HDL PROGRAMMING-3.pdfHDL PROGRAMMING-3.pdf
HDL PROGRAMMING-3.pdf
 
SPICE MODEL of TC7WZ74FK in SPICE PARK
SPICE MODEL of TC7WZ74FK in SPICE PARKSPICE MODEL of TC7WZ74FK in SPICE PARK
SPICE MODEL of TC7WZ74FK in SPICE PARK
 
SPICE MODEL of TC7WZ74FU in SPICE PARK
SPICE MODEL of TC7WZ74FU in SPICE PARKSPICE MODEL of TC7WZ74FU in SPICE PARK
SPICE MODEL of TC7WZ74FU in SPICE PARK
 
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
 
Verilog code
Verilog codeVerilog code
Verilog code
 
FlipFlopsLatches1.ppt
FlipFlopsLatches1.pptFlipFlopsLatches1.ppt
FlipFlopsLatches1.ppt
 
FlipFlopsLatches1.ppt
FlipFlopsLatches1.pptFlipFlopsLatches1.ppt
FlipFlopsLatches1.ppt
 
FlipFlopsLatches1 (3).ppt
FlipFlopsLatches1 (3).pptFlipFlopsLatches1 (3).ppt
FlipFlopsLatches1 (3).ppt
 
FlipFlopsLatches1.ppt
FlipFlopsLatches1.pptFlipFlopsLatches1.ppt
FlipFlopsLatches1.ppt
 
FlipFlopsLatches off different inputs a and b
FlipFlopsLatches off different inputs a and bFlipFlopsLatches off different inputs a and b
FlipFlopsLatches off different inputs a and b
 
Theorie, Praxis und Perspektiven der operationsbasierten formalen Schaltungsv...
Theorie, Praxis und Perspektiven der operationsbasierten formalen Schaltungsv...Theorie, Praxis und Perspektiven der operationsbasierten formalen Schaltungsv...
Theorie, Praxis und Perspektiven der operationsbasierten formalen Schaltungsv...
 
Flip flop
Flip flopFlip flop
Flip flop
 
VHDL summary.pdf
VHDL summary.pdfVHDL summary.pdf
VHDL summary.pdf
 
Flip flops
Flip flopsFlip flops
Flip flops
 
Combinational Circuits
Combinational CircuitsCombinational Circuits
Combinational Circuits
 

Último

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 

Último (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

07 sequential verilog

  • 1. More Verilog 8-bit Register with Synchronous Reset module reg8 (reset, CLK, D, Q); input reset; input CLK; input [7:0] D; output [7:0] Q; reg [7:0] Q; always @(posedge CLK) if (reset) Q = 0; else Q = D; endmodule // reg8 Verilog - 1 Verilog - 2 N-bit Register with Asynchronous Reset Shift Register Example // 8-bit register can be cleared, loaded, shifted left module regN (reset, CLK, D, Q); // Retains value if no control signal is asserted input reset; input CLK; module shiftReg (CLK, clr, shift, ld, Din, SI, Dout); input CLK; parameter N = 8; // Allow N to be changed input clr; // clear register input [N-1:0] D; input shift; // shift output [N-1:0] Q; input ld; // load register from Din reg [N-1:0] Q; input [7:0] Din; // Data input for load input SI; // Input bit to shift in always @(posedge CLK or posedge reset) output [7:0] Dout; if (reset) reg [7:0] Dout; Q = 0; else if (CLK == 1) always @(posedge CLK) begin if (clr) Dout <= 0; Q = D; else if (ld) Dout <= Din; else if (shift) Dout <= { Dout[6:0], SI }; endmodule // regN end endmodule // shiftReg Verilog - 3 Verilog - 4 Blocking and Non-Blocking Assignments Swap (continued) Q = A % % ! " % # $ Q <= A always @(posedge CLK) always @(posedge CLK) begin begin A = B; B = A; % end end & ! ( posedge CLK ' % & ! % always @(posedge CLK) always @(posedge CLK) always @(posedge CLK) begin begin always @(posedge CLK) A <= B; B <= A; begin begin temp = B; end end A <= B; B = A; B <= A; A = temp; end end Verilog - 5 Verilog - 6
  • 2. Non-Blocking Assignment Counter Example # $ ! ) ! % % ! % $ $ * %$ % 0 1 22 & + ), + - ./ " % // this implements 3 parallel flip-flops always @(posedge clk) // 8-bit counter with clear and count enable controls begin module count8 (CLK, clr, cntEn, Dout); B = A; // this implements a shift register input CLK; C = B; always @(posedge clk) D = C; input clr; // clear counter begin end {D, C, B} = {C, B, A}; input cntEn; // enable count end output [7:0] Dout; // counter value // this implements a shift register reg [7:0] Dout; always @(posedge clk) begin always @(posedge CLK) B <= A; if (clr) Dout <= 0; C <= B; else if (cntEn) Dout <= Dout + 1; D <= C; end endmodule Verilog - 7 Verilog - 8 Finite State Machines Verilog FSM - Reduce 1s example 4 5 46 Mealy outputs ' % % next state Moore outputs inputs combinational // State assignment logic parameter zero = 0, one1 = 1, two1s = 2; current state module reduce (clk, reset, in, out); input clk, reset, in; output out; reg out; reg [1:0] state; // state register reg [1:0] next_state; % // Implement the state register always @(posedge clk) 3 % ! if (reset) state = zero; 3 % % ! else state = next_state; Verilog - 9 Verilog - 10 Moore Verilog FSM (cont’d) Mealy Verilog FSM for Reduce-1s example always @(in or state) module reduce (clk, reset, in, out); case (state) input clk, reset, in; out = 0; // defaults output out; next_state = zero; reg out; zero: begin // last input was a zero reg state; // state register if (in) next_state = one1; reg next_state; end parameter zero = 0, one = 1; always @(posedge clk) one1: begin // we've seen one 1 if (reset) state = zero; if (in) next_state = two1s; else state = next_state; end always @(in or state) two1s: begin // we've seen at least 2 ones out = 0; out = 1; next_state = zero; if (in) next_state = two1s; case (state) end zero: begin // last input was a zero // Don’t need case default because of default assignments if (in) next_state = one; endcase end endmodule one: // we've seen one 1 if (in) begin next_state = one; out = 1; end endcase endmodule Verilog - 11 Verilog - 12 6
  • 3. Single-always Moore Machine Restricted FSM Implementation Style (Not Recommended!) " ! ! % )7 module reduce (clk, reset, in, out); % % input clk, reset, in; output out; ! ! reg out; reg [1:0] state; // state register 22 % parameter zero = 0, one1 = 1, two1s = 2; % % ! 1 Verilog - 13 Verilog - 14 Single-always Moore Machine (Not Recommended!) Delays always @(posedge clk) case (state) All outputs are registered zero: begin out = 0; if (in) state = one1; else state = zero; end one1: 3 1 0 ! if (in) begin state = two1s; % ! out = 1; end else begin This is confusing: the 8 45 45 state = zero; out = 0; output does not change end until the next clock cycle module and_gate (out, in1, in2); two1s: if (in) begin input in1, in2; state = two1s; out = 1; output out; end else begin state = zero; end out = 0; assign #10 out = in1 & in2; default: begin state = zero; out = 0; endmodule end endcase endmodule Verilog - 15 Verilog - 16 6 Verilog Propagation Delay Initial Blocks ! ) ! assign #5 c = a | b; 0 assign #4 {Cout, S} = Cin + A + B; always @(A or B or Cin) #4 S = A + B + Cin; #2 Cout = (A & B) | (B & Cin) | (A & Cin); assign #3 zero = (sum == 0) ? 1 : 0; always @(sum) if (sum == 0) #6 zero = 1; else #3 zero = 0; Verilog - 17 Verilog - 18
  • 4. Tri-State Buffers Test Fixtures < 9: 6 $ < = % % $ ; % % module tstate (EnA, EnB, BusA, BusB, BusOut); input EnA, EnB; % % input [7:0] BusA, BusB; output [7:0] BusOut; 1 1 =! 1 2 assign BusOut = EnA ? BusA : 8’bZ; Simulation assign BusOut = EnB ? BusB : 8’bZ; endmodule Test Fixture Circuit Description (Specification) (Synthesizeable) Verilog - 19 Verilog - 20 Verilog Clocks Verilog Clocks > + module clockGenerator (CLK); parameter period = 10; module clock_gen (masterclk); ! " parameter howlong = 100; " output CLK; reg CLK; `define PERIOD = 10; initial begin output masterclk; CLK = 0; reg masterclk; #(period/2); repeat (howlong) begin CLK = 1; initial masterclk = 0; #(period-period/2); CLK = 0; always begin " # #(period/2); end #`PERIOD/2 $finish; masterclk = ~masterclk; end end endmodule // clockGenerator endmodule Verilog - 21 Verilog - 22 Example Test Fixture Simulation Driver module stimulus (a, b, c); module stimulus (a, b); parameter delay = 10; module full_addr1 (A, B, Cin, S, Cout); input A, B, Cin; parameter delay = 10; output a, b, c; reg [2:0] cnt; output S, Cout; output a, b; $% initial begin assign {Cout, S} = A + B + Cin; reg [1:0] cnt; cnt = 0; endmodule repeat (8) begin #delay cnt=cnt+1; initial begin & end #delay $finish; cnt = 0; # " end repeat (4) begin assign {c, a, b} = cnt; endmodule #delay cnt = cnt + 1; end module driver; // Structural Verilog connects test-fixture to full adder wire a, b, cin, sum, cout; #delay $finish; stimulus stim (a, b, cin); full_addr1 fa1 (a, b, cin, sum, cout); end initial begin $monitor ("@ time=%0d cin=%b, a=%b, b=%b, cout=%d, sum=%d", assign {a, b} = cnt; $time, cin, a, b, cout, sum); end endmodule endmodule Verilog - 23 Verilog - 24
  • 5. Test Vectors Verilog Simulation module testData(clk, reset, data); 3 % 2 % input clk; % output reset, data; reg [1:0] testVector [100:0]; ) reg reset, data; integer count; initial begin % $readmemb("data.b", testVector); count = 0; 0 ? { reset, data } = testVector[0]; end always @(posedge clk) begin count = count + 1; #1 { reset, data } = testVector[count]; end endmodule Verilog - 25 Verilog - 26 Intepreted vs. Compiled Simulation Simulation Level 3 % ' % " ! ! % % ! & " 1 ! $ 1% ! " 1 % % > % % = ! ! $ & % ! ! % $ % " 1 % 0 % % % * % @ % Verilog - 27 Verilog - 28 Simulation Time and Event Queues Verilog Time ' " + % %% 0 % A A% " ! " % % 8 $ % % " % % " ! % % " B ! $! 1 22B % 1 ! //5 %% " ! " , " 1 % % =! % % ! ! ! 0 ? % % ! % C % % Verilog - 29 Verilog - 30
  • 6. Inertial and Transport Delays A few requirements for CSE467... 3 ! $ ! 8DE /+ F + ! % , D 1 + E G E ! ! + % ; $ E ./ 8 D + F % 8 % + E1 D ) 1 $ % ; % % 6 ) % 0 Verilog - 31 Verilog - 32