+ All Categories
Home > Documents > Vlsi Manual e&c Dept

Vlsi Manual e&c Dept

Date post: 07-Apr-2015
Category:
Upload: madhusudan-g-s-tumkur
View: 439 times
Download: 2 times
Share this document with a friend
105
Department of Electronics and Communication DSCE, Bangalore – 560 078. VLSI Lab Manual Page 1 VLSI LAB Subject Code : 06ECL77 IA Marks : 25 No. of Practical Hrs/Week : 03 Exam Hours : 03 Total no. of Practical Hrs. : 42 Exam Marks : 50 PART - A DIGITAL DESIGN ASIC-DIGITAL DESIGN FLOW 1. Write Verilog Code for the following circuits and their Test Bench for verification, observe the waveform and synthesise the code with technological library with given Constraints*. Do the initial timing verification with gate level simulation. i. An inverter, ii. A Buffer iii. Transmission Gate iv. Basic/universal gates v. Flip flop -RS, D, JK, MS, T vi. Serial & Parallel adder vii. 4-bit counter [Synchronous and Asynchronous counter] viii. Successive approximation register [SAR] * An appropriate constraint should be given PART - B ANALOG DESIGN Analog Design Flow 1. Design an Inverter with given specifications*, completing the design flow mentioned below: a. Draw the schematic and verify the following i) DC Analysis ii) Transient Analysis b. Draw the Layout and verify the DRC, ERC c. Check for LVS d. Extract RC and back annotate the same and verify the Design e. Verify & Optimize for Time, Power and Area to the given constraint*** 2. Design the following circuits with given specifications*, completing the design flow mentioned below: a. Draw the schematic and verify the following i) DC Analysis ii) AC Analysis iii) Transient Analysis b. Draw the Layout and verify the DRC, ERC c. Check for LVS d. Extract RC and back annotate the same and verify the Design. i) A Single Stage differential amplifier ii) Common source and Common Drain amplifier Design an op-amp with given specification* using given differential amplifier
Transcript
Page 1: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 1

VLSI LAB Subject Code : 06ECL77 IA Marks : 25 No. of Practical Hrs/Week : 03 Exam Hours : 03 Total no. of Practical Hrs. : 42 Exam Marks : 50

PART - A DIGITAL DESIGN ASIC-DIGITAL DESIGN FLOW

1. Write Verilog Code for the following circuits and their Test Bench for verification, observe the waveform and synthesise the code with technological library with given Constraints*. Do the initial timing verification with gate level simulation.

i. An inverter, ii. A Buffer iii. Transmission Gate iv. Basic/universal gates v. Flip flop -RS, D, JK, MS, T vi. Serial & Parallel adder vii. 4-bit counter [Synchronous and Asynchronous counter] viii. Successive approximation register [SAR] * An appropriate constraint should be given

PART - B

ANALOG DESIGN Analog Design Flow

1. Design an Inverter with given specifications*, completing the design flow mentioned below:

a. Draw the schematic and verify the following i) DC Analysis ii) Transient Analysis b. Draw the Layout and verify the DRC, ERC c. Check for LVS d. Extract RC and back annotate the same and verify the Design e. Verify & Optimize for Time, Power and Area to the given constraint*** 2. Design the following circuits with given specifications*, completing the design flow mentioned below: a. Draw the schematic and verify the following i) DC Analysis ii) AC Analysis iii) Transient Analysis b. Draw the Layout and verify the DRC, ERC c. Check for LVS d. Extract RC and back annotate the same and verify the Design. i) A Single Stage differential amplifier ii) Common source and Common Drain amplifier

Design an op-amp with given specification* using given differential amplifier

Page 2: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 2

2. Common source and Common Drain amplifier in library** and completing the design flow mentioned below:

a. Draw the schematic and verify the following i) DC Analysis ii) AC Analysis iii) Transient Analysis b. Draw the Layout and verify the DRC, ERC c. Check for LVS d. Extract RC and back annotate the same and verify the Design.

3. Design a 4 bit R-2R based DAC for the given specification and completing the design flow mentioned using given op-amp in the library**.

a. Draw the schematic and verify the following i) DC Analysis ii) AC Analysis iii) Transient Analysis b. Draw the Layout and verify the DRC, ERC c. Check for LVS d. Extract RC and back annotate the same and verify the Design.

