Designing A CPU

Lynx516

Senior member
Apr 20, 2003
272
0
0
OK peeps I decided to learn as much as I can about CPUs and I have decided that the only way I can learn more is to actually design one. I have managed to wangle access to a VHDL simulator proggy and Have defined my ISA. It will be an 8 bit CPU 16 instructions. The only thing I am having trouble wiht is how to get the data from the registers to do the required opperations such as Add and subtract. At the moment I am thinking of having a dedicated unit to do this at the same time as the Decoder is doing it job. How have other people done this?
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
I use Verilog instead of VHDL, but for this post, it should be the same. I created a register file which has two outputs and one input. The outputs are just muxes to select the registers you want, and the input is a decoder. that writes to the register you are storing to. Then, you hook up the output muxes and input decoder to your datapath wherever you want the register contents to be (e.g. input to your ALU, output from your ALU).
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Agreed... I looked at some example code and it is UGLY. My profs all hate it.
 

AbsolutDealage

Platinum Member
Dec 20, 2002
2,675
0
0
Originally posted by: CTho9305
Agreed... I looked at some example code and it is UGLY. My profs all hate it.

Well then your profs are ignoring a massive chunk of modern design. What would you rather do? Full custom layouts? No thanks. I'll take my "UGLY" code any day.

One of the only ways a project like this can be handled by a single person in any reasonable amount of time is VHDL. The code might be ugly, but no uglier than plenty of other languages out there... and VHDL is actually very powerful once you get the hang of it.

When we did this project in school we did VHDL synthesized down to gates (using Leonardo) and then brought down to transistors using the Mentor tools along with auto place & route. It was virtually all automated (minus the few routing glitches), and at the end of it all we had a chip which we sent out to a fab. All we really had to do was write the code and wire up a few pins. Personally, I don't think there would be an easier way to do this project. You tell me another way you can go from concept to fabrication in under a semester, and I'll take my hat off to you.
 

Lynx516

Senior member
Apr 20, 2003
272
0
0
VHDL IMHO is for me better than Verilog. I have done programming in the past and VHDL is realy quite similar in structure to C++. I have picked it up fairly easily and I personally think it is better for the job I want to do
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Synopsis tools synthesize Verilog to the gate level. Sure, Verilog allows constructs that are not synthesizable, but if you're aiming for a synthesizable design, you don't use those features.

Some of the higher level classes do transistor-level stuff, but full-custom as far as I know.
 

Burner

Member
Oct 25, 1999
85
0
0
I've never had a problem synthesizing verilog to gatelevel or fpga level. As long as you write proper code you shouldn't have to do very much except size up a few gates to get it to run faster.
Generally the private sector uses verilog and the government projects use VHDL.
My first processor was mips r3000. 5 pipeline states, and other stuff that I don't exactly remember. I did that in verilog and it synthesized just fine. Took about a month.
Second processor was mips r10000 in four weeks. We did everything except with a limited instruction set (including caches). It did all the instruction reordering stuff. It was at a slightly higher level in systemC but it was still synthesizeable.
Third processor was 4 processor multiprocessor on a chip. It acted like one processor and would make speculative guesses on where it could do loop unrolling to the other 3 processors. Then it would do checks to make sure it was valid. This processor was really cool and did everything like it was supposed to. We wrote it in a language I don't think I can talk about. The language was awful though and we ended up spending more time getting the designers to fix compiler bugs then actually writing code. This one took about two months.

If you want to just learn processor design you really should consider systemC its probably easier to learn, and you can design things more from an architecture standpoint rather then a hardware standpoint. I don't think the compiler produces very good gate level code though.
 

Lynx516

Senior member
Apr 20, 2003
272
0
0
Sounds very interesting Burner. Any chance there are any free SystemC compilers/simulators? Found one and I am sure I have Visual C++ lying aroudn here somewhere. Do manjor companies use this software as I am very interested in going into microporcessor design.

edit: LOL just looked at the Steering group and it contains ARM and I am going there in a few weeks for work experience
 

Burner

Member
Oct 25, 1999
85
0
0
Here is their website: http://www.systemc.org/
I'm not sure if its free I haven't really investigated using it. I really hate system C as a language for synthesis but it is good for high level architectural modelings. I think some major companies do use it, most likely for architecture.
Basically its like learning software languages once you learn one you should pretty much be able to use any with just syntax differences.
Right now I think that most companies write their code in a company proprietary langauge. It is usually something that is a perl wrapper around anther language. I can't give you any points to one, but if you find one it is usually much easier to use. An example would be something like:

The perl basically wires everything up for you and makes dependency lists. This takes out all the annoying work out of using something like verilog.
 

acx

Senior member
Jan 26, 2001
364
0
71
If you don't have it already, I suggest getting a copy of: Computer Organization & Design - The Hardware/Software Interface (2nd Edition) (Patterson and Hennessy)
It goes into great detail on breaking down a MIPS R4000 processor into components and explaining what each part does. I found it very useful in my computer architecture studies.
 

borealiss

Senior member
Jun 23, 2000
913
0
0
xilinx might be worth a look. it's good software for learning, but quite buggy. sometimes loses your references. but it's pretty powerful, maybe you can get a copy through a school for pretty cheap. they usually sell student copies, or borrow it from a friend. if you're more interested in how gates work, check out Ledit too.