Posts

Showing posts from August, 2023

Static Timing Analysis

Setup Time: The setup time is the interval before the clock where the data must be held stable. Hold Time: The hold time is the interval after the clock where the data must be held stable. Setup and Hold Time Violation Setup time violation: It is because when a signal arrives too late. Hold time violation: It is because when an input changes too quickly. If the setup and hold parameters are violated, the output would either logic 0, logic 1 or metastable state. To avoid setup time violation:  T(ctoq) + Tcomb + Tsetup - Tskew < Tperiod Setup Slack =   Tperiod - ( T(ctoq) + Tcomb + Tsetup - Tskew) I.   Decreasing the clk to q delay of the launching flop. II.  Decreasing the propagation delay of the combinational logic. III. Reducing the setup time requirement of the capturing flop. IV. Increasing the skew between capture and launch clock. V. Increasing the clock period. To avoid hold time violation:  T(ctoq) + Tcomb >  Thold + Tskew Hold Slack...

Serial In Serial Out Shift Register

 module SISO(clk,rst,d,q);     input clk,rst,d;     output q;     reg [3:0] temp;     always@(posedge clk or negedge rst)     begin          if(rst == 1'b1)               temp <= 4'b0;          else               begin                    temp[3] <= d;                    temp     <= temp >>1;               end                    assign q = temp[0]; endmodule Testbench module SISO_tb;     reg t_clk, t_rst, t_d;     wire t_q;     SISO SISO_tb(.clk(t_clk),                        ...

Moore State Machine:1001

Image
module moore_machine(clk, rst, din, dout);     input clk, rst, din;     output dout;     reg      dout;     reg [4:0] sate;     parameter s0 = 5'b00001,                           s1 = 5'b00010,                           s2 = 5'b00100,                          s3 = 5'b01000,                          s4 = 5'b10000;     always@(posedge clk or negedge rst)     begin          if(rst == 1'b0)               begin                    state <=           ...

Mealy State Machine:1001

Image
  Design module mealy_machine(clk,rst,din,dout);     input clk,rst,din;     output dout;     reg      dout;     reg [3:0] state;     parameter s0 = 4'b0001,                          s1 = 4'b0010,                           s2 = 4'b0100,                          s3 = 4'b1000;     always@(posedge clk or negedge rst)     begin          if(rst == 1'b0)               begin                    state <= s0;                    dout <= 1'b0;                end ...

Counter

Design module counter(clk, rst, count);     input clk,rst;     output [3:0] count;     reg      [3:0] counter;     always@(posedge clk or negedge rst)     begin          if(rst == 1'b0)               counter <= 4'b0;          else               counter <= counter + 4'b1;      end               assign count = counter; endmodule Testbench module counter_tb     reg t_clk,t_rst;     wire [3:0] t_count;     counter counter_tb(.clk(t_clk),                                            .rst(t_rst),                      ...

D Flip Flop(synchronous Reset)

Image
  Truth Table Design module d_ff_sync(d,clk,rst,q);     input d,clk,rst;     output q;     reg      q;     always@(posedge clk )     begin         if(rst == 1'b1)             q <= 1'b0;          else              q <= d;       end endmodule Testbench module d_ff_sync_tb;     reg t_d,t_clk,t_rst;     wire t_q;     d_ff_sync d_ff_sync_tb(.d(t_d),                                             .clk(t_clk),                                              .rst(t_rst),                        ...

D Flip Flop(Asynchronous Reset)

Image
Truth Table  Design module d_ff_async(d,clk,rst,q);     input d,clk,rst;     output q;     reg      q;     always@(posedge clk or posedge rst)     begin         if(rst == 1'b1)             q <= 1'b0;          else              q <= d;       end endmodule Testbench module d_ff_async_tb;     reg t_d,t_clk,t_rst;     wire t_q;     d_ff_async d_ff_async_tb(.d(t_d),                                                .clk(t_clk),                                                .rst(t_rst),             ...

8X1 MUX using 2X1 MUX

Image
  Truth Table

4X1 Multiplexer

Image
  Truth Table Dataflow Modeling     module mux_41(I0,I1,I2,I3,S1,S0,Y)         input I0,I1,I2,I3,S1,S0;         output Y;         assign Y=S1?(S0?I3:I2):(S0?I1:I0);     endmodule   Case Statement module mux_41(I0,I1,I2,I3,S1,S0,Y);     input I0,I1,I2,I3,S1,S0;     output Y;      reg     Y;      always@(I0 or I1 or I2 or I3 or S1 or S0)      begin           case(S1 or S0)               2'b00 : Y = I0;               2'b01 : Y = I1;               2'b10 : Y = I2;               2'b11 : Y = I3;              endcase         end endmodule Structural Modeling 2X1 Multiplexer     module mux_21(I0,I1,S,Y)...