Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

Writing to memory

Altera_Forum
Honored Contributor II
1,022 Views

I'm a beginner in FPGA, working on Stratix III DE3 340.  

 

I got a set of serial data, converted it into parallel form, and now I need to write the output of a deserialiser into memory (for processing later). How do I begin? Is there some kind of megafunction for this?
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
324 Views

The exact answer depends on the details of your system, but assuming you're getting one bit at a time and just want to store them in blockram, then by far the simplest is to use the fact that you can use different bit widths for the two different ports. Eg, you can have one be 1 bit wide and read it out 16-bit at a time on the other. 

 

In the more general case, you can accumulate the bits in a shift register and every time you have collected a word worth of data, you write it to memory. 

 

Untested example code (not production code, but written for illustration): 

 

module memory( input clock, input serial_in, input serial_valid, input read_address, output reg read_data); reg word; reg bits_collected = 0; reg bits = 0; reg write_address = 0; always @(posedge clock) begin read_data <= word; if (serial_valid) begin bits <= {serial_in, bits}; // lowest bit first bits_collected <= bits_collected + 1; if (bits_collected == 32) begin word <= bits; write_address <= write_address + 1; bits_collected <= 1; end end endmodule
0 Kudos
Reply