You are on page 1of 5

`timescale 1ns / 1ps

////////////////////////////////////////////////////////////////////////////////
//
// Company:Project_Vertibre_Decoder
// Engineer: Aritra Bhattacharya
//
// Create Date:
15:16:12 08/24/2012
// Design Name:
// Module Name:
gdi1
// Project Name: VERTIBRE DECODER
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
/////////////////////MODULE FOR GDI/////////////////////////////////////////////
////////////////////////////////////////////////////
module gdi1(a,b,reset,clk,t,b1,b2,b3,c_in,q_d1,q_d2,q_d3,q_d4,d,
vd_out);
input a,b,reset,t,b1,b2,b3,c_in,clk,d;
output q_d1,q_d2,q_d3,q_d4,vd_out;
wire q3,q2,q1,b1,b2,b3,q11,q22,q33,s1,s2,s3,s11,s22,s33,c_out,c_
out1,f0,f1,f2,f3,q_d1,q_d2,q_d3,q_d4,d,d11,d12,sm;
////////////////////////////////////////////////////////////////////////////////
//INTERNAL FOR BMU AND CLA
aritrabmuu1 out11(a,b,q3,q2,q1,reset,t);
//
callcla1 out12(s1,s2,s3, c_out, q1,q2,q3,b1,b2,
b3, c_in);
//
aritrabmuu1 value3(a,b,q33,q22,q11,reset,t);
//
callcla1 value4(s11,s22,s33, c_out1, q11,q22,q3
3,b1,b2,b3, c_in); //
////////////////////////////////////////////////////////////////////////////////
//
comparator4bit1 value5(s1,s2,s3,c_out,s11,s22,s33,c_out1,sm);
mux2_call value10(s1,s2,s3,s11,s22,s33,sm,c_out,c_out1,f0
,f1,f2,f3);
call_d_ff value11(f0,f1,f2,f3,clk,reset,q_d1,q_
d2,q_d3,q_d4);
mux1 value12( sm, d,b, d11 );
dff_sync_reset value13(d11,clk,reset,d12);
dff_sync_reset valude14(d12,clk,reset,vd_out);
endmodule
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
////////////////CALL D_FF///////////////////////////////////////////////////////
////////////////////////////////////////////////////
module call_d_ff(f0,f1,f2,f3,clk,reset,q_d1,q_d2,q_d3,q_d4);
input f0,f1,f2,f3,clk,reset;
output q_d1,q_d2,q_d3,q_d4;

dff_sync_reset
dff_sync_reset
dff_sync_reset
dff_sync_reset

out111(f0,clk,reset,q_d1);
out112(f1,clk,reset,q_d2);
out113(f2,clk,reset,q_d3);
out114(f3,clk,reset,q_d4);

endmodule
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
///////////////D_FF MODDULE/////////////////////////////////////////////////////
////////////////////////////////////////////////////
module dff_sync_reset (
data , // Data Input
clk
, // Clock Input
reset , // Reset input
q
// Q output
);
//-----------Input Ports--------------input data, clk, reset ;
//-----------Output Ports--------------output q;
//------------Internal Variables-------reg q;
//-------------Code Starts Here--------always @ ( posedge clk)
if (~reset) begin
q <= 1'b0;
end else begin
q <= data;
end
endmodule //End Of Module dff_sync_reset
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
///////////////////////MODULE CALL FOR 4 BIT SELCTOR 2X1 MUX////////////////////
////////////////////////////////////////////////////
module mux2_call(s1,s2,s3,s11,s22,s33,sm,c_out,c_out1,f0,f1,f2,f3);
input s1,s2,s3,s11,s22,s33,sm,c_out,c_out1;
output f0,f1,f2,f3;
mux1 value6( sm, s1,s11, f0 );
mux1 value7( sm, s2,s22, f1 );
mux1 value8( sm, s3,s33, f2);
mux1 value9( sm, c_out,c_out1, f3);
endmodule
//////////////////////4 BIT SELECTOR CIRCUIT////////////////////////////////////
////////////////////////////////////////////////////
module mux1( select, s_1,s_2 , f );
input select;
input s_1,s_2;

output f;
wire f;
wire select;
wire[1:0] s;
assign s[0]=s_1,
s[1]=s_2;
assign f = s[select];
endmodule
//////////////////////COMPARATOR CIRCUIT OF 4X1 A<B/////////////////////////////
////////////////////////////////////////////////////
module comparator4bit1(s1,s2,s3,c_out,s11,s22,s33,c_out1,sm);
input s1,s2,s3,c_out,s11,s22,s33,c_out1;
//input [3:0]b;
output sm;
reg eq,sm,gt;
wire [3:0]a;
wire [3:0]b;
assign a[0]=s1,
a[1]=s2,
a[2]=s3,
a[3]=c_out,
b[3]=s11,
b[2]=s22,
b[1]=s33,
b[0]=c_out1;
always @(a,b)
begin
if (a>b)
gt<=1'b1;
else
gt<=1'b0;
if (a<b)
sm<=1'b1;
else
sm<=1'b0;
if (a==b)
eq<=1'b1;
else
eq<=1'b0;
end
endmodule
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
/////////////////////////MODULE FOR BMU/////////////////////////////////////////
////////////////////////////////////////////////////
module aritrabmuu1(a,b,q3,q2,q1,reset,t);
input a,b,reset,t;
output q3,q2,q1;
wire y;//q2,q3;
///////////////////////////////////////////////////////INTERNALS FOR BMU DESIGNI
NG(CALLING OF T_FF AND XOR GATE)
xorgate out22(a,b,y);
//

tff_async_reset out1(t,y,reset,q1);
tff_async_reset out2(t,y,reset,q2);
//
tff_async_reset out3(t,y,reset,q3);
///////////////////////////////////////////////////////
endmodule

//
//
//

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
//////////////////////////MODULE FOR 3 BIT CARRY LOOK AHEAD ADDER///////////////
////////////////////////////////////////////////////
//3-bit full adder with Carry Lookahead
module callcla1(s1,s2,s3, c_out, q1,q2,q3,b1,b2,b3, c_in);
//Inputs and outputs
output s1,s2,s3;
output c_out;
input q1,q2,q3,b1,b2,b3;
input c_in;
//Internal wires
wire p1,
wire c3,
//compute the p for each
assign p1 = q1 ^

g1, p2,
c2, c1;
stage
b1,
p2 = q2
p3 = q3
//compute the g for each stage
assign g1 = q1 & b1,
g2 = q2
g3 = q3

g2, p3, g3;

^ b2,
^ b3;
& b2,
& b3;

//compute the carry for each stage


// Note that c_in is equivalent c0 in the arithmetic equation for
//carry lookahead computation
assign c1 = g1 | (p1 & c_in),
c2 = g2 | (p2 & g1) | (p2 & p1 & c_in),
c3 = g3 | (p3 & g2) | (p3 & p2 & g1) |
(p3 & p2 & p1 & c_in);
//compute sum
assign s1 = p1 ^ c_in,
s2 = p2 ^ c1,
s3 = p3 ^ c2;
//Assign carry output
assign c_out = c3;
endmodule
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
///////////////////////////MODULE FOR XOR GATE IN BMU///////////////////////////
////////////////////////////////////////////////////
//`timescale 1ns / 1ps
module xorgate(a, b, y);
input a;

input b;
output y;
assign y = a ^ b;
endmodule
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
/////////////////////////////MODULE FOR T_FF IN BMU/////////////////////////////
////////////////////////////////////////////////////
module tff_async_reset (
t,
y,//data , // Data Input
//clk

, // Clock Input

reset , // Reset input


q

// Q output

//qbar

// Qbar output

);
input t,y,reset ; //clk //-----------Input Ports-------------output q;
tput Ports--------------reg q;
nternal Variables-------//wire q,qbar;

//-----------Ou
//------------I

always @ ( posedge y or negedge reset)


if (~reset)
q <= 1'b0;
else if (y)
q <= !q;
endmodule //End Of Module tff_async_reset
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////

You might also like