Efficient packing of data for BlockRAMs, UltraRAMs
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Charles
am 22 Mär. 2023
Kommentiert: Ryan Baird
am 29 Mär. 2023
Hi,
I have a system where there's four channels of 18-bit data processed simultaneously and written to a RAM as 4096 words x 4 channels of data. HDL Coder seems to want to instantiate four separate RAMs (appears that way in the Verilog), and Vivado shows this too.
I'd like to see the four channels packed into a 72-bit word and written to one location in an UltraRAM. I specified "ultra" for the RAMDirective, and this "works" - the netlist shows four UltraRAMs in use, so at least we've got UltraRAMs.
But how do I get the data packed into a single 72-bit word? Is that something I need to do in the Simulink diagram?
Thanks,
Charles
0 Kommentare
Akzeptierte Antwort
Ryan Baird
am 22 Mär. 2023
Bearbeitet: Ryan Baird
am 22 Mär. 2023
The RAM block interprets vectors of data to mean you want separate RAM banks. In order to store and retreive the data as a single value, you currently need to combine the data before writing and separate the data after reading outside of the RAM block. The easiest way I'm aware of to do this is with the Bit Concat and Bit Slice blocks. You could use a Bit Concat block before the RAM block to combine the data, and use Bit Slice blocks after the RAM block to separate the read data back into 4 different values.
5 Kommentare
Ryan Baird
am 23 Mär. 2023
Bearbeitet: Ryan Baird
am 23 Mär. 2023
One possibility is that you could concatenate one type and not the other. That might be easier to do with MATLAB Function blocks, e.g.:
function out = concatIfNotDouble(v)
if(isa(v(1), 'double'))
out = v;
else
% Assumed array of four 18 bit fixpt values
out = bitconcat(v(4), v(3), v(2), v(1));
end
end
function out = splitIfNotDouble(v)
if(isa(v(1), 'double'))
% 4 double values
out = v;
else
% Assumed 72 bit value to be split into four 18 bit values
out = fi(zeros(1,4), 0, 18, 0);
for i = 0:3
start=18*i+1;
out(i+1) = bitsliceget(v,start+17,start);
end
end
end
Weitere Antworten (2)
Charles
am 29 Mär. 2023
1 Kommentar
Ryan Baird
am 29 Mär. 2023
There's a function "typecast" for converting between integer and floating point types, keeping the same underlying data (similar to a c++ reinterpret_cast), and there's a function "reinterpretcast" for converting between integer and fixedpoint types while keeping the same underlying data:
Siehe auch
Kategorien
Mehr zu HDL Code Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!