Close

Program Counter

A project log for World's first 32bit Homebrew CPU

Creating the world's first 32bit homebrew CPU using 74' series logic.

phil-wrightPhil Wright 03/14/2017 at 22:183 Comments

The program counter module is split between two different boards because there are too many IC's to fit on a single 100mm x 80mm sized board. The top board provides storage by using 4 x 74HC574 IC's that each store 8 bits. Every clock cycle the storage is updated with the incoming 32-bit address. Because our CPU design is single cycle the PC needs updating every cycle. Hence there is no need for a control line that determines if the PC needs updating during the next tick.

The current value is constantly output to a long header that is connected to the bottom board. This uses 8 x 74HC283 IC's to perform an add of the constant value 4. Because we are implementing the RV32E specification we know it does not need to support the condensed instructions, therefore all instructions are aligned on a 4-byte boundary. Moving to the next instruction always involves adding 4 to the current value. The CPU design will include multiplexors that determine how the input is provided to the PC. It could be the result of adding 4 but it could be the result of a conditional branch or the destination of a jump.

Discussions

Yann Guidon / YGDES wrote 03/15/2017 at 01:29 point

Here is a trick : don't care or compute the 2 lower bit of the address. This saves a bit of hardware and time.

The 2 LSB could contain mode bits, or even the carry bit, so you can keep the latches, but the '283 take a while to fully update through the carry chain.

I found 16-bits adders on eBay, see

https://hackaday.io/project/8121-discrete-yasep/log/28461-a-reasonable-discrete-alu

https://hackaday.io/project/8121-discrete-yasep/log/28438-what-chips-for-the-alu

But what I think you need is the 74HC193 : a preloadable counter, which i use for the #Discrete YASEP's register set : https://hackaday.io/project/8121-discrete-yasep/log/28548-counters-counters-counters

This way, you save adders (use them for the ALU), you save MUXes and you save latches !

  Are you sure? yes | no

Phil Wright wrote 03/15/2017 at 02:38 point

Every time I pat myself on the back for getting something to work, it turns out there is a cleverer way to do it. But that is good, that is how you learn. Even this slow path of 8 carries working their way through the system is not going to be the longest path in the machine. I am looking into creating the ALU and for a 32-bit processor that means I need a 5 level barrel shifter!

  Are you sure? yes | no

Yann Guidon / YGDES wrote 03/15/2017 at 11:49 point

Barrel shifter ? Don't waste your time ;-)
https://hackaday.io/project/8121/log/28207-barrel-shifter

https://hackaday.io/project/8121-discrete-yasep/log/28271-barrel-shifter-2

https://hackaday.io/project/8121-discrete-yasep/log/28427-barrel-shifter-3

It looks imposing but it's quite regular and the critical datapath (CDP) is only 5 circuits for 32 bits.

  Are you sure? yes | no