4. For the SAR based ADC mentioned in the figure below draw the mixed signal schematic and verify the functionality by completing ASIC Design FLOW.

[Specifications to GDS-II]

* Appropriate specification should be given. ** Applicable Library should be added & information should be given to the Designer.

*** An appropriate constraint should be given

Page 3: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 3

Page 4: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 4

Page 5: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 5

Page 6: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 6

Page 7: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 7

Page 8: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 8

Page 9: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 9

Page 10: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 10

Page 11: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 11

Page 12: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 12

Page 13: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 13

Page 14: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 14

Page 15: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 15

Page 16: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 16

Page 17: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 17

Page 18: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 18

Page 19: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 19

Page 20: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 20

Page 21: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 21

Page 22: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 22

Page 23: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 23

Page 24: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 24

Page 25: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 25

Page 26: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 26

Page 27: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 27

Page 28: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 28

Page 29: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 29

Page 30: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 30

Page 31: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 31

Page 32: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 32

Page 33: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 33

Page 34: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 34

Page 35: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 35

Page 36: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 36

Page 37: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 37

Page 38: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 38

Page 39: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 39

Page 40: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 40

Page 41: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 41

Page 42: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 42

Page 43: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 43

Page 44: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 44

Page 45: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 45

Page 46: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 46

Page 47: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 47

Page 48: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 48

Page 49: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 49

Page 50: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 50

Page 51: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 51

Page 52: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 52

Page 53: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 53

Page 54: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 54

Page 55: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 55

Page 56: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 56

Page 57: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 57

Page 58: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 58

Page 59: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 59

Page 60: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 60

Page 61: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 61

Page 62: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 62

Page 63: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 63

Page 64: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 64

Page 65: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 65

Page 66: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 66

Page 67: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 67

Page 68: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 68

Page 69: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 69

Page 70: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 70

Page 71: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 71

Page 72: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 72

Page 73: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 73

Page 74: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 74

Page 75: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 75

Page 76: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 76

Page 77: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 77

Page 78: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 78

Page 79: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 79

Page 80: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 80

Page 81: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 81

Page 82: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 82

Page 83: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 83

Page 84: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 84

Page 85: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 85

Page 86: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 86

Page 87: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 87

PROCEDURE TO RUN THE SIMULATION AND SYNTHESIS USING NCSIM AND ENCOUNTER RTL

Example for SERIAL ADDER

Setup the design environment

1. Create cds.lib and make the following enteries Define sadder_lib ./sadder.lib Define designlib ../design.lib

2. Create the following directories Mkdir sadder.lib Mkdir ../design.lib

3. Create hdl.var and make the following entry Define WORK designlib Define VIEW vlog Compilation process

1. ncvlog shift_register.v –messages 2. ncvlog serial_adder.v –mess 3. ncvlog serial_adder_t.v –mess –work sadder_lib 4. Add the following entry to hdl.var:::: Define NCELABOPTS –messages

Elaborate the Design

ncelab serial_adder_t –access +rwc

Simulate the Design

ncsim serial_adder_t –gui

When the Design Browser window pops up

1. Select the SERIAL_ADDER_T instance and click SEND the SELECTED SIGNALS TO THE TARGETED WAVEFORM WINDOW.

2. In the waveform window press RUN. 3. Now you will be able to visualize the waveforms.

Page 88: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 88

SYNTHESIS 1. Change the work directory to cd rclabs/work 2. Start the tool by entering rc –gui –logfile serial_adder.log 3. An rc:/> shell prompt would appear with a GUI interface. 4. At the shell prompt enter gui_hide 5. Generate a template script-----rc:/>write_template –outfile template.tcl

Setup the environment

In the template.tcl fill the following commands to set the search paths

1. The RTL files are in the ../rtl directory 2. The libraries are in the ../library directory 3. The Tcl scripts are in the ../tcl and in the work directory 4. Add the following script search path in template.tcl

Set_attr hdl_search_path {../rtl}/ Set_attr lib_search_path{../library}/ Set_attr script_searc_path{../tcl} Set_attr information_level 7/

5. At rc:/> include ../tcl/setup.g 6. Read the libraries with library command----rc:/> set_attr library $LIBRARY 7. Specify the cells to avoid by entering –rc:/> set_attr avoid true [find /lib * -libcell

SDFF*] 8. rc:/> read_hdl $FILE_LIST 9. rc:/>elaborate serial_adder 10. rc:/>check_design serial_adder 11. rc:/>include constraints_serial_adder.g 12. rc:/> report timing –lint 13. rc:/> synthesize –to_mapped –eff medium –no_incr 14. rc:/>report area >> serial_adder.report 15. rc:/>write_hdl –m > serial_adder_mapped.netlist 16. rc:/>gui_show

Page 89: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 89

INVERTER `resetall `timescale 1 ns / 1 ns `view vlog //Define our own Inverter, module inverter ( out , in ); // Declarations of I/O ,Power and Ground Lines output out; input in; supply1 pwr; supply0 gnd; // Instantiate pmos and nmos switches pmos (out,pwr,in); nmos (out,gnd,in); endmodule `noview `resetall `timescale 1 ns / 1 ns `view vlog // Testbench for Inverter Module module inv_test; wire out ; reg in ; `uselib view = vlog // Instantiate inverter Module inverter i1 ( out, in ) ; `nouselib

Page 90: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 90

// Display task display ; begin $display ( "time=%0d" , $time , " ns" , " Input=" , in , " Output=", out ) ; end endtask // Apply Stimulus initial begin in = 1'b0 ; #10 ; display ; in = 1'b1 ; #10 ; display ; in = 1'bx ; #10 ; display ; in = 1'bz ; #10 ; display ; end endmodule `noview BUFFER `resetall `timescale 1 ns / 1 ns `view vlog //Define our own Inverter, module inverter ( Y, A ); // Declarations of I/O ,Power and Ground Lines output Y; input A; supply1 pwr; supply0 gnd;

Page 91: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 91

// Instantiate pmos and nmos switches pmos (Y,pwr,A); nmos (Y,gnd,A); endmodule // Define our own Buffer module buffer ( out, in ); // Declarations of I/O Lines output out; input in; // Wire Declaration wire a; // Instantiate Inverter module inverter i1 (a,in); inverter i2 (out,a); endmodule `noview // Testbench for Buffer Module `resetall `timescale 1 ns / 1 ns `view vlog module buf_test; wire out ; reg in ; `uselib view = vlog // Instantiate Buffer Module buffer b1 ( out, in ) ; `nouselib

Page 92: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 92

// Display task display ; begin $display ( "time=%0d" , $time , " ns" , " Input=" , in , " Output=", out ) ; end endtask // Apply Stimulus initial begin in = 1'b0 ; #10 ; display ; in = 1'b1 ; #10 ; display ; in = 1'bx ; #10 ; display ; in = 1'bz ; #10 ; display ; end endmodule `noview TRANSMISSION GATE `resetall `timescale 1 ns / 1 ns `view vlog //Define our own Transmission Gate, module trangate ( out , in , cntrl1, cntrl2 ); // Declarations of I/O and Control Lines output out; input in; input cntrl1,cntrl2;

Page 93: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 93

// Instantiate pmos and nmos switches pmos (out,in,cntrl1); nmos (out,in,cntrl2); endmodule `noview `resetall `timescale 1 ns / 1 ns `view vlog // Testbench for Inverter Module module trangate_test; wire out ; reg in ; reg cntrl1,cntrl2; `uselib view = vlog // Instantiate trangate Module trangate t1 ( out, in, cntrl1, cntrl2 ) ; `nouselib // Display task display ; begin $display ( "time=%0d" , $time , " ns" , " Input=" , in , " Output=", out , " Control1=",cntrl1 , " Control2=",cntrl2 ) ; end endtask

Page 94: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 94

