Computer Hardware Flashcards

1
Q

How do computers represent data?

A

With bits (an instance of a state)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a bit

A

A bit represents a state (1 or 0)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a nybble (nibble, or nyble)

A

Four consecutive bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a byte?

A

Eight consecutive bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When talking about memory what is the concept of a “word”

A

Basic unit of data that a cpu can process at one time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How many possible characters in ASCII and why?

A

2^7, so 128.

This is because 2 (states 1 or 0) and ASCII characters are stored in 7 bits.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a combinatorial logic circuit?

A

Circuit whose digital output are dependent only on their digital inputs (works in binary, no memory).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

All logic gates have two inputs and one output , except for ______.

How does this logic gate behave?

A

NOT (1 input, 1 output)

Invert (E.g., if input is 1, it will invert it and output 0)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How many functions for 1 input and 1 output?

A

4
False, Indentity, True, and NOT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How many functions for 2 input and 1 output?

A

16

Because there are 4 input combinations: (00, 01, 10, 11) . For each combination there are two possible outputs, therefore 2^4 = 16.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the AND logic gate look like?

And how does this logic gate work?

A

2 inputs going into a ‘D’ shape, with one output coming off the other end of the D.

Gives true (1) if both are same.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the NAND logic gate look like?

And how does this logic gate work?

A

Same as AND but with a small circle at the end of the D.

True (1) when they are both NOT true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the OR logic gate look like?

And how does this logic gate work?

A

2 inputs going into a ‘shield’ shape, with one output coming off the other end of the D.

True (1) when either input or both are true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the EOR/XOR logic gate look like?

And how does this logic gate work?

A

Similar to or, but an arch is on the top of the shield.

You can have one or the other, but can’t have both.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What a boolean expression for both the ‘OR’ and ‘AND’ logic gates.

A

Or: Y = A + B
And: Y = A * B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Write a diagram to represent 2 input, 2 output for a circuit containing a ‘XOR’ and a ‘AND’ logic gate.

A

Combine both with both input bits going to both logic gates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a Ripple Carry Adder?

A

Each full adder takes the current bits being added, along with any carry from the previous addition stage, and produces the sum and carry output, which is then used in the next stage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a 3-bit Parity Generator

A

A 3-bit parity generator is designed to ensure that the total number of 1s in the 3-bit binary sequence is always odd, which is typically achieved by setting the parity bit to 1 or 0 to make the total count of 1s odd. This is often used for error checking and correction purposes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Write an equation so P is always true (3-bit Parity Generator)

A

P = (notA * notB * notC) + (A * B * notC) + (A * notB * C) + (notA * B * C)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do 7-segment Digital Displays work?

A

They form an 7 with lines, and bits symbolise which lines to light up.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the Boolean Operator Precedence.

(order in which Boolean operators (such as NOT, AND, and OR) are evaluated)

A

1st - NOT
2nd - AND
3rd - OR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a transistor?

And how do they work?

A

An electronic switch.
B = Base, C = Collector, E = Emitter

0v to B = Switch opens, C is disconnected from E

Apply v to B = Switch closes, C is connected to E.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is a demultiplexer?

A

A multi-way switch where the address selects which output receives the input.

E.g., 00 = Y0, 01 = Y1, 10 = Y2, 11 = Y3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a Set-Reset Latch?

Draw a table to represent S R inputs and their corresponding actions.

A

Used to set and unset latch.

S | R | Action
0 | 0 | None
0 | 1 | Q = 0
1 | 0 | Q = 1
1 | 1 | Invalid

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Can you make the Flip-Flop using only NAND gates?

A

Yes, by inverting S and R.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is a D-type Flip-Flop

A

Data Input (D): The value at the D input represents the data that you want to store in the flip-flop.

Clock Input (CLK): The clock input determines when the data at the D input is sampled and transferred to the Q output. The data is transferred on either the rising or falling edge of the clock signal, depending on the specific type of D flip-flop (positive-edge-triggered or negative-edge-triggered).

Q Output: This is the output of the flip-flop, and it reflects the value of the D input when the clock edge occurs.

Q’ Output: This is the complement of the Q output (inverted Q). If Q is high, Q’ is low, and vice versa.

USED FOR:
Data Storage
Synchronization
Sequential Logic
Edge Detection
Frequency Division
Memory Elements
Data Transfer
Control Logic
Serial-to-Parallel Conversion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What is a T-type Flip-Flop

A

A T-type flip-flop, also known as a toggle flip-flop, is a type of digital circuit used in electronics and digital logic design. It has a single input (T) and a single output (Q). The purpose of a T-type flip-flop is to change its output state based on the input signal.

