ALU Design

Thread Starter

cagan78

Joined Jun 13, 2021
4
ALU has to be designed according to table, and I've designed multiplexers and they are working properly. I need help to design ALU in verilog.
1.JPG
resim_2021-06-13_175401.png
 

Papabravo

Joined Feb 24, 2006
16,825
I would start by making a table that shows alu_opcode, alu_operation, and alu_result. something like

alu_opcode alu_operation alu_A alu_B alu_result
001 select B xxxx 1111 1111
010 ADD R[xx] 0001 R[xx]+1
011 SUB R[xx] 0001 R[xx]-1
100 Select B R[xx] dddd dddd
101 Select A dddd R[xx] dddd
110 ADD R[xx] R[yy] R[xx]+R[yy]
111 Select B R[xx] R[yy] R[yy]

Sorry, that didn't render very well
 

Thread Starter

cagan78

Joined Jun 13, 2021
4
I would start by making a table that shows alu_opcode, alu_operation, and alu_result. something like

alu_opcode alu_operation alu_A alu_B alu_result
001 select B xxxx 1111 1111
010 ADD R[xx] 0001 R[xx]+1
011 SUB R[xx] 0001 R[xx]-1
100 Select B R[xx] dddd dddd
101 Select A dddd R[xx] dddd
110 ADD R[xx] R[yy] R[xx]+R[yy]
111 Select B R[xx] R[yy] R[yy]

Sorry, that didn't render very well
it doesn't help, I cannot figure it out how to design and I'm very confused.
 

MrAl

Joined Jun 17, 2014
8,479
it doesn't help, I cannot figure it out how to design and I'm very confused.
What are you confused about exactly?

Wow this takes me back to the 1970's when i worked for a company and we had to design our own ALU because microprocessors where not that common yet. It was a full size PC board maybe 6 x 8 inches or something like that. It was part of the CPU design, all with TTL logic.
 

Papabravo

Joined Feb 24, 2006
16,825
it doesn't help, I cannot figure it out how to design and I'm very confused.
I don't understand what you are confused about. An ALU is a combinatorial logic circuit, that means no memory elements or clock signals, Tt has a fixed number of inputs, 4 bits on side A, 4 bits on side B, and 3 opcode bits. It has 4 output bits. So you look at the three opcode bits and you create a path way for the desired result to show up at the output. You could do all 8 operations in parallel and send the 8 results to an 8:1 multiplexer. That would work. There is not a unique solution, and this is where creativity comes in.
 

Papabravo

Joined Feb 24, 2006
16,825
What are you confused about exactly?

Wow this takes me back to the 1970's when i worked for a company and we had to design our own ALU because microprocessors where not that common yet. It was a full size PC board maybe 6 x 8 inches or something like that. It was part of the CPU design, all with TTL logic.
Ours involved a pair of 74181 units. It resulted in a kind of weird instruction set.
 

Papabravo

Joined Feb 24, 2006
16,825
It helps to know things like how you can use an adder to do subtraction by taking the 1's complement of one operand adding it to the other operant and incrementing the result. It also helps to know that there is more than one way of incrementing a number. One was is to add a constant '1' to the number, but another way is to add the '0' to the number AND set the Carry In to a 1. In many cases a zero is an easier constant to create than one.

Without this kind of knowledge designing an ALU is going to be significantly more challenging. To get some perspective, imagine doing a serial input, serial output 1-bit wide ALU.
 

Thread Starter

cagan78

Joined Jun 13, 2021
4
Sounds like you found somebody to do it for you., or at least how they would do it.
Pardon? All verilog codes and circuitry design are belonged to me on this work. If you would like to understand how to solve it, i will be glad to show you how it is done. In this kind of tasks, it needs more than writing the table in words
 

Papabravo

Joined Feb 24, 2006
16,825
Pardon? All verilog codes and circuitry design are belonged to me on this work. If you would like to understand how to solve it, i will be glad to show you how it is done. In this kind of tasks, it needs more than writing the table in words
Well you never did explain what the actual problem was, I had no idea that your problem was how to express the solution in Verilog. I knew Verilog was the final step, but I thought you were having difficulty in visualizing what was going on inside the ALU. Mea culpa, and I don't need you to show me anything, thanks all the same.
 
Last edited:

MrAl

Joined Jun 17, 2014
8,479
Ours involved a pair of 74181 units. It resulted in a kind of weird instruction set.
Yeah and ours was limited to less than 100 types of instructions but i cant remember the actual number now.
I really liked the fact that we could create any instruction we wanted to though that made it really flexible. Imagine if modern CPU's could somehow allow for low level instruction programming maybe via electrical programming similar to EEPROM's or something like that. Those instructions would be super fast.
That reminds me we used to use UV EPROMS back then (ha ha) and had to program every single code with s set of 8 switches and a pushbutton to write to the EPROM with that one single byte, then go to the next byte. That took hours to program just one EPROM.
 

Papabravo

Joined Feb 24, 2006
16,825
Yeah and ours was limited to less than 100 types of instructions but i cant remember the actual number now.
I really liked the fact that we could create any instruction we wanted to though that made it really flexible. Imagine if modern CPU's could somehow allow for low level instruction programming maybe via electrical programming similar to EEPROM's or something like that. Those instructions would be super fast.
That reminds me we used to use UV EPROMS back then (ha ha) and had to program every single code with s set of 8 switches and a pushbutton to write to the EPROM with that one single byte, then go to the next byte. That took hours to program just one EPROM.
We used wire wound ROM before there were semiconductor ROMs available. We also had technicians who could patch them. Couldn't do that with the mask programmed variety.
 

MrAl

Joined Jun 17, 2014
8,479
We used wire wound ROM before there were semiconductor ROMs available. We also had technicians who could patch them. Couldn't do that with the mask programmed variety.
You mean the old magnetic core memories?
I had one of those it was on a big PC board about 10 by 12 inches or something. It was able to store something like 500 bytes (ha ha ha) of non volatile memory. There were something like 4000 little tiny toroids on that board and each one had three very thin wires maybe #32 running through them, if i rem right two for for x and y and the third was the sense wire. The PC board was part of a very complex electronic cash register. Long term data was stored on a tape drive the size of a decent size suit case. When i worked for that company i had to call those tape drives up that were around the country and extract the data and analyze it. A main fram computer was used to call them using punched cards to program it with. Wow have things changed or what. That was early 1970's.
 

Papabravo

Joined Feb 24, 2006
16,825
You mean the old magnetic core memories?
I had one of those it was on a big PC board about 10 by 12 inches or something. It was able to store something like 500 bytes (ha ha ha) of non volatile memory. There were something like 4000 little tiny toroids on that board and each one had three very thin wires maybe #32 running through them, if i rem right two for for x and y and the third was the sense wire. The PC board was part of a very complex electronic cash register. Long term data was stored on a tape drive the size of a decent size suit case. When i worked for that company i had to call those tape drives up that were around the country and extract the data and analyze it. A main fram computer was used to call them using punched cards to program it with. Wow have things changed or what. That was early 1970's.
They were actually E-cores and each E-core had multiple wires going through it. There were 2 boards, the small one had 8K bits and the large one had 32K bits. A patch involved not only the bytes you wanted to change, but all the other bytes on the wire you needed to change. Generating the patch instructions for the line technicians was a bit of a challenge. They wouldn't bother removing any of the wires, they just clipped the ends and left them there as inert pieces of enamel copper.
 
Top