// Apply Stimulus initial begin in = 1'b0 ; cntrl1 = 1'b0 ; cntrl2 = 1'b1 ; #10 ; display ; in = 1'b0 ; cntrl1 = 1'b1 ; cntrl2 = 1'b0 ; #10 ; display ; in = 1'b1 ; cntrl1 = 1'b0 ; cntrl2 = 1'b1 ; #10 ; display ; in = 1'b1 ; cntrl1 = 1'b1 ; cntrl2 = 1'b0 ; #10 ; display ; end endmodule `noview BASIC GATES: AND, OR, NAND, NOR, XOR, XNOR FLIPFLOPS module d_ff(q,clk,n_rst,din); output q; input clk,din,n_rst; reg q; always @(posedge clk or negedge n_rst) begin if(!n_rst) q <= 1'b0; else q <= din; end endmodule module d_ff_test; reg clk, din, n_rst; wire q, d1, clk1; d_ff df1 (q, clk, n_rst, din); assign d1=din; assign clk1=clk; initial clk = 1'b0; always #10 clk = ~clk; initial begin din = 1'b0;

Page 95: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 95

n_rst = 1'b1; #20 n_rst = 1'b0; #10 din = 1'b1; #20 n_rst = 1'b1; #18 din = 1'b0; #1 din = 1'b1; #20 din = 1'b0; #10 ; end always #5 $display ($time," clk=%b din=%b q=%b", clk, din, q); initial #100 $finish; specify $setup(d1, posedge clk1, 2); $hold(posedge clk1, d1, 2); $width(negedge d1, 2); endspecify endmodule module jk_ff(q,qbar,clk,rst,j,k); input clk,rst,j,k; output q,qbar; reg q,tq; always @(posedge clk or negedge rst) begin if (!rst) begin q <= 1'b0; tq <= 1'b0; end else begin if (j == 1'b1 && k == 1'b0) q <= j; else if (j == 1'b0 && k == 1'b1) q <= 1'b0; else if (j == 1'b1 && k == 1'b1) begin tq <= ~tq; q <= tq; end end end assign q_bar = ~q;

Page 96: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 96

endmodule module jk_ff_test; reg clk,rst,j,k; wire q,qbar; wire clk1,j1,k1; jk_ff inst(q,qbar,clk,rst,j,k); assign clk1=clk; assign j1=j; assign k1=k; initial clk = 1'b0; always #10 clk = ~clk; initial begin j = 1'b0; k = 1'b0; rst = 1'b0; #30 rst = 1'b1; #60 j = 1'b0; k = 1'b1; #29 j = 1'b1; k = 1'b0; #1 j = 1'b0; k = 1'b1; #20 j = 1'b1; k = 1'b1; #40 j = 1'b1; k = 1'b0; #5 j = 1'b0; #20 j = 1'b1; #50 rst = 1'b0; #10 ; end always #5 $display($time," clk=%b j=%b k=%b ",clk,j,k); initial #300 $finish; specify $setup(j1, posedge clk1, 2); $setup(k1, posedge clk1, 2); $hold(posedge clk1, j1, 2); $hold(posedge clk1, k1, 2); endspecify endmodule module ms_jkff(q,q_bar,clk,j,k); output q,q_bar; input clk,j,k; reg tq,q,q_bar; always @(clk) begin if (!clk) begin

Page 97: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 97

if (j==1'b0 && k==1'b1) tq <= 1'b0; else if (j==1'b1 && k==1'b0) tq <= 1'b1; else if (j==1'b1 && k==1'b1) tq <= ~tq; end if (clk) begin q <= tq; q_bar <= ~tq; end end endmodule module tb_ms_jkff; reg clk,j,k; wire q,q_bar; wire clk2,j2,k2; ms_jkff inst(q,q_bar,clk,j,k); assign clk2=clk; assign j2=j; assign k2=k; initial clk = 1'b0; always #10 clk = ~clk; initial begin j = 1'b0; k = 1'b0; #60 j = 1'b0; k = 1'b1 #40 j = 1'b1; k = 1'b0; #20 j = 1'b1; k = 1'b1; #40 j = 1'b1; k = 1'b0; #5 j = 1'b0; #20 j = 1'b1; #10 ; end always #5 $display($time," clk=%b j=%b k=%b ",clk,j,k); initial #200 $finish; specify $setup(j2, posedge clk2, 2); $setup(k2, posedge clk2, 2); $hold(posedge clk2, j2, 2);

Page 98: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 98

