Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

SRAM Content Swapping Verilog Code Example - Prof. Jing Pang, Study notes of Engineering

An example of verilog code for swapping the contents of two sram (static random access memory) locations at address 15'h66. The code includes various states and conditions for reading, writing, and swapping data.

Typology: Study notes

2009/2010

Uploaded on 03/28/2010

koofers-user-sz1-1
koofers-user-sz1-1 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Writing & Reading SRAM Example
Swap two SRAM contents at address location 15’h66.
………
assign address = 15’h 66;
always@(posedge swap_sw or negedge swapdone)
begin
if (swapdone==0) start <= 1'b0;
else start <= 1'b1;
end
always@(start or c_state)
begin
pf2

Partial preview of the text

Download SRAM Content Swapping Verilog Code Example - Prof. Jing Pang and more Study notes Engineering in PDF only on Docsity!

Writing & Reading SRAM Example

Swap two SRAM contents at address location 15’h66. ………

assign address = 15’h 66;

always@(posedge swap_sw or negedge swapdone) begin if (swapdone==0) start <= 1'b0; else start <= 1'b1; end always@(start or c_state) begin

if (start = = 0) n_state<=idle; else begin case (c_state) idle: n_state <= read_1; read_1: n_state <= swap2to1; swap2to1: n_state <= write_2; write_2: n_state <= readyff; readyff: n_state <= idle; default: n_state <= idle; endcase end end

always@(c_state) begin case (c_state) idle: begin we_1<=1'b1;we_2<=1'b1;oe_1<=1'b1;oe_2<=1'b1;swapdone<=1'b1;end read_1: begin we_1<=1'b1;we_2<=1'b1;oe_1<=1'b0;oe_2<=1'b1;swapdone<=1'b1;end swap2to1: begin we_1<=1'b0;we_2<=1'b1;oe_1<=1'b1;oe_2<=1'b0;swapdone<=1'b1;end write_2: begin we_1<=1'b1;we_2<=1'b0;oe_1<=1'b1;oe_2<=1'b1;swapdone<=1'b1;end readyff: begin we_1<=1'b1;we_2<=1'b1;oe_1<=1'b1;oe_2<=1'b1;swapdone<=1'b0;end default: begin we_1<=1'b1;we_2<=1'b1;oe_1<=1'b1;oe_2<=1'b1;swapdone<=1'b1;end endcase end always@(negedge clk) begin if (c_state= =read_1) templatch <= temp; end assign temp = (c_state= =read_1)? databus: 8'b00000000; assign databus = ((c_state= =read_1) | (c_state= =swap2to1) | (c_state= =idle) | (c_state= =readyff) )? 8'bZZZZZZZZ: templatch; endmodule