So for my digital logic course, we were asked to design a combinational circuit with 3 inputs, and an output that generates the square of the binary input. I assume she means the inputs are 3 bit binary numbers 0-7. In describing the solution, she mentioned 3 general steps of 1. Finding truth table, 2. deriving the function and 3. Simplifying
I understand perfectly how to do this when the output is a single function (combine the instances of a true function, simplify etc.) In our only relevant example, we input BCD numbers 0-9 and output their excess-3 equivalent, then simplified a k-map for each of the 4 output variables (a map for W, the leftmost bit, X the second-to-left bit, etc.). Not sure what to do from here tho. Thanks for the help
As you already mentioned, you need to fetch the inputs in binary, calculate the square in binary format (the binary length will increase from 3 to 6).
But, you don't need those BCD numbers and output their excess-3 equivalent. That would rather make the problem more complex. Simply do as directed below.
So, for the 3 different bit combinations, you need to generate a function in terms of combinational circuit that will yield a 6-bit square of the given number.
So, your input set = {b0,b1,b2} and your output set = {B1,B2,B3,B4,B5,B6}.
Then, you need to draw the truth table of 3-bit to 6-bit square converter as :-
Input B6 B5 B4 B3 B2 B1 B0
b0
b1
b2
Fill the entries, that's the homework for you.
And, then when you have output bits B6,B5,...,B0 in terms of b0,b1 and b2, just simplify all the functions.
If you still have any doubt, comment below. I will help you with your issue. Good luck.
I have used Logic Friday 1 to derive the following minimized expression for the six outputs of your multiplier:
ab5 = a2 a1 b2 b1 + a2 a1 a0 b2 b0 + a2 a0 b2 b1 b0;
ab4 = a2 a1' a0' b2 + a2 a1' b2 b1' + a2 a0' b2 b1'
+ a2 a1' b2 b0' + a2 b2 b1' b0' + a2' a1 a0 b2 b1
+ a2 a1 b2' b1 b0 + a1 a0 b2 b1 b0;
ab3 = a2' a1 a0' b2 + a2 a1' b2' b1 + a2' a1 b2 b1'
+ a2 b2' b1 b0' + a2' a1 a0 b2' b1 b0 + a2 a1' a0 b2 b1' b0
+ a1 a0' b2 b1' + a2 a1' b1 b0' + a2 a0' b2 b1 b0
+ a2 a1 a0 b2 b0';
ab2 = a2' a1 a0' b1 + a2 a1' a0' b0 + a2 a0' b1' b0
+ a1' a0 b2 b0' + a1 a0' b1 b0' + a1 b2' b1 b0'
+ a0 b2 b1' b0' + a2' a0 b2 b0 + a2 a0 b2' b0;
ab1 = a1' a0 b1 + a1 a0' b0 + a1 b1' b0 + a0 b1 b0';
ab0 = a0 b0;
As a truth table:
The original truth table has 64 rows.
The largest output number is 49 = 7 * 7 = 32 + 16 + 1.
Therefore, six (= 3 + 3) output bits are sufficient.
Related
I have been going through Faster RCNN Paper and I am facing a trouble understanding how to find out the positive and negative anchors at the time of training RPN's
As per the paper (Section 3.1.2), for each anchor, authors assign a positive label for
The anchor/anchors with the highest IoU overlap with a ground-truth box
An anchor that has IoU overlap higher than 0.7 with any ground-truth-box
for finding the negative proposal (background proposal), go through the remaining anchors and assign a negative label if
IoU is less than 0.3 for all ground-truth box
The remaining anchors even after this step are ignored while training.
EXAMPLE
G/A
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
0.54
0.44
0.02
0.03
0
0.25
0.78
0.71
0.29
0.01
G2
0.63
0.28
0.68
0.62
0.9
0.21
0.73
0.26
0.27
0.14
G3
0.66
0.26
0.03
0.64
0.54
0.53
0.47
0.46
0.15
0.02
After applying rule 1 (for each ground truth, find the maximum IoU with anchor and assign it as positive), So
For G1, the highest value is for A7, so A7 is matched to G1
For G2, the highest value is for A5, so A5 is matched to G2
For G3, the highest value is for A1, so A1 is matched to G3
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
G2
G1
After applying rule 2 we will get (for each anchor box, if IOU is greater than 0.7, then assign to the ground-truth)
For A8, the maximum value occurs with G1, so A8 is matched with G1
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
G2
G1
G1
After applying rule 3 we will get
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
G2
G1
G1
N
N
Now all the remaining one are marked as ignored.
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
I
I
I
G2
I
G1
G1
N
N
My questions :
I wanted to know if my understanding is right or wrong ?
Also, if the rules are applied in different order then will it change the final output ?
In the above example, for rule 1 if suppose G2 maximum is also A7, then A7, then how should one decide G1 or G2 (I suppose choose the one which has the maximum, but I am not sure though)
Thanks.
I have two tables:
Table 1
MARKET ATC3 ATC4 PRODUCT BOOLEAN FLAG JOINING COLUMN
A1 B1 B1C1 D1 1 ATC4
A2 B1 B1C2 D2 1 ATC4
A2 B1 B1C3 ATC4
FAMILY A B1 ATC3
Table 2:
PRODUCT ATC3 ATC4 VALUES
D1 B1 B1C1 10
D1 B1 B1C1 20
D2 B1 B1C2 15
D2 B1 B1C2 25
D2 B1 B1C2 10
D3 B1 B1C3 5
My desired output:
PRODUCT ATC3 ATC4 VALUES MARKET VALUES
D1 B1 B1C1 10 A1 10
D1 B1 B1C1 20 A1 20
D2 B1 B1C2 15 A2 15
D2 B1 B1C2 25 A2 25
D2 B1 B1C2 10 A2 10
D3 B1 B1C3 5 A2 5
ALL D1+D2+D3 FAMILY A 85
The idea is, Table 2 has many rows and products but does not have Market. Table 1 helps you find out which product in Table 2 belongs to which Market-based on the Joining column. For example, There are 3 Markets present in Table 1, I want to then assign a new column Market in Table 2 such that all PRODUCTS in Table 2 with the ATC4 code of B1C1 belongs to the Market A1. Why? Because in Table 1, it says that Market A1 should follow the Joining Column of ATC4 - which corresponds to the code B1C1. In Table 1, we also provided a Product column, this is just for our purpose of identifying our own companies product name. Now if you see that for Table 1, there are two rows of Market A2, with different ATC4, this is very normal, because maybe Product D2 and D10 belong to Market A2, but both may contain different ATC4!
There is also one more nuance to it, we have Family A! This is merely a combination of A1+A2, but in my Table 2, there is no such row value that sums up to Family A. So I need to achieve two things:
I want to make a new column Market in Table 2 so that each product is mapped to the market.
I want to create extra rows to account for the Market Family A (A1+A2) and call the product Name "Lovely Family A" or something. The above table 3 provides an expected output.
Since I am new to SQL, I tried to first use CASE Statements, to map slowly one by one, but soon it gets tedious and I wonder if there's some tricks.
My CASE looks like this
,CASE WHEN ATC4 LIKE '%B1C1%' THEN 'A1'
WHEN ATC4 LIKE '%B1C2%' OR ATC4 LIKE '%B1C3%' THEN 'A2' ELSE ATC4 END AS MARKET_NAME
but have yet to figure out how to add the additional row where I can sum up A1+A2.
You seem to want something like this:
with rows as (
select PRODUCT, ATC3, ATC4, VALUES
from table2
union all
select 'ALL D1+D2+D3', ATC3, NULL, SUM(VALUES)
from table2
group by ATC3
)
select r.*, t1.market
from rows r join
table1 t1
on (t1.joining_column = 'ATC3' and t1.atc3 = r.atc3) or
(t1.joining_column = 'ATC4' and t1.atc4 = r.atc4);
I see no reason to repeat the values column. And values is a really bad name for a column because it is a SQL keyword.
I have table with several entries for one point, is it possible to show only last entry for each point?
Example
points | date
A1 2016-02-12
A1 2016-02-15
A1 2016-03-12
B1 2016-01-11
B1 2016-03-15
B1 2015-09-28
C1 2016-01-28
C2 2016-03-03
D1 2015-12-12
D1 2016-01-12
E2 Null
E3 Null
F1 Null
I want to get something like this, without ignoring Null values.
points | date
A1 12.03.2016.
B1 12.03.2016.
C1 03.03.2016.
D1 12.01.2016.
E2 Null
E3 Null
F1 Null
I edited question because I tried group by and it didn't work for me( I forgot to mention before) It showed only entries with date, and I need points with null value as well
Something like this:
A1 12.03.2016.
B1 12.03.2016.
C1 03.03.2016.
D1 12.01.2016.
You can get by using MAX FUNTION
SELECT points,MAX(date)
FROM table_name
GROUP BY points;
if you want to change date format you can use DATE_FORMAT function
I have a table tbl_usi in mysql with records as below:
present_date usi_value deal_count
----------------------------------------------------------
2015-10-13 b1 c1
2015-10-12 b2 c2
2015-10-11 b3 c3
I want to write a query that will do this using present_date field to select the present date and the date before it and display them together:
present_date usi_value deal_count previous_date previous_usi_value previous_deal_count
----------------------------------------------------------
2015-10-13 b1 c1 2015-10-12 b2 c2
2015-10-12 b2 c2 2015-10-11 b3 c3
2015-10-11 b3 c3 2015-10-10 b4 c4
How do I achieve this. Thanks
Select everything from your table, then join it to itself, making sure the 2 joined tables are given different names so you can distinguish them (I used 'a' and 'b' here). The join offsets the dates by 1 day. Then you can select the fields you want from the joined table.
select
a.present_date,
a.usi_value,
a.deal_count,
b.present_date as previous_present_date,
b.usi_value as previous_usi_value,
b.deal_count as previous_deal_count
from
tbl_usi as a
left join tbl_usi as b
on b.present_date = a.present_date - interval 1 day;
If you didn't already have one before, you will now want an index for the present_date column too BTW.
Alternative, which works when there are date gaps.
select
a.present_date,
a.usi_value,
a.deal_count,
b.present_date as previous_present_date,
b.usi_value as previous_usi_value,
b.deal_count as previous_deal_count
from
tbl_usi as a
join tbl_usi as b
where
b.present_date = (select max(present_date) from tbl_usi where present_date < a.present_date);
As with previous solution the same table is joined twice, but this time the previous row is found by way of a subquery.
In my hymn, I need to start the first measure halfway through. It has a time of 3/4, but I have to insert two empty, non-showing eighth notes. How do I do that?
I've used o4 o4 c8[ d] below for the first measure, but lilypond does not like this. What's the right way?
Here's the line:
o4 o4 c8[ d] e4 e4 e8[ f] g4 g4 f8[ e] d4 d4 g8[ f] e2
For upbeats, there's a special command \partial available. In your case, you should notate a quarter partial:
\relative c' {
\time 3/4
\partial 4
c8 d | e4 e4 e8 f | g4 g4 f8 e | d4 d4 g8 f | e2
}
This results in: