

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
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
1 / 2
This page cannot be seen from the preview
Don't miss anything!
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