$hold(posedge clk2, k2, 2); endspecify endmodule module SR_ff(q,qbar,s,r,clk); output q,qbar; input clk,s,r; reg tq; always @(posedge clk or tq) begin if (s == 1'b0 && r == 1'b0) tq <= tq; else if (s == 1'b0 && r == 1'b1) tq <= 1'b0; else if (s == 1'b1 && r == 1'b0) tq <= 1'b1; else if (s == 1'b1 && r == 1'b1) tq <= 1'bx; end assign q = tq; assign qbar = ~tq; endmodule module SR_ff_test; reg clk,s,r; wire q,qbar; wire s1,r1,clk1; SR_ff sr1(q,qbar,s,r,clk); assign s1=s; assign r1=r; assign clk1=clk; initial clk = 1'b0; always #10 clk = ~clk; initial begin s = 1'b0; r = 1'b0; #30 s = 1'b1; #29 s = 1'b0; #1 r = 1'b1; #30 s = 1'b1; #30 r = 1'b0; #20 s = 1'b0; #19 s = 1'b1;

Page 99: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 99

#200 s = 1'b1; r = 1'b1; #50 s = 1'b0; r = 1'b0; #50 s = 1'b1; r = 1'b0; #10 ; end always #5 $display($time," clk=%b s=%b r=%b ",clk,s,r); initial #500 $finish; specify $setup(s1, posedge clk1, 2); $setup(r1, posedge clk1, 2); $hold(posedge clk1, s1, 2); $hold(posedge clk1, r1, 2); endspecify endmodule module t_ff(q,qbar,clk,tin,rst); output q,qbar; input clk,tin,rst; reg tq; always @(posedge clk or negedge rst) begin if(!rst) tq <= 1'b0; else begin if (tin) tq <= ~tq; end end assign q = tq; assign qbar = ~q; endmodule module t_ff_test; reg clk,tin,rst; wire q,qbar; t_ff t1(q,qbar,clk,tin,rst); initial clk = 1'b0; always #10 clk = ~clk; initial begin

Page 100: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 100

rst = 1'b0; tin = 1'b0; #30 rst = 1'b1; #10 tin = 1'b1; #205 tin = 1'b0; #300 tin = 1'b1; #175 tin = 1'b0; #280 rst = 1'b0; #20 rst = 1'b1; #280 tin = 1'b1; #10 ; end initial #2000 $finish; endmodule SERIAL ADDER module serial_adder ( A,B, reset, clock, sum); input [7:0] A,B; input reset,clock; output [7:0] sum; reg [3:0] count; reg s,y,Y; wire [7:0] qa,qb,sum; wire run; parameter G=0,H=1; shiftrne shift_A (A,reset,1'b1,1'b0,clock,qa); shiftrne shift_B (B,reset,1'b1,1'b0,clock,qb); shiftrne shift_sum (8'b0,reset,run,s,clock,sum); //adder fsm //output and next state combinational circuit always @(qa or qb or y) case (y) G: begin s = qa[0]^qb[0]; if (qa[0] & qb[0]) Y = H; else Y = G; end H: begin

Page 101: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 101

s = qa[0] ~^qb[0]; if (~qa[0] & ~qb[0]) Y =G; else Y = H; end default : Y = G; endcase //sequential block always @(posedge clock) if (reset) y <= G; else y <= Y; //control the shifting process always @(posedge clock) if (reset) count = 8; else if (run) count = count - 1; assign run=|count; endmodule module shiftrne ( R,L,E,w,clock,q); parameter n=8; input [n-1:0] R; input L,E,w,clock; output [n-1:0] q; reg [n-1:0] q; integer k; always @(posedge clock) if (L) q <= R; else if (E) begin for (k=n-1;k>0;k=k-1) q[k-1] <= q[k]; q[n-1] <= w; end endmodule

Page 102: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 102

module serial_adder_t ; reg [7:0] A,B; reg reset,clock; wire [7:0] sum ; initial clock = 1'b0; always #5 clock =~clock; serial_adder s1 (A,B,reset,clock,sum); initial begin reset = 1'b0;A = 8'b10101010; B = 8'b11111111; #20 reset = 1'b1; #20 reset = 1'b0; #150 reset = 1'b1; A = 8'b11110000 ; B = 8'b11110011; #20 reset = 1'b0; #200 $finish; end initial $monitor ($time, " SUM = %d ", sum); endmodule PARELLEL ADDER