Here’s how a T-type flip-flop operates:

When the input (T) is set to 0, the flip-flop retains its current state. In other words, the output doesn’t change.

When the input (T) is set to 1, the flip-flop toggles its state. If the output was 0, it changes to 1, and if it was 1, it changes to 0. This is why it’s called a “toggle” flip-flop.

T-type flip-flops are used in various applications, including counters and frequency dividers, where the toggling behavior is valuable for creating clock signals and binary counting sequences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is a JK-type Flip-Flop

A

A JK-type Flip-Flop is a digital circuit element with two inputs, J (set) and K (reset), and a clock input.

If we feed 0 0 to the inputs (Let’s say J and K) it does not change the clock.

If we feed 0 1, it resets it.

If we feed 1 0, it sets it.

If we feed 1 1, it toggles it (Gives not what Q was before)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

How can we change the JK-type Flip-Flop into a T and D flip-flop.

A

T: Set K = J
D: Set K = notJ

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

How does an Asynchronous Ripple Counter work?

What if we use a 2-bit Ripple Counter?

A

Switches between 0 and 1 each clock cycle. (Output is half the frequency of the input square wave, or clock cycle)

First will be 0, 1, 0 ,1, 0, 1 …
2-bit will be 00, 11, 00, 11…
And so on.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Show an example of Synchronous Counter bits

A

1, 0, 1, 0, 1, 0
00, 01, 10, 11, 00

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What do Sequential Circuits do?

A

Store state between each use (i.e., they have memory).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

How can you detect inputs with state transition diagrams?

Given the need to find 11011. Write a state transition diagram for this.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

What is a Tristate Buffer, and what are it’s three states?

What are the combinations are their corresponding outputs.

A

High (1), Low(0), High-Impedance(Z).
- Output is either the input (D) or high-impedance.

D | E | Y
0 | 0 | Z
0 | 1 | 0
1 | 0 | Z
1 | 1 | 1

When E is 0 (disabled), the output Y is in a high-impedance state (Z), regardless of the value of D.
When E is 1 (enabled), the output Y is equal to the value of D.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

How are buses represented?

A

With widow arrows (which represents several wires).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

What are some ‘buses’ features?

A
  • Used to communicate with parts of the computer.
  • Only one transmitter at a time.
  • Only one addressed bus can respond (tristate buffer disconnects other devices).
  • 2 levels of buses; internal to chip & external to chip.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Memory size is dependent on ____?

A

address bus ‘width’

2^n bytes for n-lines on the address bus: 2^8 = 256B
So 2^16 = 64KB
2^32 = 4GB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

How are flip flops grouped?

A

Into bytes (or larger).

Flip-flops can be grouped into various configurations based on the specific design requirements, which may or may not align with byte-sized or larger data units.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

Memory made from flip flops are called ____?

A

Static Ram:
- Used in the CPU cached RAM.
- Used anywhere a small amount of fast RAM is needed.
- SRAM is expensive.

Note: The main memory of your computer is Dynamic Ram.

40
Q

How is Dynamic Ram stored?

Explain the aspects of capacitors, that demand attention for Dynamic Ram.

A

On a capacitor as a charge
0 = No Charge
1 = Charged

Capacitors are leaky
- Need to be periodically refreshed.
- A read operation drains the capacitor.

41
Q

What’s another name for Read-Only-Memory

A

Non-Volatile Memory

42
Q

What is an ALU (Arithmatic Logic Unit)?

What components does it have?

A

Performs arithmetic operations and performs logical operations
- Addition, subtraction, etc
- AND, OR, SHIFT, etc

  • Two inputs.
  • AND logic gate
  • Add circuit
  • Load
43
Q

What does the control unit do?

A

Generates control signals:
- Connect to registers on the bus.
- Control the function of ALU.
- Provides timing signals to the system.

44
Q

What are registers?

What does it do when connected to the ALU and control unit?

A

Memory cells with names: A bunch of flip-flops storing values.

Typically holds data same size as the memory words.

Stores values, and feeds it back in.

45
Q

What are the special purpose registers and what do they do?

A

The program counter
- Stores the address of the current instruction.

The accumulator
- Source of one of the operands.
- Destination of the result.

The status flags
- Individual bits store information about results of the operations.
- Result of the last instruction was negative, zero,
or positive.
- Carry from the most recent arithmetic operation.
- Overflow occurred during the last instruction.

46
Q

What are CPU instructions?

(6809 Instruction Structure)

A

Bit patterns
Can be split into a number of fields
- Operation to be executed
- Address in memory
- Which registers (or memory cells) to use as operands
- Where to place the result (registers or memory)

