Exp 1.docx

  • Uploaded by: Anonymous L3zAMqRlzU
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Exp 1.docx as PDF for free.

More details

  • Words: 209
  • Pages: 5
EXP 1 RCA HALF ADDER USING OPERATORS Source code module ha_operator(a,b,s,c); input a,b; output s,c; assign s=a^b; assign c=a&b; endmodule Testbench module ha_operator_tb(); reg a,b; wire s,c; ha_operator d(a,b,s,c); initial begin a=1'b0;b=1'b0; #10 a=1'b0;b=1'b1; #10 a=1'b1;b=1'b0; #10 a=1'b1;b=1'b1; #10 $finish; end endmodule Waveform:

full adder

Source code module fa(a,b,cin,s,cout); input a,b,cin; output s,cout; wire w1,w2,w3; ha_operator a1(a,b,w1,w3), a2(w1,cin,s,w2); or o1(cout,w2,w3); endmodule

testbench module fa_tb(); reg a,b,cin; wire s,cout; fa f1(a,b,cin,s,cout); initial begin {a,b,cin}=3'b000; #10 {a,b,cin}=3'b001; #10 {a,b,cin}=3'b010; #10 {a,b,cin}=3'b011; #10 {a,b,cin}=3'b100; #10 {a,b,cin}=3'b101; #10 {a,b,cin}=3'b110; #10 {a,b,cin}=3'b111; #10 $finish; end endmodule waveform

4bit RCA Souce code module rca_4bit(a,b,cin,s,cout); input [3:0]a,b; input cin; output [3:0]s; output cout; wire w1,w2,w3; fa f1(a[0],b[0],cin,s[0],w1), f2(a[1],b[1],w1,s[1],w2), f3(a[2],b[2],w2,s[2],w3), f4(a[3],b[3],w3,s[3],cout); endmodule

testbench code module rca_4bit_tb(); reg [3:0]a,b; reg cin; wire [3:0]s; wire cout; rca_4bit r1(a,b,cin,s,cout); initial begin a=$random;b=$random;cin=$random; #10 a=$random;b=$random;cin=$random; #10 a=$random;b=$random;cin=$random; #10 a=$random;b=$random;cin=$random; #10 $finish; end endmodule

waveform

Rca using generate

Sourcecode module rcagenerate(a,b,cin,s,cout); parameter n=4; input [n-1:0] a,b; input cin; output [n-1:0] s; output cout; wire [n:0] c; assign c[0]=cin; genvar i; generate for(i=0; i
Testbench code

module rca_generate_tb(); reg [3:0]a,b; reg cin;

wire [3:0]s; wire cout; rcagenerate r1(a,b,cin,s,cout); initial begin a=$random;b=$random;cin=$random; #10 a=$random;b=$random;cin=$random; #10 a=$random;b=$random;cin=$random; #10 a=$random;b=$random;cin=$random; #10 $finish; end endmodule

Waveform of testbench

Related Documents

Exp
November 2019 29
Exp
May 2020 27
Exp
November 2019 33
Exp
July 2020 17
Exp
October 2019 33
Exp. Anatomia.docx
November 2019 18

More Documents from "Crist F. Angel"