Академический Документы
Профессиональный Документы
Культура Документы
Arnold S. Berger
Solutions for
Even-Numbered Problems
510 = 111111110
64,200 = 1111101011001000
4,001 = 111110100001
255 = 11111111
F = A*B
4. When X is raised to logic level 1 it creates a low impedance path to ground. The signal from A
to B is short-circuited to ground. No signal can travel from A to B unless X is at logic 0.
6. The rst thing to notice is that the NOT gate connected to input C controls the
two AND gates. When C = 0, the upper AND gate is enabled, when C = 1, the
lower AND gate is enabled. Thus, we may consider the effects of NOR and
XOR gates independently. Here is the truth table:
8.
OR gate
A=0
A=1
A
0
1
0
1
0
1
0
1
B
0
0
1
1
0
0
1
1
C
0
0
0
0
1
1
1
1
X
1
0
0
0
0
1
1
0
CASE 1
A
A NOR B
*A
*B
*A AND *B
CASE 2
B
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
C
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
D
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
X
1
1
1
0
0
1
1
0
1
0
0
0
0
0
0
1
A NAND B
*A
*B
*A OR *B
XOR
XOR
AND
XOR
XOR
8. This problem can be very tedious, but it is actually quite simple if you realize that you can
convert the logic to positive logic for the output devices. This means that there is only one
output term for each row in the truth table. Then you only need to add a NOT gate at the end
(or use a NAND gate). You could still do all of the Boolean algebra and K-map manipulations
and you would arrive at the right answer.
A0
A0 A1 A1 A2
A2
NAND
CS0
NAND
CS1
NAND
CS2
NAND
CS3
NAND
CS4
NAND
CS5
NAND
CS6
NAND
CS7
Clock
Q0
Q1
Q2
T0 T1
T2
T3
T4
T5
T6
T7
T8
4. FF1 and FF2 are connect like a binary counter, so theyll count up from 00 to 11 and then
return to 00. Thus, we can ll them in right away. The XOR gate will have a zero output if
both inputs are 1 or 0, so after the RESET pulse, the *Q outpus are 1, so the output of the
XOR gate is 0. Thus, the pattern that will exit the XOR gate is 0, 1, 1, 0, 0. This is then the
inputs to FF# and FF4. The truth table is shown below:
After reset pulse
After clock pulse 1
After clock pulse 2
After clock pulse 3
After clock pulse 4
Q0
Q1
Q2
Q3
0
1
0
1
0
0
0
1
1
0
0
0
1
1
0
0
0
0
1
1
6. Each D-FF stage in the counter introduces a delay of 25 ns from the rising edge of the clock to
the time that the output change has settled down. Therefore, when we have one clock pulse enter
the rst FF, then changes to the last Q output (if any) will occur 8 25 ns later, or after 200 ns.
If we want to be sure that the last output has stabilized before another clock pulse can come in,
then the next rising clock edge cant occur until 200 ns has elapsed. Therefore, the frequency
of a string of clock pulses that have rising edges separated by 200 ns is 1/200 ns or 5.0 MHz.
7
Cout
K
LOAD
In case youre wondering how the circuit was derived, heres the details. Following is the truth
table:
Cin
LOAD
Cout
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
1
1
1
0
0
0
1
0
0
0
1
1
1
1
1
0
0
0
0
101
001
110
0
1
0
1
0
1
0
1
Bin
0
0
1
1
0
0
1
1
Cin
0
0
0
0
1
1
1
1
Anext Bnext
1
1
X
0
1
0
0
1
1
0
X
0
1
1
0
0
Cnext
0
1
X
1
1
1
0
0
X = Dont care.
In the gure, below, each of the input variable becomes an output variable to determine the
next state.
The Karnaugh maps are shown below with the logic gates. In this particular case, we didnt
need to use the fact that state 010 never shows up. It doesnt help us.
AB AB
B B C C
C
AB AB
1
1
Anext
AB AB
Bnext
AB AB
1
Cnext
AB AB
1
1
1
1/0
000
0/0
1/0
0/0
100
1/0
001
0/0
010
1/0 0/0
0/0
1/1
011
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
IN
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
X
0
X
0
X
0
0
0
X
0
X
1
X
0
0
1
X
1
X
0
X
0
0
0
X
0
X
0
X
0
1
1
X
0
X
0
X
1
0
0
X
0
X
0
X
0
0
0
X
0
X
0
X
0
0
0
X
0
X
1
X
10
a
b
c
C
Q
D
clock
B
Q
D
clock
A
Q
D
clock
OUT
Clock
11
Q
D
clock
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
A1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
R/W
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
CS
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
W0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
CS0
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
W1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
CS1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
W2
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
CS2
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
W3
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
CS3
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
The rst thing to notice is that the output side of the truth table is almost all 1s. This could
make the K-map reduction really tedious. However, there is hope. Suppose that on the output
side we change the sense of the logic. Lets make 0 true and 1 false. Suddenly, the truth table
gets a lot simpler. In fact, it becomes so simple we dont need a K-map because each output
variable is true for only one set of conditions (one row) of the input variables.
By inspection, the equations are:
W0 = A0 * A1 * (R/W) * CS
W1 = A0 * A1 * (R/W) * CS
W2 = A0 * A1 * (R/W) * CS
W3 = A0 * A1 * (R/W) * CS
CS0 = A0 * A1 * (R/W) * CS
W1 = A0 * A1 * (R/W) * CS
W2 = A0 * A1 * (R/W) * CS
12
W0
A1
W0
R/W
CS
W2
W3
CS0
CS1
CS2
CS3
4. A clock frequency of 50 MHz has a clock period of 20 nanoseconds. From the timing diagram
we see that RD, WR and ADDRVAL go low on the falling edge of T1 and they rise again to
end the cycle at the falling edge of T3. Since this is two clock periods, the slowest memory
that will work reliably must have an access time of at least 40 nanoseconds. Anything with an
access time of 40 nanoseconds or less will work in this application.
6a. Since the memory device has 17 address lines, it contains 128 K of addressable memory.
6b. Each memory location holds 16 bits, or 24 bits. Thus 217 memory locations 24 bits per
memory location = 221 bits, or 2M bits.
6c.
Page
0
1
7
Starting Address
00000
20000
E0000
13
Ending Address
1FFFF
3FFFF
FFFFF
1
2
3
4
5
6
7
8
Address Range
00000..1FFFF
20000..3FFFF
40000..5FFFF
60000..7FFFF
80000..9FFFF
A0000..BFFFF
C0000..DFFFF
E0000..FFFFF
8b. A microprocessor with a 24-bit address range and using four memory chips with a capacity of
64K each. Two of the memory chips occupy the rst 128K of the address range and two chips
occupy the top 128K of the address range.
This is a bit tougher. The address range of the processor is 000000..FFFFFF and each of the
memory chips has an address range of 0000..FFFF. The address table looks like this.
Memory chip
1
2
3
4
Address Range
000000..00FFFF
010000..01FFFF
FE0000..FEFFFF
FF0000..FFFFFF
8c. A microprocessor with a 32-bit address range and using eight memory chips with a capacity
of 1M each. (1 M= 1,048,576). Two of the memory chips occupy the rst 2M of the address
range and six chips occupy the top 6M of the address range. This gets a bit tougher still.
Memory chip
1
2
3
4
5
6
7
8
Address Range
00000000..000FFFFF
00100000..001FFFFF
FFA00000..FFAFFFFF
FFB00000..FFBFFFFF
FFC00000..FFCFFFFF
FFD00000..FFDFFFFF
FFE00000..FFEEFFFF
FFF00000..FFFFFFFF
14
1
2
3
4
5
6
7
8
Address Range
00000..1FFFF
20000..3FFFF
40000..5FFFF
60000..7FFFF
E0000..E7FFF
E8000..EFFFF
F0000..F7FFF
F8000..FFFFF
15
start
ORG
$400
move.b
move.b
move.b
move.b
move.b
move.b
$4000,D0
$4001,D1
$4002,D2
$4003,$4000
D2,$4001
D1,$4002
16
move.b
bra
end
D0,$4003
done
$400
10. The rst instruction puts the 32-bit number $FA865580 in D0. The next instruction moves it
to memory starting at address $4000 and going to address $4003, with $FA stored in $4000
and $80 stored in $4003. The next instruction is a logical shift left of a word start in at address
$4002. Thus, we are going to do a shift left of $5580, with each bit going to the next higher
bit position, with zero shifting into the LSB and the MSB going into the carry bit. Therefore
$5580 becomes $AB00. Moving the longword into D1 gives us. <D1> = $FA86AB00.
17
LEA
ZERO,A0
* Not OK
MOVEM.L (SP)+,D0-D7/A1-A6 * Restore the registers
RTS
* Go back
The probability of the checksum not detecting an error is 1 part in 216, or 1/65,536.
4.
****************************************************************
*
* Subroutine : int_srch
*
* This subroutine searches a sequence of long-words in memory,
* starting at the address pointed to by A0. D2 returns the search
* results.
*
* Register usage:
*
* A0 = Pointer to search string
* D1 = Longword value to search for
* D0 = Number of elements to search for
* D2 = Returns zero or the address of the rst search match
*
* Assumptions:
* D0 contains a positive number between 1 and 65,535.
* The user knows the length of the sequence in memory. No error
* checking will be done by the program.
*
******************************************************************
int_srch
MOVEM.L
D3,-(SP)
*Save the registers I use
CLR.L
D3
*Well use D3 as a 32-bit counter
MOVE.W
D0,D3
*Load D3
loop
CMPI.L
#00,D0
*Is it zero?
BEQ
exit
*D0 is = 0, so exit
CMP.L
D1,(A0)+
*Check and advance A0
BEQ
match
*They are equal
SUBQ.L
#1,D3
*Decrement counter
BRA
loop
*Go back for next test
match
MOVE.L
A0,D2
*Transfer address
SUBQ.L
#4,D2
*Reset address
exit
MOVEM.L
(SP)+,D3
*Restore register
RTS
*Go home
6.
start
org $400
CLR.B $101F
MOVE.L
$1000,D0
MOVE.L
$1008,D1
19
no_carry
MOVE.L
MOVE.L
ADD.L
ADDX.L
BCC
ADDQ.B
MOVE.L
MOVE.L
END $400
$1004,D2
$100C,D3
D3,D2
D1,D0
no_carry
#1,$101F
D0,$1020
D2,$1024
8.
***********************************************************************
* Subroutine Send_String
* Sends a string of byte characters to a serial port
* A pointer to the data is passed in address register A0
* The data string is terminated with the null character, $FF
* The data is sent from D0 and the status is checked in D1
* The subroutine saves all registers used
**********************************************************************
* Equates for subroutine
Xmit
EQU
$4000
*Data Port for Serial I/O
Status
EQU
$4001
* Status Port for serial I/O
EOS
EQU
$FF
* End of String Character
TBE
EQU
01
* Transmitter buffer empty mask
reg_list
REG
D0/D1
* Saved registers
**********************************************************************
Send_Str
MOVEM.W
reg_list,-(SP)
*Save registers
Byte_loop MOVE.B
(A0)+,D0
*Get a byte
CMPI.B
#EOS,D0
*Is it FF?
BEQ
Exit
*If yes, exit
Xmit_loop MOVE.B
Status,D1
*Get status byte
ANDI.B
#TBE,D1
*Empty?
BEQ
Xmit_loop
*Not yet. Keep waiting
MOVE.B
D0,Xmit
*Ship it
BRA
Byte_loop
*Do it again
Exit
MOVEM.W
(SP)+,reg_list
*Get ready to leave
RTS
20
Initialize
Do third test
Do first test
Complement
Pattern 2
Complement
Pattern 1
NO
Done
Shifting?
Do fourth test
YES
Quit
Get third pattern
Do second test
Main Program
Save registers
Pattern
the
same?
Initialize
YES
Memory
filled?
NO
Increment
address pointer
Increment the
counter
NO
Memory
tested?
NO
YES
Reset pointer
Subroutine: Do Test
YES
Restore registers
and return
21
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
$AAAA
$FFFF
$0001
$00001000
$0003FFFF
$000A0000
2
1
1
$2700
$500
$400
*
*
*
*
*
*
*
*
*
*
*
*
* Main Program
shift1
OPT
ORG
CRE
start
LEA
LEA
LEA
LEA
LEA
CLR.B
MOVE.W
JSR
NOT.W
JSR
MOVE.W
JSR
NOT.W
MOVE.W
JSR
ROL.W
BCC
MOVE.W
NOT.W
stack,SP
test_patt,A3
bad_cnt,A4
bad_addr,A5
data_read,A6
bad_cnt
(A3)+,D0
do_test
D0
do_test
(A3)+,D0
do_test
D0
(A3),D0
do_test
#bit,D0
shift1
-(A3),D0
D0
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
22
done
JSR
ROL.W
BCS
STOP
do_test
#bit,D0
shift2
#exit_pgm
*
*
*
*
************************************************************************
*
* Subroutine: do_test
*
* Performs the actual memory test. Fills
* the memory with the test pattern of interest.
* Registers used: D1,A0,A1,A2
* Return values: None
* Registers saved: None
* Input parameters:
* D0.W = test pattern
* A4.L = Points to memory location to save the count of bad addresses
* A5.L = Points to memory location to save the last bad address found
* A6.L = Points to memory location to save the data_read back and data
* written
*
* Assumptions: Saves all registers used internally
************************************************************************
do_test
MOVEM.L
LEA
LEA
MOVE.L
ll_loop MOVE.W
CMPA.L
BLE
MOVE.L
test_loop MOVE.W
CMP.W
BEQ
not_ok
MOVE.L
ADDQ.W
MOVE.W
MOVE.W
SUBQ.L
addr_ok
ADDQ.L
CMPA.L
BLE
MOVEM.L
A0-A2/D1,-(SP)
st_addr,A0
end_addr,A1
A0,A2
D0,(A2)+
A1,A2
ll_loop
A0,A2
(A2),D1
D0,D1
addr_ok
A0,(A5)
#byte,(A4)
D1,(A6)+
D0,(A6)
#word,A6
#word,A2
A1,A2
test_loop
(SP)+,D1/A0-A2
*
*
*
*
*
*
Save registers
A0 points to start address
A1 points to last address
Fill A2 will point to memory
Fill and increment pointer
Are we done?
*
*
*
*
*
*
*
*
*
*
*
*
*
Reset pointer
Read value back from memory
Are they the same?
OK, check next location
Save the address of the bad location
Increment the counter
Save the data read back
Save the data written
Restore A6 as a pointer
A2 points to next memory location
Have we hit the last address yet?
No, keep testing
Restore registers
23
test_patt
bad_cnt
bad_addr
data_read
data_wrt
ORG
DC.W
DS.W
DS.L
DS.W
DS.W
END
* Go back
1
1
1
1
data
pattern1,pattern2,pattern3
* Keep track
* Store last
* What did I
* What did I
start
If you examine the code youll see that there are no magic numbers. All numeric values used
as operands are given symbolic names with the EQUates so that each instruction is as readable
as possible.
24
(A6),D0
#shift,D1
D1,D0
fetch the next instruction from memory, and shift the bits 12 positions to the right, shifting in
zeros to the leftmost bit positions. Thus, the contents of D0 will be a number between 0 and $F.
The instruction:
MULU
#6,D0
*Form offset
creates an indexing value that multiplies the value in D0 by 6, the length, in bytes, of each of
the jump instructions in the jump table.
Finally, the instruction,
JSR
00(A0,D0)
uses the complex addressing modes, address register indirect with index and offset, to form a
vector to the appropriate subroutine through one of the 16 possible jump instructions in the table.
25
AX,0AA55H
BL,AL
AL,AH
AH,BL
MOV
MOV
MUL
MOV
MOV
AX,[204h]
BX,[206h]
BX
[202h],DX
[200h],AX
8.
10.
MOV
MOV
MOV
MOV
MOV
MOV
MOV
loader:
MOV
ES:MOV
INC
INC
DEC
JNZ
AX,8200H
BX,0C400H
DX,AX
ES,BX
SI,0000
DI,0000H
CX,1000
AL,[SI]
[DI],AL
SI
DI
CX
loader
;Get byte
;Store byte
;Advance pointers
;Decrement counter
;Done? No,go back.
26
8. MOV
LDR
ADDS
STR
r4,#&06000000
r4,r4,#&00AA0000
r4,r4,#&00004C00
r4,r4,#&00000001
r0,#&00001000
r1,[r0]
r3,r3,r1
r3,[r0]
;Initialize pointer
;Get operand
;Do addition
;Write back
27
28
1
0.5
0
0.5
1
40
0
0
0
0
0
0
0
0
0
0
80 120 180 200 240 280 320 360 400 440
1.5
2
2.5
29
D4
#4,D4
D4,SP
D0,(SP)
D4,SP
D1,(SP)
D4,SP
D2,(SP)
D4,SP
D3,(SP)
D4,SP
D5,(SP)
D4,SP
A0,(SP)
D4,SP
A1,(SP)
D4,SP
A2,(SP)
D4,SP
30
D1,D0
#$3400,D2
(A4),A6
D0,D3
D7,A2
#$F6AA,D4
D3,D1
Actually, there are lots of possibilities. The idea is to place instructions without dependencies in
the space between the instructions with dependencies. That way, the dependent instructions can be
completed without needing to wait for the next instruction.
31
27
26
25
|
24
23 22
offset
21
32
20
|
33
35