Hot answers tagged

39

This possibly answers the title of the question, if not the body: Floating point addition requires aligning the two mantissa's before adding them (depending on the difference between the two exponents), potentially requiring a large variable amount of shift before the adder. Then renormalizing the result of the mantissa addition might be needed, ...


31

Typically high resolution sin(x) functions would be implemented with a CORDIC (COrdiate Rotation DIgital Computer) algorithm, which can be accomplished with a small number of iterations using only shifts and add/subtract and a small lookup table. The original paper The CORDIC Computing Technique by Jack Volder is from 1959. It also works nicely when ...


24

In FP multiplication, exponent processing turns out to be simple addition (for exactly the same reason that multiplication in the log domain is merely addition). You have come across logarithms, I hope. Now consider how difficult it is to add two numbers in logarithmic form... Floating point inhabits a grey area between the linear and log domains, with ...


24

Ah, you're missing the STATE MACHINE concept. That's where we can "write code" made out of TTL hardware chips: data-selectors, 4-bit counters, gangs of parallel flipflops. (But all those are the complicated parts, while the idea behind "state machines" is fairly simple.) "State-machine" is also commonly called "micro-code." Also called "bit-slice" or "...


22

TL:DR: because Intel thought SSE/AVX FP add latency was more important than throughput, they chose not to run it on the FMA units in Haswell/Broadwell. Haswell runs (SIMD) FP multiply on the same execution units as FMA (Fused Multiply-Add), of which it has two because some FP-intensive code can use mostly FMAs to do 2 FLOPs per instruction. Same 5 cycle ...


16

As @duskwuff suspected, I've looked into this. To answer the question, the 8085 has two extra registers in the ALU. The 8085 has several "hidden" registers: a 16-bit WZ pair and two 8-bit ALU helper registers: ACT and TMP. WZ is part of the register file, while ACT, A (accumulator) and TMP are located in the ALU circuitry itself. Here's a diagram of how ...


14

Most computer trig libraries are based on polynomial approximations, which gives the best balance between speed an accuracy. For example, a dozen or so multiplication and add/subtract operations is enough to give full single-precision accuracy for sine and cosine.


13

Yes, when written as multiplication in normal math, it means AND in Boolean logic. This does make some sense when you think about it. Make a truth table of multiplying two value that can be either 0 or 1. The result is 0 except when both are 1, then the result is 1. That's exactly what AND does. This logic doesn't really follow for "+", unless you ...


10

I'm going to look at this part: "Why is it that they would allow"... TL;DR - because they designed it that way. It is a management decision. Sure there are answers of mantissa and bit shifters, but these are things that go into the management decision. Why did they design it that way? The answer is that the specs are made to meet certain goals. Those ...


8

You can manipulate arbitrarily wide numbers using a finite width ALU. However, multiple operations are required when the number is wider than the ALU. To illustrate this, I'll use a PIC 18 as example. This architecture can manipulate only 8 bit numbers directly. To add the 8 bit quantities VAR1 and VAR2 and put the result into SUM would take code like ...


8

In an unsigned binary representation, only positive numbers can be represented, and the weight of each bit including the most significant bit is a power of two. So with a word size of 8 (byte), 00000000 => 0 01111111 => 127 10000000 => 128 11111111 => 255 Two's-complement, which is used for signed binary notation, encodes both positive and ...


8

A processor is really a finite state machine (FSM) for implementing the machine code instructions. It reads the instructions from memory and uses the required hardware, such as the ALU, to implement them. Here is the data path of the MIPS architecture. source You have a control unit implementing said FSM and is responsible for ensuring the data is ...


8

The simplest thing is to just add the input number to itself. Doubling a number (multiplication by 2) is equivalent to a left shift in binary. In other words, select ADD as the ALU operation, and feed the input value to both inputs of the ALU. If you do add-with-carry, then the carry bit will automatically get shifted into the LSB. In either case, the carry-...


7

As with many texts written for beginners the situation has been somewhat simplified. The assumption is that a 32-bit processor does all address operations and calculations also in 32 bits. From that it assumes a 32-bit address bus. Therefore the maximum address range is 4GBytes. That same reasoning is then extended to a 64-bit processor. In real life it ...


7

This diagram from Intel may help: It appears they've given each unit a FMA (fused multiply-add) as well as a multiply and a single adder. They may or may not share hardware underneath. The question of why is a lot harder to answer without internal design rationales, but the text in the purple box gives us a hint with "doubles peak FLOPs": the processor ...


