multi-inputs multi-outputs FIFO

7 次查看(过去 30 天)
Doaa
Doaa 2013-10-28
回答: Prateekshya 2024-10-16
I am new to matlab and simulink. I am trying to build a shared memory(RAM). I searched alot for solutions as integer arrays, multi-ports FIFO, but till now I am not able to find clear answer for this: so now there is no memory in simulink (array of registers) any suggestions for building multi-in multi-out FIFO ?

回答(1 个)

Prateekshya
Prateekshya 2024-10-16
Hello Doaa,
Building a multi-in, multi-out FIFO (First-In, First-Out) buffer in Simulink can be a bit challenging, especially if you're new to the platform. However, you can achieve this by using a combination of Simulink blocks to simulate the behavior of a shared memory structure. Here is a step-by-step guide to help you create a simple FIFO buffer:
Understand the Requirements:
  • Multi-In, Multi-Out: You need to handle multiple input and output channels.
  • FIFO Behavior: Data should be read in the order it was written.
Basic Components:
  • Memory Block: Use a memory block to store the data.
  • Counter: Keep track of the read and write positions.
  • Logic: Implement logic to handle reading and writing operations.
Simulink Blocks to Use:
  • Unit Delay: To store previous values.
  • Switch: To control data flow.
  • Mux/Demux: To handle multiple inputs and outputs.
  • MATLAB Function Block: For custom logic if needed.
Building the FIFO in Simulink:
Initialize the Model:
  • Open Simulink and create a new model.
  • Set the solver type to discrete if you are working with digital signals.
Create the FIFO Logic:
  • Memory Block: Use a Unit Delay block or Memory block to store the current state of the FIFO.
  • Counter: Use Counter Free-Running blocks to keep track of the read and write indices.
  • Switching Logic: Use Switch blocks to decide when to read or write data.
Handle Multiple Inputs/Outputs:
  • Use Mux blocks to combine multiple inputs into a single signal.
  • Use Demux blocks to split the output signal into multiple channels.
Implement Read/Write Control:
  • Use MATLAB Function blocks if you need custom logic to handle read/write operations.
  • Ensure that you have logic to prevent overflows (writing more data than the buffer can hold) or underflows (reading data when the buffer is empty).
Example Setup:
  • Use a Switch block to select between writing new data or retaining old data based on the write enable signal.
  • Increment the write pointer using a counter.
  • Use a Switch block to output data from the FIFO based on the read enable signal.
  • Increment the read pointer using a counter.
  • Use Scope blocks to visualize the data being written to and read from the FIFO.
I hope this helps!

类别

Help CenterFile Exchange 中查找有关 Event Functions 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by