Comparator Dataflow Modeling

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

COMPARATOR

Dataflow modeling
module cmp(x,y,z,a,b);

input a,b;

output x,y,z;

assign x=(~a)&b;

assign y=((~a)&(~b))|(a&b);

assign z=a&(~b);

endmodule

Test Bench
module cmp_tb;

// Inputs

reg a;

reg b;

// Outputs

wire x;

wire y;

wire z;

// Instantiate the Unit Under Test (UUT)

cmp uut (
.x(x),

.y(y),

.z(z),

.a(a),

.b(b)

);

initial begin

// Initialize Inputs

a = 0;b = 0;#100;

a = 0;b = 1;#100;

a = 1;b = 0;#100;

a = 1;b = 1;#100;

// Add stimulus here

end

endmodule

behavioral modeling
module cmp(x,y,z,a,b);

input a,b;

output x,y,z;

reg x,y,z;
always@ (a or b)

if (a>b)

begin

x=0;y=0;z=1;end

else if (a==b)

begin

x=0;y=1;z=0;end

else

begin

x=1;y=0;z=0;end

endmodule

Test Bench
module cmp_tb1;

// Inputs

reg a;

reg b;

// Outputs

wire x;

wire y;

wire z;

// Instantiate the Unit Under Test (UUT)


cmp uut (

.x(x),

.y(y),

.z(z),

.a(a),

.b(b)

);

initial begin

// Initialize Inputs

a = 0;b = 0;#100;

a = 0;b = 1;#100;

a = 1;b = 0;#100;

a = 1;b = 1;#100;

// Add stimulus here

end

endmodule

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy