Two pointers in ROM hardware implementation [closed] - memory

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
ROM is implemented by case statement to store fixed values in it and read them whenever we need.
But how can I read two values at the same clock cycle ??

It is always useful to show at least part of your code. I assume you have something like this:
case (adrs)
8'h00 : dout <= 8h01;
8'h01 : dout <= 8h03;
8'h02 : dout <= 8h07;
The only solution is to make two identical case statements but it is easier to instance the same ROM twice.
Alternative is to make a memory and initialise it.
reg [7:0] mem [0:255];
... // initialise memory e.g
... // using initial with for loop and case statement
always #(posedge clk)
begin
dout1< = mem[adrs1];
dout2< = mem[adrs2];
end
I assume this is for an FPGA so look at the vendor manual how to make a pre-loaded RAM. (Which is on fact a ROM as long as you don't write to it)

Related

Memory management of Metal resources [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
There some MTLTextures of which histogram is to be calculated, this textures changes at every loop iteration so calculation of histogram is carried out in loop using MPSImageHistogram.
There is a single command queue on which a new command buffer is created at every loop iteration to perform histogram calculation.
Memory footprints (from allocation instrument) keeps on increasing due to new command buffer creation in the loop.
The question is how to clear the allocated memory of the command buffer once it's executed? Or is there any way for restructuring the calculation scheme?
In short, how to deallocate the memory consumed by metal objects like command buffer, compute pipeline, encoders etc.
I would suggest looking at autoreleasepool. It is intended to be used for iterations, it frees memory each loop.
Supposing your render function is called performHistogram you can do something like this:
var myTexture: MTLTexture? = nil
autoreleasepool {
myTexture = performHistogram()
}
//myTexture has been updated and memory should be freed.

is there a way to measure Swift's performance without building UI on iPhone with Xcode 11? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need to measure performance of different swift libraries without writing UI on iPhone. There are many examples of Swift/UI examples that are normally, multi-threaded in nature. So what I want to measure is raw performance without gui overhead, if possible. And the output can we printed into the Xcode 11 console window in debugger, for example. Could you please kindly point me where I could find such sample code ? I would greatly appreciate the help.
This is an example of how to measure the time of a sum of numbers
let numbersArray = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6]
func showBenchmarkTime(title:String, operation:()->()) {
let startTime = CFAbsoluteTimeGetCurrent()
operation()
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime
print("Time elapsed for \(title): \(timeElapsed) s.")
}
showBenchmarkTime(title: "sum an array of numbers") {
print(numbersArray.reduce(0, +))
}

Is there such thing as a Perabyte? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I recently saw a marketing video that cited the "Perabyte" as a unit of disk storage measure. I emailed a representative responsible for the video and got a response that "1 Perabyte (PB) = 1024 Terabytes (TB)."
A quick google search seems to indicate that a Petabyte is defined as 1000 TB.
Is a Perabyte a real thing, and is it 1024 (vs 1000) TB?
Edit: This thread has answered my question, despite the votes to close. No one has heard of a "Perabyte" except as a misspelling of "Petabyte." Thanks.
Edit (2): Petabytes have been tagged real by "BRIGHT SIDE"
A perabyte doesn't exist, but a petabyte is a real thing. It is
2^50 bytes; 1024 terabytes, or a million gigabytes.
It seems likely that your perabyte was the result of a typo, seeing as 'r' and 't' are close on the keyboard.
The 1024 versus 1000 question most likely arises from which base you are using.
1024 is base 2, 1000 is base 10.
See https://en.wikipedia.org/wiki/Petabyte
A petabyte is 10005, or 1000 terabytes.
A pebibyte is 250, or 1024 tebibytes.
A perabyte is not a thing.

Floating point inexact result exception in TFDTable Component in Delphi [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am using TFDTable component in Delphi Seattle. I have kept this table component at design time.
While executing
TFDTable(Compo).Open
I get error while debugging (Ctrl +F7) "Floating point inexact result at 0042F353"
I googled, but got the reason but didn't get exactly what it is.
Any suggestions?
Reference URL:
http://www.delphigroups.info/2/e8/524771.html
Floating Point inexact result
This exception suggests that you have
the "loss of precision" mask bit in the FPU turned OFF. It is
normally ON. Look for the $0020 bit in the system variable
Default8087CW and try ORing in $0020 into the control word with a
Set8087CW(Default8087CW or $0020) statement.
http://www.umiacs.umd.edu/~resnik/ling645_sp2002/cmu_manual/node19.html
There is a well known issue that Default8087CW as a global variable can be misused by libraries or even your own code and be changed at any time in ways that cause unexpected results of FP calculations or unexpected exceptions to occur. The six lowest bits of the 8087 FPU Control word are the exception mask bits, meaning that if a bit is set, corresponding exception is masked, that is prevented from being raised.
The "loss of precision" mask bit that John Herbster is talking about is one of those bits, in Delphis TArithmeticException enum called exPrecision. Further he suggests to assure this bit is set by calling the Set8087CW(Default8087CW or $0020). Since you are using Delphi 10 Seattle, it is recommended to use the SetExceptionMask() function (from the System.Math unit) instead, since it handles equally also the corresponding SSE mask on 64 bit hw:
var
OldExceptionMask: TArithmeticExceptionMask;
...
OldExceptionMask := SetExceptionMask(GetExceptionMask + [exPrecision]);
Calling the above before TFDTable(Compo).Open should solve your problem.
The function takes and returns a TArithmeticExceptionMask (set of TArithmeticException). All other exception enums and FPU/SSE related functions are in the documentation.

Counting the number of elemnts in a stack [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am working with delphi.How do i get the total number of elements in a stack and retain the stack after the process.I am aware that this can also be achived by creating a temporary stack and copying the original stack to the new one (temp),so as to then pop the elements from the temp while counting, but i am not allowed to use this formular. Can somebody help me with an algorthm that achieves my task please!
If you are using the generic TStack collection class in Delphi XE4 then the number of elements currently in the stack is already exposed directly via the Count property:
var
myStack: TStack<Integer>;
begin
myStack := TStack<Integer>.Create;
myStack.Push(42);
ShowMessageFmt('Stack contains %d elements', [myStack.Count]);
myStack.Free;
end;
However, since you presumably have not found this property then it is possible you are using some other stack implementation.
Determining how best to access the same information about the stack from the implementation you are using is impossible without further details about that particular implementation.

Resources