Long Explanation:
‘cmpb #9’ Let’s break it down:

Operation to Be Executed: ‘cmpb’ represents the operation to be executed. ‘cmpb’ stands for “compare byte.” It’s an operation that compares the value of a byte-sized operand.

Address in Memory: The ‘#’ symbol is often used in assembly language to represent an immediate value, which means that the value 9 is the constant operand to be used in the comparison. In this context, there might not be a specific memory address involved, as the value 9 is directly provided in the instruction.

Operand: The operand is the value 9 that you want to compare.

Where to Place Result: The ‘cmpb’ instruction does not produce a result that is typically stored anywhere. It is used for comparing values. The result of the comparison is stored in status flags, such as zero flag, carry flag, or sign flag, depending on the architecture. These flags are used to make decisions in conditional branches (like jump if equal, jump if not equal, etc.) that follow the comparison.

47
Q

What are the Three Key Concepts of Von Neumann Architecture?

A
  • Data and instructions are stored in a single read-write memory.
  • Contents of memory are addressable by location, without regard to the type of data contained.
  • Execution occurs in a sequential fashion, unless explicitly altered, from one instruction to the next.
48
Q

What is machine code, coded in?

A

1’s and 0’s

49
Q

How much memory does 6809 have?

A

64KB 2^16
- Though, we only do math with 8 bit numbers, it is a 16 bit address bus.
- 64,000KB of memory broken into memory (256 pages, 2^8).

50
Q

What bits are the 6809 registers.

A

A, B = 8 bit (does math with them)
All the rest are 16bits (access memory).

51
Q

What are the 6809 registers are what are they used for?

A

Index Register (X) & (Y)
Makes accessing indexes in memory easier.

User Stack Pointer (U):
For own purposes.

System Stack Pointer (S):
Used for function calls, keeps track of processes.

Program Counter (PC):
Which instruction we are executing.

D (A and B):

52
Q

What are the 6809 Condition Codes (CC), and what do they do?

A

The Condition Codes (CC) holds information about the result of the previous operation.

N - If last math operation resulted in negative.

Z - If last math operation resulted in 0.

V - Overflow, meaning result of operation cannot be represented within the valid range for signed numbers.

C - Carry or borrow of most significant bit.

53
Q

What do instructions consist of?

Are instructions different length?

(6809 assembly)

A

(1) One or more fields:

  • The mnemonic opcode (e.g., return to subroutine).
  • And (optionally) parameters called operands (e.g., GOTO (bra more)).

(2) Yes, they often are.

54
Q

Discuss Operand Symbols

A

