Design a circuit that can add and subtract two 2-bit two\'s complement binary nu
ID: 3604105 • Letter: D
Question
Design a circuit that can add and subtract two 2-bit two's complement binary numbers and check for overflow. Your circuit should have a 2-bit input A = a2a1, a 2-bit input B = b2b1, a 1-bit input M, a 2-bit output S = s2s1, and a 1-bit output OF. When M = 0, the output S should be the sum of A and B (i.e. S = A + B), and when M = 1 the output should be S = A - B. The output OF should be 1 if overflow occurs.
a. Create a truth table for the circuit described above. The truth table has been created below with a few filled out as examples, fill out the rest of the table.
b. Draw the resulting circuit diagram.
Explanation / Answer
rabbit0 = 100; fox0 = 10; Y0 = [rabbit0; fox0]; % pack the i.c. into a column vector % testing -- uncomment for simple call to make a plot % ode45(@lotka, [0 365], Y0) % % return % set the time interval for solving Tstart=0; Tend = 365*2; % 2 years % solve the ODE [T, X] = ode45(@lotka, [Tstart, Tend], Y0); % unpack the results. % In the output array X, variables are in each column, with time running down the rows rabbits = X(:,1); % all rows, first column foxes = X(:,2); $ all rows, second column % make some nice plots figure % time series subplot(2,1,1) plot (T,rabbits, T,foxes) xlabel('Day') ylabel('Population') legend('Rabbits', 'Foxes') % rabbits vs foxes subplot(2,1,2) plot (rabbits,foxes) xlabel('Rabbits') ylabel('Foxes') end function rate = lotka(t, V) % Poulation growth of Rabbits and Foxes % Note that rabbits is first column, foxes second % unpack the dependent varables rabbits = V(1); foxes = V(2); % set some parameters a= 0.1; b= 0.01; c= 0.1; e= 0.2; % a= 0.1*(1 + .5*sin(2*pi*t/365)); % allow annual cycle in rabbit growth % compute rates for each dependent variable dr = a*rabbits - b*rabbits*foxes; df = e*b*rabbits*foxes - c*foxes; % pack rates into a column vector as the output variable rate = [dr; df]; end Starting from this program, create a new program to solve the Lorenz system: dx/dt=-sigma*x+sigma*y dy/dt=beta*x-y-x*z dz/dt=-rho*z+xy sigma=10, beta=8/3, rho=28
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.