module adder4 ( carryin,x,y,sum,carryout); input carryin; input [3:0] x,y; output [3:0] sum; output carryout; fulladd stage0 (carryin,x[0],y[0],sum[0],c1); fulladd stage1 (c1,x[1],y[1],sum[1],c2); fulladd stage2 (c2,x[2],y[2],sum[2],c3); fulladd stage3 (c3,x[3],y[3],sum[3],carryout); endmodule module fulladd (cin,x,y,s,cout); input cin,x,y; output s,cout; assign s = x^y^cin; assign cout =( x & y) | (x & cin) |( y & cin); endmodule module adder4_t ; reg [3:0] x,y; reg carryin; wire [3:0] sum; wire carryout;

Page 103: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 103

adder4 a1 ( carryin,x,y,sum,carryout); initial begin $monitor($time,"SUM=%d",sum); x = 4'b0000; y= 4'b0000;carryin = 1'b0; #20 x =4'b1111; y = 4'b1010; #40 x =4'b1011; y =4'b0110; #40 x =4'b1111; y=4'b1111; #50 $finish; end endmodule ASYNCOUNTER

`view rtl module ripple_counter (clock, toggle, reset, count); input clock, toggle, reset; output [3:0] count; reg [3:0] count; wire c0, c1, c2; assign c0 = count[0], c1 = count[1], c2 = count[2]; always @ (posedge reset or posedge clock) if (reset == 1'b1) count[0] <= 1'b0; else if (toggle == 1'b1) count[0] <= ~count[0]; always @ (posedge reset or negedge c0) if (reset == 1'b1) count[1] <= 1'b0; else if (toggle == 1'b1) count[1] <= ~count[1]; always @ (posedge reset or negedge c1) if (reset == 1'b1) count[2] <= 1'b0; else if (toggle == 1'b1) count[2] <= ~count[2]; always @ (posedge reset or negedge c2) if (reset == 1'b1) count[3] <= 1'b0; else if (toggle == 1'b1) count[3] <= ~count[3]; endmodule `noview module ripple_counter_t ; reg clock,toggle,reset; wire [3:0] count ; ripple_counter r1 (clock,toggle,reset,count); initial clock = 1'b0; always #5 clock = ~clock; initial

Page 104: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 104

begin reset = 1'b0;toggle = 1'b0; #10 reset = 1'b1; toggle = 1'b1; #10 reset = 1'b0; #190 reset = 1'b1; #20 reset = 1'b0; #100 reset = 1'b1; #40 reset = 1'b0; #250 $finish; end initial $monitor ($time, " output q = %d", count); endmodule SYNCOUNTER

module counter_behav ( count,reset,clk); input wire reset, clk; output reg [3:0] count; always @(posedge clk) if (reset) count <= 4'b0000; else count <= count + 4'b0001; endmodule module mycounter_t ; wire [3:0] count; reg reset,clk; initial clk = 1'b0; always #5 clk = ~clk; counter_behav m1 ( count,reset,clk); initial begin reset = 1'b0 ; #15 reset =1'b1; #30 reset =1'b0; #300 $finish; end initial $monitor ($time, "Output count = %d ",count ); endmodule

Page 105: Vlsi Manual e&c Dept

Department of Electronics and Communication DSCE, Bangalore – 560 078.

VLSI Lab Manual Page 105

SAR module shiftrne ( R,L,E,w,clock,q); parameter n=8; input [n-1:0] R; input L,E,w,clock; output [n-1:0] q; reg [n-1:0] q; integer k; always @(posedge clock) if (L) q <= R; else if (E) begin for (k=n-1;k>0;k=k-1) q[k-1] <= q[k]; q[n-1] <= w; end endmodule module sar_t; reg [7:0] r; reg l; reg e; reg w; reg clk; wire [7:0] q; shiftrne sf(.R(r),.L(l),.E(e),.w(w),.clock(clk),.q(q)); initial begin clk = 1'b0; l = 1'b1; w = 1'b0; e = 1'b0; #5 r = 8'b1111_0000; #10 l = 1'b0; e = 1'b1; w = 1'b0; #10 w = 1'b0; #10 w = 1'b0; #10 w = 1'b0; #10 w = 1'b1; #10 w = 1'b1; #10 w = 1'b1; #10 w = 1'b1; #10 $finish; end always #5 clk = ~clk; end module


Recommended