alu

how to set auxiliary flag for 16bits binary addition

陌路散爱 提交于 2019-12-11 13:59:45
问题 I know that when performing an 8-bit binary addition, the auxiliary flag is set to 1 if there is a carry from 3rd bit to 4th bit; but what about the addition of 2 16-bit numbers? i can't see any clear answer on the web. I'm studying intel 8086 microprocessor... For example, when i add these 2 numbers, 0x30a2 and 0xf1ac 0011 0000 1010 0010 + 1111 0001 1010 1100 CF=1 ZF=0 PF=1 SF=0 OF=1 AF=? I'm not sure where to check it 回答1: From "Programming the 8086/8088" by James W. Coffron: AF auxiliary

Memory Hierarchy - Why are registers expensive?

本秂侑毒 提交于 2019-12-10 18:37:34
问题 I understand that: Faster access time > More expensive Slower access time > Less expensive I also understand that registers are the top of the hierarchy, and have the fastest access time. What I am having a hard time researching is why it's so expensive? To my knowledge, registers are literally circuits built directly into the ALU. If they're literally built into the CPU (the ALU especially), what actually makes it the most expensive? Is it the size (registers being the smallest, of course)?

How does the arithmetic logic unit actually works? [closed]

牧云@^-^@ 提交于 2019-12-10 13:46:58
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . In other words, how can energy combined with metal perform logic operations? In the research I've done i'ts always assumed how the 'magic' happens but usually there's a lack of explanation on how can a physical device can 'understand' and perform processes of logical nature. I think would be a good approach to

Making a 4-bit ALU from several 1-bit ALUs

こ雲淡風輕ζ 提交于 2019-12-02 17:46:09
问题 I'm trying to combine several 1 bit ALUs into a 4 bit ALU. I am confused about how to actually do this in VHDL. Here is the code for the 1bit ALU that I am using: component alu1 -- define the 1 bit alu component port(a, b: std_logic_vector(1 downto 0); m: in std_logic_vector(1 downto 0); result: out std_logic_vector(1 downto 0)); end alu1; architecture behv1 of alu1 is begin process(a, b, m) begin case m is when "00" => result <= a + b; when "01" => result <= a + (not b) + 1; when "10" =>

Making a 4-bit ALU from several 1-bit ALUs

巧了我就是萌 提交于 2019-12-02 07:54:46
I'm trying to combine several 1 bit ALUs into a 4 bit ALU. I am confused about how to actually do this in VHDL. Here is the code for the 1bit ALU that I am using: component alu1 -- define the 1 bit alu component port(a, b: std_logic_vector(1 downto 0); m: in std_logic_vector(1 downto 0); result: out std_logic_vector(1 downto 0)); end alu1; architecture behv1 of alu1 is begin process(a, b, m) begin case m is when "00" => result <= a + b; when "01" => result <= a + (not b) + 1; when "10" => result <= a and b; when "11" => result <= a or b; end case end process end behv1 I am assuming I define

Making a 16-bit ALU using 1-bit ALUs

谁都会走 提交于 2019-12-01 11:03:08
Hello I am trying to create a 16-bit ALU from several 1-bit ALUs I created a package named basic_alu1 which contains a component of the 1-bit ALU.The code for this is: library ieee; use ieee.std_logic_1164.all; package basic_alu1 is component alu1 port (a, b: std_logic_vector(1 downto 0); m: in std_logic_vector(1 downto 0); result: out std_logic_vector(1 downto 0)); end component; end package basic_alu1; library ieee; use ieee.std_logic_1164.all; entity alu1 is port (a, b: std_logic_vector(1 downto 0); m: in std_logic_vector(1 downto 0); result: out std_logic_vector(1 downto 0)); end alu1;

Making a 16-bit ALU using 1-bit ALUs

最后都变了- 提交于 2019-12-01 07:40:25
问题 Hello I am trying to create a 16-bit ALU from several 1-bit ALUs I created a package named basic_alu1 which contains a component of the 1-bit ALU.The code for this is: library ieee; use ieee.std_logic_1164.all; package basic_alu1 is component alu1 port (a, b: std_logic_vector(1 downto 0); m: in std_logic_vector(1 downto 0); result: out std_logic_vector(1 downto 0)); end component; end package basic_alu1; library ieee; use ieee.std_logic_1164.all; entity alu1 is port (a, b: std_logic_vector(1

How are shifts implemented on the hardware level?

耗尽温柔 提交于 2019-12-01 02:56:48
How are bit shifts implemented at the hardware level when the number to shift by is unknown? I can't imagine that there would be a separate circuit for each number you can shift by (that would 64 shift circuits on a 64-bit machine), nor can I imagine that it would be a loop of shifts by one (that would take up to 64 shift cycles on a 64-bit machine). Is it some sort of compromise between the two or is there some clever trick? The circuit is called a " barrel shifter " - it's a load of multiplexers basically. It has a layer per address-bit-of-shift-required, so an 8-bit barrel shifter needs

How are shifts implemented on the hardware level?

我与影子孤独终老i 提交于 2019-11-30 22:48:01
问题 How are bit shifts implemented at the hardware level when the number to shift by is unknown? I can't imagine that there would be a separate circuit for each number you can shift by (that would 64 shift circuits on a 64-bit machine), nor can I imagine that it would be a loop of shifts by one (that would take up to 64 shift cycles on a 64-bit machine). Is it some sort of compromise between the two or is there some clever trick? 回答1: The circuit is called a "barrel shifter" - it's a load of

How does the CPU do subtraction?

折月煮酒 提交于 2019-11-26 20:29:01
问题 I have some basic doubts, but every time I sit to try my hands at interview questions, these questions and my doubts pop up. Say A = 5, B = -2. Assuming that A and B are 4-bytes, how does the CPU do the A + B addition? I understand that A will have sign bit (MSB) as 0 to signify a positive value and B will have sign bit as 1 to signify a negative integer. Now when in C++ program, I want to print A + B , does the addition module of the ALU (Arithmetic Logic Unit) first check for sign bit and