ALTERA DE2 Verilog HDL Study notes 04-altera Read and write on SRAM DE2

Source: Internet
Author: User

Last semester just learned the principle of single-chip microcomputer, so get started DE2 board relatively easy, RAM and ROM concept has been established earlier. After playing the call of duty after some tiredness, write a DE2 board on the SRAM on the study notes to alleviate a bit. +_+

First, the size of the SRAM on the DE2 is 512KB, the model is ISSI-IS61LV25616AL-10TL, the TSOP package, the schematic is as follows:

Pin Description:


Here is the description under Address bus a0-a17, altogether 18 bits, 2^18=256k! = 512KB, this may be the RAM chip inside there is a decoder smacking.

Data bus I/O 0~i/o 15, 16-bit output.

Truth table


Directly below the code:

Feature Description:

1, RAM address occurs, we use a KEY0 as a counter, when artificially pressed, 4-bit counter count++, high 14-bit direct complement 0;

2, with the key KEY1 as we, when pressed, write the current key state (data);

3, the Development Board SW0 ~ SW15 as data input;

4, hex3~hex0 display the destination address data, HEX4 display address;

5, UB and LB both open at the same time, easy to read all data;

Top Module Module SRAM (input [1:0] KEY,//pushbutton [1:0] input [15:0] SW,//toggle switch[15:0] output [6:0] HEX
                            0,//7-seg display output [6:0] HEX1,//7-seg display
                            Output [6:0] HEX2,//7-seg display output [6:0] HEX3,//7-seg display         Output [6:0] HEX4,//7-seg display output [6:0] HEX5, 7-seg display output [6:0] HEX6,//7-seg display output
                            [3:0] Ledg,//led green[3:0] output [15:0] Ledr,//led red[15:0]    inout [15:0] sram_dq,//sram data bus, bits output [17:0] sram_addr, SRAM Address Bus 18 Bits output Sram_ub_n,//sram high-byte data mask  Output Sram_lb_n,//sram low-byte data mask output Sram_we_n,//sram write Enable output Sram_ce_n,//sram chip enable output Sram_o
                            
E_n//sram output enable);

reg [3:0] shortcount;    Assign Hex5=7 ' b011_1111;  -Assign Hex6=7 ' b011_1111 is first closed with a digital tube that cannot be used;  -Assign hex6=7 ' b011_1111; -//memeory address//connect KEY0 switch to LEDs to upcount and display always @ (Negedge key[0]) begin SHORTCOUNT&L
t;=shortcount+1;    
End assign Ledg[3:0]=shortcount;

Display the hex value of the counter//this is also the memory address Hexdigit DIGIT4 (hex4,shortcount);    SRAM Interface assign sram_addr={14 ' H0,shortcount};                           SRAM Address bus bits assign sram_ub_n=0;             Hi byte Select Enabled assign Sram_lb_n=0;                                        Lo byte Select enabled assign Sram_ce_n=0;                            Chip is enabled assign SRAM_WE_N=KEY[1];                                        Write when KEY1 is pressed assign sram_oe_n=0;  Output enable is Overidden by WE//if KEY1 are not pressed, then float bus, so this SRAM can drive it (read)//if KEY1 are
Pressed, drive it with data from sw[15:0] to being stored in SRAM (write) Assign sram_dq= (key[1]?16 ' hzzzz:sw[15:0]);
Show memory on the LEDs and 7-seg display assign LEDR[15:0]=SRAM_DQ; 
Hexdigit Digit0 (hex0,sram_dq[3:0]); 
Hexdigit Digit1 (Hex1,sram_dq[7:4]); 
Hexdigit Digit2 (Hex2,sram_dq[11:8]); 

Hexdigit Digit3 (Hex3,sram_dq[15:12]); Endmodule


Decode one hex digit for LED 7-seg display

module hexdigit (segs,num
                                //input [3:0] num,
                                //output reg [6:0] se GS
                                );
input [3:0] num;
Output [6:0] segs;
reg [6:0] segs;
                                
Always @ (num)
begin case
    (num)
        4 ' H0:segs = 7 ' b1000000;
        4 ' H1:segs = 7 ' b1111001;
        4 ' H2:segs = 7 ' b0100100;
        4 ' H3:segs = 7 ' b0110000;
        4 ' H4:segs = 7 ' b0011001;
        4 ' H5:segs = 7 ' b0010010;
        4 ' H6:segs = 7 ' b0000010;
        4 ' H7:segs = 7 ' b1111000;
        4 ' H8:segs = 7 ' b0000000;
        4 ' H9:segs = 7 ' b0010000;
        4 ' Ha:segs = 7 ' b0001000;
        4 ' Hb:segs = 7 ' b0000011;
        4 ' Hc:segs = 7 ' b1000110;
        4 ' Hd:segs = 7 ' b0100001;
        4 ' He:segs = 7 ' b0000110;
        4 ' Hf:segs = 7 ' b0001110;
        Default Segs = 7 ' b1111111;    
    Endcase
End

Endmodule

Since the pins are more, take the import txt pin file. When you take the variable name, it can be the same as the official CSV document, so that it is easy to import directly.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.