7

There’s nothing special about computers in this context. An infinite number of nonrepeating decimal places cannot be stored or manipulated on a computer, on paper, or in a human brain. Irrational numbers can be represented in a few different ways: A symbol that names the number, such as e or π. A computer can use symbolic computation to work with such ...


6

In 2's complement the MSb is defined as -(2n) where n is the bit position of the MSb. Due to how numbers work, all bits other than the MSb add up to (2n)-1. Adding those together results in -1.


6

The basic idea is that the adder after the abext cells can do the heavy lifting needed for the first few operations, with some simple transformations of the inputs. Some options (not sure if these are all optimal): A + B → ia = A, ib = B, cin = 0 A - B → hint: do you know how to convert B to 2's complement? A + 1 → ia = A, ib = 0, cin = 1 A → ia = A, ib = ...


6

The instruction actually ends at the end of T2 of the M1 cycle that reads the next instruction, as explained at z80.info So, an instruction such as: SUB r can be broken down like this: M1 / T1 M1 / T2 : read opcode M1 / T3 : opcode is decoded as SUB r. A is loaded into op1 latch M1 / T4 : r is loaded into op2 latch ------------ M1 / T1 : low nibble of ...


6

Formal verification is state-point mapping done to ensure a schematic matches verilog or RTL model of the module. This means that for every set of inputs and states defined in the RTL model, the design is checked against the schematic to ensure that for those same inputs and states, the outputs are the same. It is a bit more cumbersome than other ...


6

You're making a couple of assumptions: Multiple outputs can be connected directly together When any such output is "high", then the wire is "high". This is known as "wired-OR", and indeed, such circuits can be constructed. They rely on special features of the circuits of the previous outputs to create the logic function you're looking for. However, a ...


6

Option 1 is how I've seen it and how I've designed it for integer inversion. The "add 1" takes one cycle and the bit inversion is absorbed in the same cycle. For subtraction, the same adder with inverter is used, and the "add 1" is applied through the carry-in for the LSB, and so it costs no extra cycles. From https://cs.wellesley.edu/~...


5

I don't know what logic the 6502 uses exactly, but many micros have a decimal adjust instruction that depends on having carry and nibble carry flags available. It is applied after a binary 8-bit addition. The logic works like this: If there's a nibble carry or if the LSD is > 9, add 0x06 ('or' the carry flag previous with new) If there's a carry or if ...


5

If you want immediate results from your ALU, then don't use a clocked process at all: module alu ( input [7:0] a, input [7:0] b, input [3:0] opcode, output reg [7:0] y ); /* Decode the instruction */ always @* begin case (opcode) 4'h00 /* OR */: y <= a | b; 4'h01 /* AND */: y <= a & b; 4'h02 /* NOTA */: y &...


5

In computers, arithmetic operations are performed by a specific integrated circuit that is placed inside the microprocessor, and is called "Arithmetic Logic Unit". You can have a look at the Wikipedia article on ALU ( https://en.wikipedia.org/wiki/Arithmetic_logic_unit ). As an example it mentions the 74181 ALU, which is a very simple Arithmetic logic unit, ...


5

The bottom line is that a lookup table is made up of logic gates, and it always takes fewer gates to implement the kinds of ALU operations you're talking about directly rather than use a lookup table. So, no matter how much technology advances, it never makes sense to use lookup tables over direct logic using the same technology. FPGAs are a special case ...


5

In synchronous designs it is an important task of designer to ensure such things do not happen. Register, which is having data being "clocked" into, is having specific dynamic properties like clock raise time, clock hold time, data stable prior and after clock signal change. If timing is violated, resulting state is not guaranteed. In your particular case ...


5

The accumulator is the ALU's output register. The 8085 has a two phase clock. Where single clock instruction like a NOP took 2 clock cycles. Similar to the 8088 used in the original IBM PC, the 8088 had a 4Mhz four phase clock and executed instruction at a rate of 1Mhz. With the two phase clock you have two oscillator cycles for each instruction cycle. ...


5

Generally, the business requirements for processor designs are directed to meet either synthetic benchmarks or real-world application workloads. Features that don't address either of those are harder to sell, and therefore more likely to be left out. During the 80s, the Dhrystone benchmark was very popular. Usually this would be presented in a high-level ...


Only top voted, non community-wiki answers of a minimum length are eligible