I am working on a project for the FPGA implementation of the Breakout Game. In this game, we have to break the bricks using a ball and a paddle. Some bricks may break on multiple contacts with the ball. For this, I am using an integer array to represent the number of hits required to break a particular brick. eg (2,0,1,2) represents a brickk which needs 2 hits to be broken followed by a broken brick followed by a brick which needs a single hit to be broken et al.
Also, I have done all my coding in VHDL but in order to output the results onto the VGA screen, I am using Verilog.
In VHDL, I have declared a type for an integer array in a package as follows:
package mytypes_pkg is
type int_array is array (0 to 39) of integer;
end mytypes_pkg;
then in my ball motion controlling file, I have imported work.mytypes_pkg.all and then have:
brickout:out int_array;
which contains the current state of all the bricks in the game. This array has to be passed to my Verilog file where all the VGA Display generation has to take place. There, I tried
input [39:0] bricki;
but it gives me the error
"Different types for port 'brickout' on entity and component for 'mainc'"
How can I rectify this error and do what I want to do? Is there some way of telling Verilog that bricki is also of type int_array? And do I need to import work.mytypes_pkg.all in Verilog too?
In SystemVerilog you can use typedef to define your own types, e.g.
typedef int [N-1:0] mytype;
and this way build exactly what you want. Define your types in a package and then import it:
import pkg_keccak::mytype;
...
mytype int_table;
Related
Part of my project is to design a 16bit Multiplier with an arrayMultiplier structure. In this array Multiplier instead of using 1 bit adders, I made a 16bit Adder (which is working, I've done simulations). I'm using it as a component in the multiplier.
Note I have attach my last name to every variable according to the professor, please ignore that
I have to put it into a pastebin cause it's too long for posting. Please ignore the comments that say like +16, FA, -1. This is for me to just follow a diagram for proper indexing.
This is an example diagram
https://d2vlcm61l7u1fs.cloudfront.net/media%2F27b%2F27b41d2f-aa6c-4a81-bdc0-16ff1c681fc7%2FphpQ0V3VI.png
**REDACTED **
Third is the error itself
Code Redacted
https://pastebin.com/tZ6ptLYp
I'm not sure what the error is saying so I can't solve the issue. Been working on this for hours so maybe I'm just tired and am not seeing it. Thanks
The problem is that you bind multiple wires to the same output wire.
For example :
Line 57 : ... Arena_16bitOUT_Cout_fa => Arena_Cout_vec(0) ...
Line 61 : ... Arena_16bitOUT_Cout_fa => Arena_Cout_vec(0));
I guess it is just copy/paste errors. I did not read all the logic but if it is not the case, you will need some multiplexing logic.
Is it possible to inject a signal by itself with no coloured Gaussian noise?
Question asked by Arunava Mukherjee via email
Yes. There are two easy ways to do this.
1) Use the existing helper functions
When generating an interferometer object, bilby provides several helper routines denoted by bilby.gw.detector.get_interferometer_with.... In this case, you'll want to use this function (I've truncated the doctring)
bilby.gw.detector.get_interferometer_with_fake_noise_and_injection(
name, injection_parameters, injection_polarizations=None,
waveform_generator=None, sampling_frequency=4096, duration=4,
start_time=None, outdir='outdir', label=None, plot=True, save=True,
zero_noise=False)
Docstring:
Helper function to obtain an Interferometer instance with appropriate
power spectral density and data, given an center_time.
Note: by default this generates an Interferometer with a power spectral
density based on advanced LIGO.
Parameters
----------
name: str
Detector name, e.g., 'H1'.
...
zero_noise: bool
If true, set noise to zero.
So you just pass the flag in and it will create an interferometer with just the injection signal (you'll then need to make one for each interferometer you want in the list of interferometers passed in to the likelihood.
2) Use the low level set strain data methods
Alternatively, you may instead wish to use the low level methods themselves. As a general rule of thumb, you can always look at the source code for the generic helper functions to figure out how this should be done. Here, we create a H1 interferometer set the strain data with zero noise and inject a signal:
interferometer = get_empty_interferometer("H1")
interferometer.power_spectral_density = PowerSpectralDensity.from_aligo()
interferometer.set_strain_data_from_zero_noise(
sampling_frequency=sampling_frequency, duration=duration,
start_time=start_time)
injection_polarizations = interferometer.inject_signal(
parameters=injection_parameters,
waveform_generator=waveform_generator)
Information correct as of v.0.3.5
Used Versions: OMNeT++ 5.0 with iNET 3.4.0
During some data analysis I noticed that the CSV-export of the analysis tool rounds values like 0.01146575 to 0.0114658. Even if I set the precision to the maximum value of 18.
Here some parts of my code:
In .ned I declared the recording using the type 'simtime_t':
#signal[timestamp](type="simtime_t");
#statistic[timestamp](title="timestamp"; record=mean);
At the top of my .cc I declared the signals:
simsignal_t timestampSignal;
timestampSignal = registerSignal("timestamp");
and somewhere in my code I got:
sintime_t myTime = ...
emit(timestamp, myTime);
Browsing my results in the .anf file I see the right timestamps, but when i export the data via CSV-export I get the bad rounding.
I think myTime is internally converted to a double value. I don't really know the reason, because I set the type of my signal to 'simtime_t'. The mentioned export-precision of '18' should normally be precise enough to display such values.
Is there anything I can do to avoid the rounding of my values? The .octave-exports seems to work fine, but I can't process this file-format in the way I want to.
Now that we've reached Swift 2.0, I've decided to convert my, as yet unfinished, OS X app to Swift. Making progress but I've run into some issues with using termios and could use some clarification and advice.
The termios struct is treated as a struct in Swift, no surprise there, but what is surprising is that the array of control characters in the struct is now a tuple. I was expecting it to just be an array. As you might imagine it took me a while to figure this out. Working in a Playground if I do:
var settings:termios = termios()
print(settings)
then I get the correct details printed for the struct.
In Obj-C to set the control characters you would use, say,
cfmakeraw(&settings);
settings.c_cc[VMIN] = 1;
where VMIN is a #define equal to 16 in termios.h. In Swift I have to do
cfmakeraw(&settings)
settings.c_cc.16 = 1
which works, but is a bit more opaque. I would prefer to use something along the lines of
settings.c_cc.vim = 1
instead, but can't seem to find any documentation describing the Swift "version" of termios. Does anyone know if the tuple has pre-assigned names for it's elements, or if not, is there a way to assign names after the fact? Should I just create my own tuple with named elements and then assign it to settings.c_cc?
Interestingly, despite the fact that pre-processor directives are not supposed to work in Swift, if I do
print(VMIN)
print(VTIME)
then the correct values are printed and no compiler errors are produced. I'd be interested in any clarification or comments on that. Is it a bug?
The remaining issues have to do with further configuration of the termios.
The definition of cfsetspeed is given as
func cfsetspeed(_: UnsafeMutablePointer<termios>, _: speed_t) -> Int32
and speed_t is typedef'ed as an unsigned long. In Obj-C we'd do
cfsetspeed(&settings, B38400);
but since B38400 is a #define in termios.h we can no longer do that. Has Apple set up replacement global constants for things like this in Swift, and if so, can anyone tell me where they are documented. The alternative seems to be to just plug in the raw values and lose readability, or to create my own versions of the constants previously defined in termios.h. I'm happy to go that route if there isn't a better choice.
Let's start with your second problem, which is easier to solve.
B38400 is available in Swift, it just has the wrong type.
So you have to convert it explicitly:
var settings = termios()
cfsetspeed(&settings, speed_t(B38400))
Your first problem has no "nice" solution that I know of.
Fixed sized arrays are imported to Swift as tuples, and – as far as I know – you cannot address a tuple element with a variable.
However,Swift preserves the memory layout of structures imported from C, as
confirmed by Apple engineer Joe Groff:. Therefore you can take the address of the tuple and “rebind” it to a pointer to the element type:
var settings = termios()
withUnsafeMutablePointer(to: &settings.c_cc) { (tuplePtr) -> Void in
tuplePtr.withMemoryRebound(to: cc_t.self, capacity: MemoryLayout.size(ofValue: settings.c_cc)) {
$0[Int(VMIN)] = 1
}
}
(Code updated for Swift 4+.)
In google's Protocol Buffers, I use large enums and I have to assign each integer value explicitly:
enum Function {ProcessLibrary=0;
RotateLeft=1;
RotateRight=2;
...}
This is very annoying and ugly. Is there a way to avoid these integer values in the code?
something like:
enum Function {ProcessLibrary;
RotateLeft;
RotateRight;
...}
No, basically. This is deliberate to prevent huge errors when adding / removing enums, and to allow for non-contiguous enums.
In most real-world cases where the list of names is already defined elsewhere, you can write a 5 line script to add =n onto each - heck, a spreadsheet calculation and "fill down" would go a long way to it - paste names into the first column, copy the generated lines out of the second.