immediate (if no # is given then it’s an address, otherwise it is NOT an address)

$ hex value

% binary value

55
Q

List a few aspects of Assembly Languages.

A
  • Can’t declare variables (only use registers).
  • Only loop constraint is GOTO
  • Can only compare using integers and bytes.
  • Can only branch if comparison matches certain conditions.
56
Q

What location does SCREEN start with 6809

A

$0400

57
Q

How do you format creating a constant in 6809?

A

<constant(name)> EQU <value></value>

58
Q

What is an important note to remember when using registers in 6809.

A

We need to restore them:

Save at start:
- pshs <registers></registers>

Restore when done:
- puls <registers></registers>

59
Q

How can you store a string into memory? (Assembly)

A

message:
.byte “<word>", 0</word>

What does the 0 do? Our subroutine only stops when it sees the $00

60
Q

What does LEA (Load Effective Address) do?

A

Does computation to find where to get it from.

61
Q

What are CMOC 6809 calling conventions? / rules

A
  • A routine must preserve Y, U, S and DP.
  • Parameters are pushed on the stack in reverse order.
  • Caller must pop them off the stack after the call.
  • Chars -> int
  • Unsigned char -> unsigned int
  • Return 8 bit value in B.
  • Return 16 bit values in D.
62
Q

What are some key notes with C routines?

A

A routine can be scoped to it’s current file
- static

Routines must be declared before use (.h file)
- extern int eleven(void)

63
Q

What word is used to represent constants

A

const

64
Q

Enums, what are they?

A

Hold constant values, which can only be integer

65
Q

What is different about C variables to Java?

A

C does not initialise variables

66
Q

What does typedef do in C?

A

Struct example{}
- struct example G

typedef Struct example{}
- example G

67
Q

What does static mean in C

A
  • Scope of routine local to this source code file.
  • This variable maintains its value between calls.
68
Q

What does volatile do in C?

A

Do NOT optimise access to this variable.

69
Q

What is * known as
What is ** known as

A

Dereferencing
Double-dereferencing

70
Q

How do you find the index of a variable, for example ‘b’

A

int *b_pointer = &b;

We use a pointer variable as addresses might be bigger or smaller than an integer.

To retrieve a value from a pointer just dereference it, for example., int b = *b_pointer

71
Q

Why use pointers in C?

A
  • Abstraction
  • Ability to change parameter
  • Multiple return values in routine
72
Q

What is call by value?

A

We pass the value of variable, which means routine has a copy. Therefore, changes do not propagate back.

Example foo(v)

73
Q

What is call by address?

A

We pass the address of parameter, meaning changes propagate back.

Example foo(&v)

74
Q

What is call by address abstraction?

A

Manipulates objects without knowing which object in advance.

75
Q

What is call by address swap?

A

A method can change the value of a thing being pointed to, without knowing what they are.

76
Q

What is call by address efficiency?

A

Passing the address of start of array:
foo(&array[0])

77
Q

Explain aspects/features of Pointer Arithmatic (Moving, incrementing, and decrementing)

A

(Aspect 1)
long *me
me++

++ increments the address by sizeof(*me) bytes

(Aspect 2)
Units are counted in elements being pointed to
E.g., int will increase by size(int)

(Aspect 3)
Cannot do arithmetic outside of one allocated block, but can compute (but not address)
- Explanation: It’s essential to understand that this computation doesn’t involve addressing new, unallocated memory. You’re working within the bounds of the memory block that has been reserved for the pointer.

78
Q

How do you find the size of an Array in C?

A
  • Keep track yourself, or put a sentinel value at the end and count to it. (Often ‘\0’
79
Q

How do we pass arrays in C?

A

We do NOT pass by value, instead we pass a pointer to the first object in the array.

80
Q

Quoted strings or “string literals” are allowed or not allowed to be changed?

Where can these be used?

A

Not allowed.

Can be used anywhere an array can be used.

81
Q

uint8_t integer_array[2];
uint16_t integer_array[2];

How many bytes of memory do these allocate?

A
  • 2 Bytes
  • 4 Bytes (16 bit, so 2 bytes instead of 1) and
82
Q

What if we don’t know how big an array needs to be?

A

We can use malloc().

For example:
uint8_t *space = malloc(16 * sizeof(uint_8);

83
Q

We want to allocate space to store 16 unsigned 64-bit integers

A

uint64_t *block = malloc(sizeof(uint64_t) * 16)

84
Q

What are some rules about free’ing memory?

A

When you have finished using an allocated block you must free this block.

  • Never free memory you didn’t allocate.
  • Never free the same memory twice.
  • You MUST call free before you lose the pointer to the block of memory.
85
Q

List aspects of Structs in C

A
  • Everything is public
  • Class, without methods, no constructers, no default values
86
Q

What is shallow copy, and what C aspects use it?

A

Shallow copy, ultimately copies the pointer to the thing, but not the thing itself. Therefore, a shallow copied string, will point to the same place in memory.

Struct assignment is by shallow copy:
E.g., first = second

Second points to the same location as first, but doesn’t copy the value.

87
Q

How is struct assignment done?

How is passing a struct to routines done?

How is passing a struct to routines, so that the initial value changes the passed value.

A
  • By shallow copy
  • By value
  • By address
88
Q

What do queue items hold?

A

A value and a pointer

89
Q

How are structs stored

A

In memory together, with a name for each variable, and an ‘overall’ name for all the values.

90
Q

What does a union allow in C?

Why is this important?

A

Union gives us multiple views of the same memory

See if the most significant or least significant digit is stored first.

91
Q

What does the compiler, assembler and loader do?

A

Compiler
- Converts a high level language description of a program into an assembly code description

Assembler
- Converts assembly language into machine code

Loader
- Loads program into memory

92
Q

How do you declare a pointer to a routine?

How to assign pointer to routine?

How to call the routine

A

int (*method)(int param);
- Takes param int and returns int

method = square;

result = method(6);

93
Q

Where can pointers to routines be used?

A

Anywhere a variable can be used.

94
Q

What benefits do modules provide?

A
  • Abstraction
  • Our queue (for example) could have a print method, but so could others. We can call “ob -> print()” without needing to know (exactly) which print method is called.
95
Q

What does a constructer do for ADT structs?

A

Creates the object, initialises it, and sets up the function pointers.

96
Q

What does RAII state?

Hint (C language)

A

“a resource is a class invariant, and is tied to the object lifetime”

Meaning, you should ONLY allocate in the constructer and deallocate only in destructor
- Allocation might be malloc(), opening a file, etc
- Deallocation might be free(), closing a file, etc.

97
Q

Where should structs be declared?

A

A class(struct) declaration in C should be in .h