Need help in adding functionality to MIPS single cycle datapath? - mips

I'm trying to add functionality to these datapaths so that it can read the following instruction:
ADDNEW X, Y, Z
if (Y > Z) X = Y+ Z
else X = MEM[Y+Z]
Not really sure where to start.. so any hints are appreciated. I think I need to rewrite the result of the slt somewhere to tell it which way to go.. but not sure how? Yes is for homework so not expecting answers.. just hopefully a direction. Thank you..
second http://www.utdallas.edu/~cantrell/ee4304/Pipe-data+control.jpg

The top design is a single cycle and the bottom design is a pipeline design.

Related

Cut ultrasound signal between specific values using Octave

I have an ultrasound wave (graph axes: Volt vs microsecond) and need to cut the signal/wave between two specific value to further analyze this clipping. My idea is to cut the signal between 0.2 V (y-axis). The wave is sine shaped as shown in the figure with the desired cutoff points in red
In my current code, I'm cutting the signal between 1900 to 4000 ms (x-axis) (Aa = A(1900:4000);) and then I want to make the aforementioned clipping and proceed with the code.
Does anyone know how I could do this y-axis clipping?
Thanks!! :)
clear
clf
pkg load signal
for k=1:2
w=1
filename=strcat("PCB 2.1 (",sprintf("%01d",k),").mat")
load(filename)
Lthisrun=length(A);
Pico(k,1:Lthisrun)=A;
Aa = A(1900:4000);
Ah= abs(hilbert(Aa));
step=100;
hold on
i=1;
Ac=0;
for index=1:step:3601
Ac(i+1)=Ac(i)+Ah(i);
i=i+1
r(k)=trapz(Ac)
end
end
ok, you want to just look at values 'above the noise' in your data. Or, in this case, 'clip out' everything below 0.2V. the easiest way to do this is with logical indexing. You can take an array and create a sub array eliminating everything that doesn't meet a certain logical condition. See this example:
f = #(x) sin(x)./x;
x = [-100:.1:100];
y = f(x);
plot(x,y);
figure;
x_trim = x(y>0.2);
y_trim = y(y>0.2);
plot(x_trim, y_trim);
From your question it looks like you want to do the clipping after applying the horizontal windowing from 1900-4000. (you say that that is in milliseconds, but your image shows the pulse being much sooner than 1900 ms). In any case, something like
Ab = Aa(Aa > 0.2);
will create another array Ab that will only contain the portions of Aa with values above 0.2. You may need to do something similar (see the example) for the horizontal axis if your x-data is not just the element index.

Inverted Smoothstep?

I am currently trying to simulate ballistics on an object, that is otherwise not affected by physics. To be precise, I have a rocket-like projectile, that is following an parabolic arc from origin to target with a Lerp. To make it more realistic, I want it not to move at constant speed, but to slow down towards the climax and speed up on its way back down.
I have used the Mathf.Smoothstep function to do the exact opposite of what i need on other objects, i.e. easing in and out of the motion.
So my question is: How do I get an inverted Smoothstep?
I found out that what i would need is actually the inverted formula to smoothstep [ x * x*(3 - 2*x) ], but being not exactly a math genius, I have no idea how to do that. All I got from online calculators was some pretty massive new function, which I'm afraid would not be very efficient.
So maybe there is a function that comes close to an inverted smoothstep, but isn't as complex to compute.
Any help on this would be much appreciated
Thanks in advance,
Tux
Correct formula is available here:
https://www.shadertoy.com/view/MsSBRh
Solution by Inigo Quilez and TinyTexel
Flt SmoothCubeInv(Flt y)
{
if(y<=0)return 0;
if(y>=1)return 1;
return 0.5f-Sin(asinf(1-2*y)/3);
}
I had a similar problem. For me, mirroring the curve in y = x worked:
So an implementation example would be:
float Smooth(float x) {
return x + (x - (x * x * (3.0f - 2.0f * x)));
}
This function has no clamping, so that may have to be added if x can go outside the 0 to 1 interval.
Wolfram Alpha example
If you're moving transforms, it is often a good idea to user iTween or similar animation libraries instead of controlling animation yourself. They have a an easy API and you can set up easing mode too.
But if you need this as a math function, you can use something like this:
y = 0.5 + (x > 0.5 ? 1 : -1) * Mathf.Pow(Mathf.Abs(2x - 1),p)/2
Where p is the measure of steepness that you want. Here's how it looks:
You seem to want a regular parabola. See the graph of this function:
http://www.wolframalpha.com/input/?i=-%28x%2A2-1%29%5E2%2B1
Which is the graph that seems to do what you want: -(x*2-1)^2+1
It goes from y=0 to y=1 and then back again between x=0 and x=1, staying a bit at the top around x=0.5 . It's what you want, if I understood it correctly.
Other ways to write this function, according to wolfram alpha, would be -(4*(x-1)*x) and (4-4*x)*x
Hope it helps.

How to prevent maxima to rewrite the output of 2*sqrt(2) to 2^(3/2)?

Maxima input of
2*sqrt(2)
by default returns the output
2^(3/2)
How can I get Maxima to just return 2*sqrt(2) ?
(I use this in the tex() function.)
To the best of my knowledge, there is no way to prevent Maxima from simplifying 2*sqrt(2) to 2^(3/2), with two probably-hard-to-use exceptions:
(1) Turn off simplification entirely. But that disables all simplifications, e.g. 1 + 1 simplifying to 2. But if you want to try it: just enter simp : false;.
(2) Disable the simplification sqrt(2) to 2^(1/2) via :lisp (setf (get '%sqrt 'operators) nil) But then Maxima for the most part doesn't know what to do with sqrt.
I don't recommend either one of these.
You can try something like
simp: false;
tex(2*sqrt(2));
block code...;
simp: true;
That way you don't have to disable the simplification permanently.
You can do this:
(%i1) matchdeclare(n_, integerp,m_, integerp)$
tellsimp(n_*sqrt(m_), n_*sqrt(box(m_)))$
and afterwards:
(%i3) 2*sqrt(2);
(%o3) 2 √2
(%i4) sqrt(3)*9;
(%o4) 9 √3
You'll notice that the number under the square root sign in the output is colored red, because of box(). But if you select the expression in wxMaxima, and then popup "Copy LaTeX", you'll get exactly what you want, e. g.
\[2\,\sqrt{2}\]
Unfortunately if you try tex(2*sqrt(2)) to get the TeX code, you'll get $$2\,\sqrt{\boxed{2}}$$instead.

Switching a logic gate on or off

if I have an "AND gate" with three inputs "A,B and control line C"
can I control switching AND gate on or off .. just like this if C == 1 then AND gates works with input A,B if C==0 then nothing happens
can this be done by any method ??
This is how you would do it in pseudo-code(if I understood correctly):
if((c == 1) && (A || B))
Forgive me if I've got the wrong end of the stick- logic gates are just a way of making a simple concept confusing to me.
Achieve the same output from simpler (2-input) AND gates:
Yeah, hook a switch to the chip to toggle whether it is powered on or not. You don't need any fancy equipment or doubled gates, just turn the thing on to have it function as normal, turn it off and no matter what inputs you apply you'll get 0v on the output pin.

Achartengine: reverse y axis, how to do?

I'm using achartengine to show graph, but I want to reverse the y axis for example from 15 up to 0. Someone can help me?
I needed just to add:
XYMultipleSeriesRenderer aRenderer = new XYMultipleSeriesRenderer();
aRenderer.setYAxisMin(15);
aRenderer.setYAxisMax(1);
aRenderer.setYLabels(15);