Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
module rcas;
// Inputs
reg [7:0] a;
reg [7:0] b;
reg cin;
// Outputs
wire [7:0] sum;
wire carry;
initial begin
// Initialize Inputs
a = 0;
b = 0;
cin = 0;
end
endmodule
SIMULATED OUTPUT:
2.DESIGN AND SIMULATION OF 4-BIT BOOTH’S MULTIPLIER AND SHIFT & ADD
MULTIPLIER
(i)BOOTHS MULTIPLIER
PROGRAM:
modulebm(xa,ya,za);
input [3:0]xa;
input [3:0]ya;
output [7:0]za;
integeri;
reg[9:0]temp;
reg[1:0]a;
reg[5:0]y;
reg[5:0]x;
reg[9:0]z;
reg[7:0]za;
always@ (xa or ya)
begin
y[5:0]=6’b000000;
y[5:1]=ya[3:0];
x[4:0]=xa[3:0];
z=9’b000000000;
temp=10’b0000000000;
for(i=0;i<=4;i=i+1)
begin
a[0]=y[i];
a[1]=y[i+1];
case(a)
2’b01:temp[4:0]=x[4:0];
2’b10:temp[4:0]=(~x[4:0])+5’b0001;
2’b11:temp[4:0]=5’b00000;
2’b00:temp[4:0]=5’b00000;
endcase
if(temp[4]==0)
begin
temp[9:5]=5’b00000;
end
else
begin
temp[9:5]=5’b11111;
end
temp=temp<<i;
z=z+temp;
end
za=z;
endendmodule
RTL- SCHEMATIC:
module bms;
// Inputs
reg [3:0] xa;
reg [3:0] ya;
// Outputs
wire [7:0] za;
initial begin
// Initialize Inputs
xa = 0;
ya = 0;
endmodule
SIMULATED OUTPUT:
module smuls;
// Inputs
reg [3:0] x;
reg [3:0] y;
reg reset;
// Outputs
wire [7:0] z;
initial begin
// Initialize Inputs
x = 0;
y = 0;
reset = 0;
endmodule
SIMULATED OUTPUT:
module imps;
// Inputs
reg [3:0] a;
reg [3:0] b;
reg [1:0] opcode;
// Outputs
wire [3:0] dataz;
wire compz;
initial begin
// Initialize Inputs
a = 0;
b = 0;
opcode = 0;
end
endmodule
SIMULATED OUTPUT:
RTL- SCHEMATIC:
VERILOG TEST FIXTURE:
`timescale 1ns/1ps
module uni_shift_8b1_tst;
reg [7:0] ip;
reg [1:0] sh_ro_lt_rt;
regrst_a,clk;
wire [7:0] op;
initial
begin
clk=1'b1;
forever #10 clk=~clk;
end
initial
begin
$monitor("ip:%b,rst_a:%b,sh_ro_lt_rt:%b, op:%b",ip,rst_a,sh_ro_lt_rt,op);
ip = 8'b11001100;
rst_a = 1'b1;
sh_ro_lt_rt = 2'b00;
#40;
ip = 8'b10001100;
rst_a = 1'b0;
sh_ro_lt_rt = 2'b00;
#80;
ip = 8'b11001100;
sh_ro_lt_rt = 2'b01;
#120;
ip = 8'b10101101;
sh_ro_lt_rt = 2'b10;
#160;
ip = 8'b11001101;
sh_ro_lt_rt = 2'b11;
#200;
$finish;
end
endmodule
SIMULATED OUTPUT:
Moore Model:
moduleMoore_Model ( output [1: 0] y_out, input x_in, clock, reset );
reg[1: 0] state;
parameterS0 = 2'b00, S1 = 2'b01, S2 = 2'b10, S3 = 2'b11;
always@ ( posedgeclock, negedgereset)
if(reset == 0) state <= S0; // Initialize to state S0
else case (state)
S0: if (~x_in) state <= S1; else state <= S0;
S1: if (x_in) state <= S2; else state <= S3;
S2: if (~x_in) state <= S3; else state <= S2;
S3: if (~x_in) state <= S0; else state <= S3;
endcase
assigny_out = state; // Output of flip-fl ops
endmodule
RTL-SCHEMATIC:
moduleMoore_Model_test;
reg clock, x_in, reset; wire [1:0] y_out;
Moore_Modeluut (y_out, x_in, clock,reset);
initial
begin
clock = 1'b0; reset = 1'b0;
#15 reset = 1'b1;
end
always #5 clock = ~clock;
initial
begin
#12 x_in = 1'b1; #10 x_in = 1'b0;
#10 x_in = 1'b1; #10 x_in = 1'b0;
#10 $finish;
end
endmodule
SIMULATED OUPUT:
6.DESIGN AND SIMULATION OF SYNCHRONOUS SINGLE PORT RANDOM ACCESS
MEMORY
PROGRAM:
module memory(clk_write, address_write,
data_write, write_enable,
clk_read, address_read, data_read);
// Write port
inputclk_write;
input [A_WIDTH-1:0] address_write;
input [D_WIDTH-1:0] data_write;
inputwrite_enable;
// Read port
inputclk_read;
input [A_WIDTH-1:0] address_read;
output [D_WIDTH-1:0] data_read;
RTL-SCHEMATIC:
modulememtest;
// Inputs
regclk_write;
reg [3:0] address_write;
reg [15:0] data_write;
regwrite_enable;
regclk_read;
reg [3:0] address_read;
// Outputs
wire [15:0] data_read;
initial begin
// Initialize Inputs
clk_write = 0;
address_write = 0;
data_write = 0;
write_enable = 0;
clk_read = 0;
address_read = 0;
tasktoggle_clk_write;
begin
#10 clk_write = ~clk_write;
#10 clk_write = ~clk_write;
end
endtask
tasktoggle_clk_read;
begin
#10 clk_read = ~clk_read;
#10 clk_read = ~clk_read;
end
endtask
endmodule
SIMULATED OUPUT:
BOOTHS MULTIPLIER
PROGRAM:
modulebm(xa,ya,za);
input [3:0]xa;
input [3:0]ya;
output [7:0]za;
integeri;
reg[9:0]temp;
reg[1:0]a;
reg[5:0]y;
reg[5:0]x;
reg[9:0]z;
reg[7:0]za;
always@ (xa or ya)
begin
y[5:0]=6’b000000;
y[5:1]=ya[3:0];
x[4:0]=xa[3:0];
z=9’b000000000;
temp=10’b0000000000;
for(i=0;i<=4;i=i+1)
begin
a[0]=y[i];
a[1]=y[i+1];
case(a)
2’b01:temp[4:0]=x[4:0];
2’b10:temp[4:0]=(~x[4:0])+5’b0001;
2’b11:temp[4:0]=5’b00000;
2’b00:temp[4:0]=5’b00000;
endcase
if(temp[4]==0)
begin
temp[9:5]=5’b00000;
end
else
begin
temp[9:5]=5’b11111;
end
temp=temp<<i;
z=z+temp;
end
za=z;
endendmodule
4-BIT ALU
PROGRAM:
module imp(a,b,opcode,dataz,compz);
input [3:0]a;
input [3:0]b;
input [1:0]opcode;
output [3:0]dataz;
outputcompz;
parameter ADD=0,NAND=1,GT=2,XOR=3;
assign
dataz=(opcode==ADD)?a+b:(opcode==NAND)?~(a&b):(opcode==XOR)?a^b:'bx;
assign
compz=(opcode==GT)?a>b:'bx;
endmodule
modulesyncou_test;
reg clock, data; wire [3:0]q;
syncoumycounter (clock,data,q);
initial
begin
//$dumpfile ("sequence.vcd"); $dumpvars (0, test_sequence);
clock = 1'b0; data = 1'b1;
end
always #5 clock = ~clock;
endmodule
SIMULATED OUTPUT:
SIMULATION STATUS
T-Spice - Tanner SPICE
Version 15.02
Network license from: server.VLSILab.local
Product Release ID: T-Spice Win32 15.02.20100805.03:20:03
Copyright © 1988-2010 Tanner EDA
Parsing "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\Cell0.sp"
Reading library entry "TT" from "C:/Documents and Settings/Administrator/My
Documents/Tanner EDA/Tanner Tools
v15.0/Process/Generic_250nm/Generic_250nm_Tech/Generic_250nm.lib"
Reading library entry "TT_NMOS_PARAMETERS" from "Generic_250nm.lib"
Reading library entry "TT_PMOS_PARAMETERS" from "Generic_250nm.lib"
Reading library entry "MOS_BIN_MODEL" from "Generic_250nm.lib"
Reading library entry "Typ" from "Generic_250nm.lib"
Reading library entry "RES_CAP" from "Generic_250nm.lib"
Loaded BSIM3v31 model library, Berkeley BSIM3 VERSION 3.1 with extensions
Opening simulation database
"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\Cell0.tsim"
General options:
threads = 2
Output options:
prtdel = 1e-008
Device and node counts:
MOSFETs - 2 MOSFET geometries - 2
BJTs - 0 JFETs - 0
MESFETs - 0 Diodes - 0
Capacitors - 0 Resistors - 0
Inductors - 0 Mutual inductors - 0
Transmission lines - 0 Coupled transmission lines - 0
Voltage sources - 2 Current sources - 0
VCVS - 0 VCCS - 0
CCVS - 0 CCCS - 0
V-control switch - 0 I-control switch - 0
Macro devices - 0 Verilog-A devices - 0
Subcircuits - 0 Subcircuit instances - 0
Model Definitions - 2 Computed Models - 2
Independent nodes - 1 Boundary nodes - 3
Total nodes - 4
Simulation completed
OUTPUT WAVEFORM
CMRR= Ad / Ac
CMRR in dB = Ad in dB – Ac in dB =17.5-1.7296 = 15.7704