Professional Documents
Culture Documents
Affiliation (Institution/Company):………………………………………………………………………………………….
Important Instructions:
1) All assignment results should be computer screenshot or computer typed. Handwritten
and scanned copies shall not be considered for evaluation
2) Due date for all assignment submission is 1 Week from the last date of internship 3) All
assignment questions should be captured along with solutions/answers.
4) Code snippets, simulation results should be captured properly
5) Use only the JPEG image format for capturing the simulation results and name/label the results
appropriately.
6) The description of answers should be short and crisp. Provide only the required information,
answered copied or cut and pasted from google shall not be considered.
module apb_add_master (
input logic pclk,
input logic preset_n,
);
apb_state_t state_q;
apb_state_t nxt_state;
logic apb_state_setup;
logic apb_state_access;
logic nxt_pwrite;
logic pwrite_q;
always_comb begin
nxt_pwrite = pwrite_q;
nxt_rdata = rdata_q; case
(state_q) ST_IDLE: if
(add_i[0]) begin
nxt_state = ST_SETUP;
PRIVATE & CONFIDENTIAL
Excel VLSI Technologies
PRIVATE & CONFIDENTIAL
Excel VLSI Technologies
nxt_pwrite = add_i[1];
end else begin
nxt_state = ST_IDLE;
end
ST_SETUP: nxt_state = ST_ACCESS;
ST_ACCESS:
if (pready_i) begin
if (~pwrite_q)
nxt_rdata = prdata_i;
nxt_state = ST_IDLE;
end else
nxt_state = ST_ACCESS;
default: nxt_state = ST_IDLE;
endcase
end
// APB Address
assign paddr_o = {32{apb_state_access}} & 32'hA000;
endmodule
logic pclk;
logic preset_n; // Active low reset
logic psel_o;
logic penable_o;
logic pwrite_o;
// Implement clock
always begin pclk
= 1'b0;
#5;
pclk = 1'b1;
#5;
end
initial begin
preset_n = 1'b0;
add_i = 2'b00;
repeat (2) `CLK;
preset_n = 1'b1;
repeat (2) `CLK;
add_i = 2'b01;
`CLK; add_i
= 2'b00;
repeat (4) `CLK;
add_i = 2'b11;
`CLK; add_i =
2'b00; repeat
(4) `CLK;
initial begin
$dumpfile("apb_master.vcd");
$dumpvars(2, apb_slave_tb); end
endmodule
WAVE FORMS
module serial_adder(input clk, input reset, input in1, input in2, output reg[3:0] sum, output reg
endmodule
module testbench();
reg clk, reset, in1, in2; wire [3:0] sum; wire carry_out; serial_adder dut(.clk(clk),
$dumpfile("dump.vcd");
initial begin
clk = 0;
reset = 1; in1
= 4'b0000;
in2 = 4'b0000;
#10 reset = 0;
in1 = 4'b0000;
in2 = 4'b0000;
in1 = 4'b0001;
in2 = 4'b0001;
in1 = 4'b0111;
in2 = 4'b1000;
$finish; end
always #5 clk =
~clk;
endmodule